branch: elpa/flycheck
commit 7d7f45f92e94fd00bf1b1ee5404bb130fe624a48
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Guard Tools menu operations for Emacs configs without it
Check that the Tools menu exists before adding or removing the
Flycheck menu item. This prevents errors in configurations like
Doom Emacs that remove the Tools menu.
Closes #2032
---
flycheck.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/flycheck.el b/flycheck.el
index 749da05dc8..36884e33a5 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -1278,7 +1278,8 @@ Only has effect when variable `global-flycheck-mode' is
non-nil."
["Read the Flycheck manual" flycheck-manual t]))
"Menu of command `flycheck-mode'.")
-(easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking")
+(when (lookup-key global-map [menu-bar tools])
+ (easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking"))
@@ -1322,7 +1323,8 @@ just return nil."
(defun flycheck-unload-function ()
"Unload function for Flycheck."
(global-flycheck-mode -1)
- (easy-menu-remove-item nil '("Tools") (cadr flycheck-mode-menu-map))
+ (when (lookup-key global-map [menu-bar tools])
+ (easy-menu-remove-item nil '("Tools") (cadr flycheck-mode-menu-map)))
(remove-hook 'kill-emacs-hook #'flycheck-global-teardown)
(setq find-function-regexp-alist
(assq-delete-all 'flycheck-checker find-function-regexp-alist)))