emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [RFC] Replace lambda functions added to org-mode-hook with named funcs
Date: Fri, 05 Oct 2018 12:42:47 +0200	[thread overview]
Message-ID: <87lg7cptco.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAFyQvY1rmrzacc2gUdFKhmbW3PEKa0v0d2Ke1LhfoXC4bZJDqQ@mail.gmail.com> (Kaushal Modi's message of "Thu, 4 Oct 2018 11:10:55 -0400")

Hello,

Kaushal Modi <kaushal.modi@gmail.com> 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

  reply	other threads:[~2018-10-05 10:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 15:10 [RFC] Replace lambda functions added to org-mode-hook with named funcs Kaushal Modi
2018-10-05 10:42 ` Nicolas Goaziou [this message]
2018-10-06 13:42   ` Kaushal Modi
  -- strict thread matches above, loose matches on Subject: below --
2019-10-01  5:00 Phil Sainty
2019-10-06  9:54 ` stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg7cptco.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).