emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 989eed2 11/14: Add to after-change-major-mode-hook at load


From: Phil
Subject: [elpa] master 989eed2 11/14: Add to after-change-major-mode-hook at load time
Date: Sat, 11 Jul 2020 00:57:56 -0400 (EDT)

branch: master
commit 989eed266e13997d572a459fbcf07e49c0058d3a
Author: Phil Sainty <psainty@orcon.net.nz>
Commit: Phil Sainty <psainty@orcon.net.nz>

    Add to after-change-major-mode-hook at load time
    
    This feels a little cleaner.  We are already adding the related
    advice at load time, so this change is consistent with that.
    
    Unless a major mode has been delighted, neither this hook function
    nor the advice have any practical effect.  Both are removed by
    `unload-feature'.
---
 delight.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/delight.el b/delight.el
index 5e6526d..d7af68f 100644
--- a/delight.el
+++ b/delight.el
@@ -185,12 +185,13 @@ for this purpose).  These FILE options are relevant to 
minor modes only.
 
 For major modes you should specify the keyword :major as the value of FILE,
 to prevent the mode being treated as a minor mode."
-  (add-hook 'after-change-major-mode-hook #'delight-major-mode)
   (let ((glum (if (consp spec) spec (list (list spec value file)))))
     (while glum
       (cl-destructuring-bind (mode &optional value file) (pop glum)
         (assq-delete-all mode delight-delighted-modes)
         (add-to-list 'delight-delighted-modes (list mode value file))
+        ;; Major modes are handled in `after-change-major-mode-hook'.
+        ;; Minor modes are handled at load time:
         (unless (eq file :major)
           (eval-after-load (if (eq file t) 'emacs (or file mode))
             `(when (featurep 'delight)
@@ -237,6 +238,9 @@ If the delighted VALUE is not a string and not nil, we do 
nothing."
             (setf (cadr menu-def) new-label)
             (define-key menu-keymap (vector mode) menu-def)))))))
 
+;; Handle major modes at call time.
+(add-hook 'after-change-major-mode-hook #'delight-major-mode)
+
 (defun delight-major-mode ()
   "Delight the 'pretty name' of the current buffer's major mode
 when displayed in the mode-line.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]