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?

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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.