Skip to content

Commit 97c3462

Browse files
committed
Name hook for change-major-mode-after-body-hook
1 parent a6038e9 commit 97c3462

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cmake-font-lock.el

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,15 +1490,13 @@ To activate this every time a CMake file is opened, use the following:
14901490
;; This ensures that this package is enabled automatically when
14911491
;; installed as a package (when cmake-mode is installed).
14921492

1493-
;; Note: Personally, I dislike adding lambda expressions to hooks.
1494-
;; However, in this case it's required to ensure that this package
1495-
;; isn't loaded until it's actually used.
1496-
14971493
;;;###autoload
1498-
(add-hook 'change-major-mode-after-body-hook
1499-
(lambda ()
1500-
(when (apply #'derived-mode-p cmake-font-lock-modes)
1501-
(cmake-font-lock-activate))))
1494+
(progn
1495+
(defun cmake-font-lock-maybe-activate ()
1496+
"Call `cmake-font-lock-activate' in `cmake-font-lock-modes'."
1497+
(when (apply #'derived-mode-p cmake-font-lock-modes)
1498+
(cmake-font-lock-activate)))
1499+
(add-hook 'change-major-mode-after-body-hook #'cmake-font-lock-maybe-activate))
15021500

15031501

15041502
(defun cmake-font-lock-add-keywords (name keywords)

0 commit comments

Comments
 (0)