Emacs Asked by siery on December 19, 2021
I been reading a blog post from Chris Wanstrath from 2010 where he write about coffee-mode
. He proposed there this functions hook:
(defun coffee-custom ()
"coffee-mode-hook"
;; Emacs key binding
(define-key coffee-mode-map [(meta r)] 'coffee-compile-buffer))
(add-hook 'coffee-mode-hook (lambda () (coffee-custom)))
In coffee-mode.el
you can see similar hook call
"... Add `(lambda () (coffee-cos-mode t))' to `coffee-mode-hook' to turn
it on by default."
I don’t understand the use of lambda calling another function in order to execute it. Why not simply:
(add-hook 'coffee-mode-hook #'my:coffee-custom)
Resources: http://ozmm.org/posts/coffee_mode.html
(add-hook 'coffee-mode-hook '(lambda () (coffee-custom)))
Definitely not recommended.
(add-hook 'coffee-mode-hook #'coffee-custom)
would be better (for many reasons).In coffee-mode.el you can see similar hook call
"... Add `'(lambda () (coffee-cos-mode t))' to `coffee-mode-hook'
This one at least had a purpose, as it's passing an argument; however:
coffee-cos-mode
is a minor mode defined with the standard macro then the argument will be redundant in this scenario (since Emacs 24.1), in which case you could just add #'coffee-cos-mode
to the hook, in the same fashion as the previous scenario.Answered by phils on December 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP