From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] Replace lambda functions added to org-mode-hook with named funcs Date: Fri, 05 Oct 2018 12:42:47 +0200 Message-ID: <87lg7cptco.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8NZU-0000Mv-4D for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 06:43:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8NZQ-0001V2-7G for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 06:43:00 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:48121) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8NZN-0001Pb-6D for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 06:42:54 -0400 In-Reply-To: (Kaushal Modi's message of "Thu, 4 Oct 2018 11:10:55 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Kaushal Modi Cc: emacs-org list Hello, Kaushal Modi 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