emacs - add a hook in prog-mode except a particular mode -


i have function

(defun a--before-test-save-hook()   "test of before save hook"   (message "foobar")) 

and want run in prog-mode except python-mode, have no clue , add-hook in prog-mode including python-mode

(add-hook 'prog-mode (lambda ()                        (add-hook 'before-save-hook 'a-test-before-save-hook t t))) 

i have try

(defun a-test-before-save-hook()   "test of before save hook"   (unless (eq major-mode 'python-mode)     (message "foobar"))) 

but want better try,any solution appreciated.

not sure if it's better, do:

(add-hook 'prog-mode-hook           (lambda ()             (unless (derived-mode-p 'python-mode)               (add-hook 'before-save-hook                         #'a-test-before-save-hook t t)))) 

of course, own reflex ask "what makes python special?". answer might let replace (derived-mode-p 'python-mode) test goes more directly @ heart of issue (e.g. maybe issue related indentation-significance , hence apply coffeescript , haskell , maybe check electric-indent-inhibit instead).


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -