I wrote a simple major mode for a configuration file.
I would like to check the syntax upon saving.
How to make sure the my-check-syntax
is added to after-save-hook
iff it is under my-config-mode
.
(defun my-check-syntax ()
;; code: print a message to show whether syntax is correct
)
(define-derived-mode my-config-mode nil "my-config"
(setq-local font-lock-defaults '(my-config-font-lock-keywords))
;; (add-hook 'after-save-hook #'my-check-syntax)
)
(add-to-list 'auto-mode-alist '("\\.myconfigure\\'" . my-config-mode))
Use the LOCAL
argument to add-hook
and remove-hook
.