[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [RFC] Replace lambda functions added to org-mode-hook with named fun
[O] [RFC] Replace lambda functions added to org-mode-hook with named funcs
Thu, 4 Oct 2018 11:10:55 -0400
Yesterday, while helping someone out with why their custom
functions added to org-mode-hook didn't work, I asked them to reveal
the value of org-mode-hook, and they presented this as the default
value of org-mode-hook once Org was loaded:
[add-hook change-major-mode-hook org-show-block-all append local]
[add-hook change-major-mode-hook org-babel-show-result-all
Going down the rabbit hole, I discovered many places in Org source
where lambdas were added to org-mode-hook.
I propose to replace such lamba functions with named functions.
Here's an example of diff on maint branch, after making one such change:
diff --git a/lisp/org.el b/lisp/org.el
index 2cc9b6a1c..9f28502d4 100644
@@ -7429,10 +7429,10 @@ a block. Return a non-nil value when toggling
(when (eq (overlay-get ov 'invisible) 'org-hide-block)
-;; Remove overlays when changing major mode
- (lambda () (add-hook 'change-major-mode-hook
- 'org-show-block-all 'append 'local)))
+(defun org--unfold-all-blocks-on-major-mode-change ()
+ "Remove overlays when changing major mode."
+ (add-hook 'change-major-mode-hook #'org-show-block-all 'append 'local))
+(add-hook 'org-mode-hook #'org--unfold-all-blocks-on-major-mode-change)
If there is no objection to this, I can fix this everywhere in maint,
and then merge that into master.
- [O] [RFC] Replace lambda functions added to org-mode-hook with named funcs,
Kaushal Modi <=