key-bindings – Conflicto entre emmet-mode y yasnippet, misma tecla de activación

Pregunta:

Quiero que tanto emmet-mode como el yasnippet activen con la misma tecla C-return : en un búfer en html-mode , C-return primero debería probar yas-expand y luego emmet-expand-line si no se encontró un fragmento adecuado.

Parece que me falta algo sobre las palabras clave vinculantes en use-package . Actualmente, solo el emmet-mode está activo en un búfer HTML.

lisp / init-emmet.el

(use-package emmet-mode
  :defer t
  :init
  (add-hook 'css-mode-hook 'emmet-mode)
  (add-hook 'sgml-mode-hook 'emmet-mode)
  :config
  (setq-default
   emmet-move-cursor-between-quotes t
   emmet-preview-default nil)
  (unbind-key "C-M-<left>" emmet-mode-keymap)
  (unbind-key "C-M-<right>" emmet-mode-keymap))

lisp / init-yasnippet.el

(use-package yasnippet
  :defer t
  :bind (:map yas-minor-mode-map ("<C-return>" . yas-expand))
  :init
  (add-hook 'js-mode-hook 'yas-minor-mode)
  (add-hook 'sgml-mode-hook 'yas-minor-mode)
  :config
  (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
  (yas-reload-all)
  (unbind-key "TAB" yas-minor-mode-map))

Respuesta:

Terminé usando hippie-expand que está integrado en Emacs (¿24+?).

modo emmet

(use-package emmet-mode
  :defer t
  :init
  (add-hook 'css-mode-hook 'emmet-mode)
  (add-hook 'sgml-mode-hook 'emmet-mode)
  :config
  (setq-default emmet-move-cursor-between-quote t)
  (unbind-key "<C-return>" emmet-mode-keymap)
  (unbind-key "C-M-<left>" emmet-mode-keymap)
  (unbind-key "C-M-<right>" emmet-mode-keymap))

hippie-expandir

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

yasnippet

(use-package yasnippet
  :defer t
  :init
  (add-hook 'js-mode-hook 'yas-minor-mode)
  (add-hook 'sgml-mode-hook 'yas-minor-mode)
  :config
  (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
  (yas-reload-all)
  (unbind-key "TAB" yas-minor-mode-map)
  (unbind-key "<tab>" yas-minor-mode-map))

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

web tasarım