emmet-mode: bind to TAB & enable in reason-mode

TAB now either indents, expands the snippet at point, or expands the
emmet expression at point.

Also it now falls back to emmet-expand-line if yasnippet won't load.
This commit is contained in:
Henrik Lissner 2018-08-01 19:25:06 +02:00
parent 8bbff852f7
commit a876d87f5e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 21 additions and 5 deletions

View file

@ -105,3 +105,18 @@ function @ http://ergoemacs.org/emacs/elisp_replace_html_entities_command.html"
"Decode HTML entities in region."
(interactive "r")
(+web--entities-region beg end t))
;;;###autoload
(defun +web/indent-or-yas-or-emmet-expand ()
"Invoke `indent-for-tab-command' if at or before text bol, `yas-expand' if on
a snippet, or `emmet-expand-yas'/`emmet-expand-line', depending on whether
`yas-minor-mode' is enabled or not."
(interactive)
(call-interactively
(cond ((<= (current-column) (current-indentation))
#'indent-for-tab-command)
((bound-and-true-p yas-minor-mode)
(if (yas--templates-for-key-at-point)
#'yas-expand
#'emmet-expand-yas))
(#'emmet-expand-line))))