From: Amin Bandali Date: Tue, 27 Aug 2019 05:34:03 +0000 (-0400) Subject: emacs: yasnippet: don’t expand on SPC in git-commit-mode X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/commitdiff_plain/5b185efac27892a4c7bc567820442085045d2a8a?ds=sidebyside emacs: yasnippet: don’t expand on SPC in git-commit-mode guix provides snippets like ‘add’ [0] which would get auto-expanded in git-commit-mode with SPC, super annoying. [0]: https://git.savannah.gnu.org/cgit/guix.git/tree/etc/snippets/text-mode/guix-commit-message-add-package --- diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4002d9a..6210f90 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1518,7 +1518,16 @@ This function is intended for use with `ivy-ignore-buffers'." (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) (yas-reload-all) (setq yas-verbosity yas-verbosity-cur) - (define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand) + + (defun b/yas--maybe-expand-key-filter (cmd) + (when (and (yas--maybe-expand-key-filter cmd) + (not (bound-and-true-p git-commit-mode))) + cmd)) + (defconst b/yas-maybe-expand + '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter)) + (define-key yas-minor-mode-map + (kbd "SPC") b/yas-maybe-expand) + (yas-global-mode)) (use-package debbugs)