diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-15 15:10:19 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-15 15:10:19 -0500 |
| commit | 2034dba7572813703b74d4e25b845cddef5346e9 (patch) | |
| tree | f0df2819a7a3ff9990eb117ba971c990f2e0a338 /modules | |
| parent | f9da2ccf8cbcd227b373fbc3c053f92405a3b186 (diff) | |
| download | dotemacs-2034dba7572813703b74d4e25b845cddef5346e9.tar.gz dotemacs-2034dba7572813703b74d4e25b845cddef5346e9.zip | |
feat(yas): activate yasnippet globally with fundamental-mode extras
The yasnippet use-package block switches from `:hook (prog-mode . yas-minor-mode)` to `:demand t` + `(yas-global-mode 1)`. That makes yas-minor-mode active in every buffer, not just prog-mode-derived ones.
I added a small helper, `cj/--yas-activate-fundamental-extras`, attached as `:hook (yas-minor-mode . ...)`. It calls `(yas-activate-extra-mode 'fundamental-mode)` so the snippet table at `snippets/fundamental-mode/` is consulted in every buffer regardless of the buffer's own major mode. That's what makes universal triggers like `<cj` work everywhere.
The new `tests/test-prog-general-yas-activation.el` covers both wiring (yas-global-mode on, fundamental-mode in yas-extra-modes, yas-minor-mode active in org/text buffers) and end-to-end expansion (the marker snippet expands correctly in fundamental, text, org, emacs-lisp, and python-ts modes). 9 tests, all green; full unit suite green with no regressions.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/prog-general.el | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/prog-general.el b/modules/prog-general.el index 45b83ca78..e7dd4989c 100644 --- a/modules/prog-general.el +++ b/modules/prog-general.el @@ -248,15 +248,23 @@ If no such file exists there, display a message." ;; ---------------------------------- Snippets --------------------------------- ;; reusable code and text +(defun cj/--yas-activate-fundamental-extras () + "Activate `fundamental-mode' as an extra yasnippet mode in this buffer. +Hooked onto `yas-minor-mode-hook' so every buffer also consults +`snippets/fundamental-mode/' regardless of the buffer's own major mode. +This is what makes universal snippets like =<cj= work in any buffer." + (yas-activate-extra-mode 'fundamental-mode)) + (use-package yasnippet - :commands (yas-new-snippet yas-visit-snippet-file yas-global-mode) - :hook (prog-mode . yas-minor-mode) + :demand t :bind ("C-c s n" . yas-new-snippet) ("C-c s e" . yas-visit-snippet-file) + :hook (yas-minor-mode . cj/--yas-activate-fundamental-extras) :config (setq yas-snippet-dirs (list snippets-dir)) - (yas-reload-all)) + (yas-reload-all) + (yas-global-mode 1)) ;; --------------------- Display Color On Color Declaration -------------------- ;; display the actual color as highlight to color hex code |
