elisp - Emacs: use add-hook inside function (defun) -
if i do
(ad-hook 'hascal-mode-hook (lambda (Setq Indent-Tabs-Mode T) (Setting Tab Width 4) (Message "OK")))
In my ~ / .emacs.d / init
, then executes (lambda ...)
when I enter Haskell-Mode
.
However, if I have a function like this:
(hook-temode tiered) (Ad-hook hook (Lambda () (Satac Indent) -Tabs-mode temode) (Setac tab-width Twidth) (message "OK"))))
and then later it ~ / .emacs.d / init. Call in el
:
(my-add-hook 'is Hascale-mode-hook T4)
then nothing happens (Even "OK" message is not displayed). Is add-hook /
a special function that can not be used within defun
? I have the per-project settings defined in a separate initialization file that detects the buffer name and adds (lambda () ...
which is in the appropriate key mode (in the example above, Haskell Mode
); I want to reduce the vocabulary of code using a thin wrapper like my-add-hook
, but I can not tell why < Code> Ad-hook is very difficult.
EDIT1: Explanation D added.
EDIT2: When I try to use my-add- I get the message "File mode Specification error: (zero-variable TMode)" message I hook < / Code>.
This is a simple improvement without the need to know about lexical binding: / P> (Defuse My Ad-hook (hook temode twdth) (ad-hook hook) (lambda () (satac indent tabs-mode, mode) (Set-tab-width, twdth) (Message "OK")))
Comments
Post a Comment