diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-03-12 14:52:40 +0100 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-03-12 14:52:40 +0100 |
| commit | 6c9bccd962d94f21b4e2e9c1878479e606fd71db (patch) | |
| tree | 7216314e45304b5c74ec0977272f39d0faca230d | |
| parent | eac219367e29090437775699df84900a030969a4 (diff) | |
No longer provide a non-global mode
Before this, font-locking was not properly refreshed when toggling
the global mode.
| -rw-r--r-- | llama.el | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -414,27 +414,32 @@ expansion, and the looks of this face should hint at that.") ;;;###autoload (define-minor-mode llama-fontify-mode - "Toggle fontification of the `##' macro and its positional arguments." + "Highlight the `##' macro in Emacs Lisp mode." :lighter llama-fontify-mode-lighter - (if llama-fontify-mode - (font-lock-add-keywords nil llama-font-lock-keywords) - (font-lock-remove-keywords nil llama-font-lock-keywords))) - -(defun llama--turn-on-fontify-mode () - "Enable `llama-fontify-mode' if in an Emacs Lisp buffer." - (when (derived-mode-p #'emacs-lisp-mode) - (llama-fontify-mode))) - -;;;###autoload -(define-globalized-minor-mode global-llama-fontify-mode - llama-fontify-mode llama--turn-on-fontify-mode) + :global t + (cond + (llama-fontify-mode + (add-hook 'emacs-lisp-mode-hook #'llama--add-font-lock-keywords)) + (t + (remove-hook 'emacs-lisp-mode-hook #'llama--add-font-lock-keywords))) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (derived-mode-p 'emacs-lisp-mode) + (if llama-fontify-mode + (font-lock-add-keywords nil llama-font-lock-keywords) + (font-lock-remove-keywords nil llama-font-lock-keywords)) + (font-lock-flush))))) + +(defun llama--add-font-lock-keywords () + (font-lock-add-keywords nil llama-font-lock-keywords)) + +(define-obsolete-function-alias 'global-llama-fontify-mode + #'llama-fontify-mode "Llama 0.6.2") (define-advice lisp--el-match-keyword (:override (limit) llama -80) (catch 'found (while (re-search-forward - (concat (if llama-fontify-mode - "(\\(?:## ?\\)?\\(" - "(\\(") + (concat "(\\(?:## ?\\)?\\(" (static-if (get 'lisp-mode-symbol 'rx-definition) ;>= 29.1 (rx lisp-mode-symbol) lisp-mode-symbol-regexp) |
