[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [RFC] Replace lambda functions added to org-mode-hook with named
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [RFC] Replace lambda functions added to org-mode-hook with named funcs |
Date: |
Fri, 05 Oct 2018 12:42:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hello,
Kaushal Modi <address@hidden> writes:
> 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
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -7429,10 +7429,10 @@ a block. Return a non-nil value when toggling
> is successful."
> (when (eq (overlay-get ov 'invisible) 'org-hide-block)
> (delete-overlay ov))))))))
>
> -;; Remove overlays when changing major mode
> -(add-hook 'org-mode-hook
> - (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 that's a function added to `org-mode-hook', it is not useful to add
"on major mode change".
> If there is no objection to this, I can fix this everywhere in maint,
> and then merge that into master.
Please make changes in "master" instead, and merge them into "next"
then.
Regards,
--
Nicolas Goaziou