0

I use hippie-expand with emmet and yasnippet.

(use-package emmet-mode
  :init
  (add-hook 'css-mode-hook 'emmet-mode)
  (add-hook 'sgml-mode-hook 'emmet-mode)
  :config (unbind-key "<C-return>" emmet-mode-keymap))

(use-package hippie-exp
  :bind ("<C-return>" . hippie-expand)
  :config
  (setq-default
   hippie-expand-try-functions-list '(yas-hippie-try-expand emmet-expand-line)))

(use-package yasnippet
  :init
  (add-hook 'emacs-lisp-mode 'yas-minor-mode)
  (add-hook 'js-mode-hook 'yas-minor-mode)
  (add-hook 'org-mode-hook 'yas-minor-mode)
  (add-hook 'sgml-mode-hook 'yas-minor-mode)
  :config (yas-reload-all))
  1. It works fine with js-mode, org-mode and with html-mode. But with emacs-lisp-mode and with lisp-interaction-mode, hippie-expand always delegate completion to emmet-expand-line.

  2. Emmet completion is still available in non-emmet'ified buffers after an emmet'ified one has been opened (css-mode-hook and sgml-mode-hook). Is the right way to fix this to change hippie-expand-try-functions-list on prog-mode-hook depending on the current major mode?

How can I setup hippie-expand with emmet and yasnippet to fix these 2 issues?

Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30

1 Answers1

1

It works fine with js-mode, org-mode and with html-mode. But with emacs-lisp-mode and with lisp-interaction-mode, hippie-expand always delegate completion to emmet-expand-line.

It's a typo in your config: you're adding to emacs-lisp-mode instead of emacs-lisp-mode-hook.

Emmet completion is still available in non-emmet'ified buffers after an emmet'ified one has been opened (css-mode-hook and sgml-mode-hook). Is the right way to fix this to change hippie-expand-try-functions-list on prog-mode-hook depending on the current major mode?

That should work. Alternatively you could use a function that only operates when emmet-mode is enabled:

(defun emmet-hippie-try-expand-line (args)
  (interactive "P")
  (when emmet-mode
    (emmet-exand-line args)))
(setq-default hippie-expand-try-functions-list
              '(yas-hippie-try-expand
                emmet-hippie-try-expand-line))
npostavs
  • 9,033
  • 1
  • 21
  • 53