Received: (at 35351) by debbugs.gnu.org; 23 Apr 2019 12:00:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 23 08:00:00 2019 Received: from localhost ([127.0.0.1]:52615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIu5g-0004za-3P for submit <at> debbugs.gnu.org; Tue, 23 Apr 2019 08:00:00 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:40960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1hIu5d-0004zQ-J7 for 35351 <at> debbugs.gnu.org; Tue, 23 Apr 2019 07:59:58 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3NBxrYN010074; Tue, 23 Apr 2019 07:59:54 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 071CB66184; Tue, 23 Apr 2019 07:59:51 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Phil Sainty <psainty@HIDDEN> Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <jwv1s1torxi.fsf-monnier+emacs@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> <jwvsgu9pj9f.fsf-monnier+emacs@HIDDEN> <1c020e77-3a71-4b84-c15d-752062b8b8db@HIDDEN> Date: Tue, 23 Apr 2019 07:59:51 -0400 In-Reply-To: <1c020e77-3a71-4b84-c15d-752062b8b8db@HIDDEN> (Phil Sainty's message of "Tue, 23 Apr 2019 15:52:18 +1200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6531=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6531> : inlines <7058> : streams <1819491> : uri <2836081> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > which does not require quoting), but I'm also not terribly happy with > "before-hook", as I now feel it's quite ambiguous. While "before-hook" may not be perfect, it has the very definitive advantage of matching the existing "after-hook", so we should go with that. If/when we find a better naming scheme for those two, we can consider renaming them, but that itself comes with non-negligible disadvantages, so we're probably better off living with the existing "suboptimal" names. More important would be to make sure that the new semantics covers most of the existing needs. Stefan
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 23 Apr 2019 03:52:24 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 23:52:24 2019 Received: from localhost ([127.0.0.1]:52130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hImTo-0005ho-IS for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 23:52:24 -0400 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:53735) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hImTm-0005hf-1z for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 23:52:22 -0400 Received: from [150.107.172.17] (port=33682 helo=[192.168.20.103]) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hImTi-0006ZO-N3; Tue, 23 Apr 2019 15:52:18 +1200 Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code To: Stefan Monnier <monnier@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> <jwvsgu9pj9f.fsf-monnier+emacs@HIDDEN> From: Phil Sainty <psainty@HIDDEN> Message-ID: <1c020e77-3a71-4b84-c15d-752062b8b8db@HIDDEN> Date: Tue, 23 Apr 2019 15:52:18 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <jwvsgu9pj9f.fsf-monnier+emacs@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On 23/04/19 2:08 PM, Stefan Monnier wrote: >>> Oh, you're absolutely right, it's called ":after-hook" because it >>> runs after the mode-hook. >> Which means :before-hook definitely isn't a good name for the new >> keyword. > > It's run before the before-change-mode-hook, so the name isn't > completely wrong (and the description of :before-hook makes this > connection clear). > >> Should I go with :eval-before ? > > I'd prefer we avoid "eval" since that would suggest to quote the form. > IOW, I think `:before-hook` is fine. Point taken re: eval (although at minimum we have `with-eval-after-load' which does not require quoting), but I'm also not terribly happy with "before-hook", as I now feel it's quite ambiguous. Running a derived mode involves all of the following hooks: * change-major-mode-hook * change-major-mode-after-body-hook * *-mode-hook(s) * after-change-major-mode-hook * delayed-after-hook-functions So "before hook" (and "after hook") are pretty vague. Especially when the "hook" in question is different in each case. The documentation would indeed clarify, but I think it's sensible to choose a name which gives a clearer idea from the outset. My other suggestion of :before-change still seems reasonable to me. -Phil
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 23 Apr 2019 02:09:03 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 22:09:03 2019 Received: from localhost ([127.0.0.1]:52043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIkrm-0000zT-MI for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 22:09:03 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:52360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1hIkrk-0000z2-Li for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 22:09:01 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3N28wmw019687; Mon, 22 Apr 2019 22:08:59 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 4508F66184; Mon, 22 Apr 2019 22:08:58 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Phil Sainty <psainty@HIDDEN> Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <jwvsgu9pj9f.fsf-monnier+emacs@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> Date: Mon, 22 Apr 2019 22:08:58 -0400 In-Reply-To: <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> (Phil Sainty's message of "Tue, 23 Apr 2019 11:18:31 +1200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6530=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6530> : inlines <7058> : streams <1819452> : uri <2835931> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) >> Oh, you're absolutely right, it's called ":after-hook" because it >> runs after the mode-hook. > Which means :before-hook definitely isn't a good name for the new > keyword. It's run before the before-change-mode-hook, so the name isn't completely wrong (and the description of :before-hook makes this connection clear). > Should I go with :eval-before ? I'd prefer we avoid "eval" since that would suggest to quote the form. IOW, I think `:before-hook` is fine. Stefan
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 22 Apr 2019 23:31:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 19:31:59 2019 Received: from localhost ([127.0.0.1]:51888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIiPn-0003Zo-Jv for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 19:31:59 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:44693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hIiPl-0003Zf-LD for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 19:31:58 -0400 Received: from [150.107.172.17] (port=44472 helo=[192.168.20.103]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hIiPj-0001yf-5p; Tue, 23 Apr 2019 11:31:55 +1200 Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code From: Phil Sainty <psainty@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> Message-ID: <af6c149b-ed78-c5b1-88fa-7b4020624c6e@HIDDEN> Date: Tue, 23 Apr 2019 11:31:54 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On 23/04/19 11:18 AM, Phil Sainty wrote: > On 23/04/19 2:39 AM, Stefan Monnier wrote: >> Oh, you're absolutely right, it's called ":after-hook" because it >> runs after the mode-hook. > > Which means :before-hook definitely isn't a good name for the new > keyword. > > Should I go with :eval-before ? Or maybe this pairing would be reasonable: :before-change :after-hook Other suggestions welcomed. -Phil
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 22 Apr 2019 23:18:36 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 19:18:36 2019 Received: from localhost ([127.0.0.1]:51870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIiCq-0003G5-IM for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 19:18:36 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:37958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hIiCo-0003Fw-Rv for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 19:18:35 -0400 Received: from [150.107.172.17] (port=33802 helo=[192.168.20.103]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hIiCl-0001BO-IZ; Tue, 23 Apr 2019 11:18:31 +1200 Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code To: Stefan Monnier <monnier@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> From: Phil Sainty <psainty@HIDDEN> Message-ID: <3a0b9268-4800-1513-8422-065a74bb6b36@HIDDEN> Date: Tue, 23 Apr 2019 11:18:31 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On 23/04/19 2:39 AM, Stefan Monnier wrote: >> I'm now unsure whether :after-hook was intended to be interpreted >> as "this is a bit like a *hook* which runs *after* everything >> else has happened"; or if it meant "do this thing *after* the >> mode *hook*" (or indeed after after-change-major-mode-hook). > > Oh, you're absolutely right, it's called ":after-hook" because it > runs after the mode-hook. Which means :before-hook definitely isn't a good name for the new keyword. Should I go with :eval-before ? And should I add :eval-after as an alias for :after-hook, for naming symmetry? (Even if :after-hook makes better sense than you initially thought, it's maybe still not the best name for it.) >> In the initial commit I've used an approach which will run the >> parent's :before-hook > > That seems backward to me. > >> Possibly it should be child-before-parent on the basis that the >> author then has more influence over the order in which things >> happen? > > Exactly. Cool. I'm switching that around. -Phil
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 22 Apr 2019 14:41:38 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 10:41:38 2019 Received: from localhost ([127.0.0.1]:51219 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIa8Y-0000fW-3X for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 10:41:38 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:44602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1hIa8W-0000fM-03 for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 10:41:36 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3MEfWGP007660; Mon, 22 Apr 2019 10:41:33 -0400 Received: by ceviche.home (Postfix, from userid 20848) id CF2586619A; Mon, 22 Apr 2019 10:41:32 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Phil Sainty <psainty@HIDDEN> Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <jwvftqaqf2m.fsf-monnier+emacs@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> Date: Mon, 22 Apr 2019 10:41:32 -0400 In-Reply-To: <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> (Phil Sainty's message of "Mon, 22 Apr 2019 20:16:33 +1200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 3 Rules triggered TRK_NCM1=0.1, EDT_SA_DN_PASS=0, RV6530=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6530> : inlines <7058> : streams <1819406> : uri <2835738> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > I've pushed an implementation to branch origin/fix/bug-35351 as a > starter. > > https://git.savannah.gnu.org/cgit/emacs.git/log?h=fix/bug-35351 BTW, could you try and look around emacs/lisp/.../*.el to see which other existing major modes could benefit from such a thing (and maybe also if they almost could but in the end can't for some reason). Stefan
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 22 Apr 2019 14:39:33 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 10:39:32 2019 Received: from localhost ([127.0.0.1]:51215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIa6W-0000bm-LV for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 10:39:32 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:57752) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1hIa6R-0000bb-MW for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 10:39:31 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3MEdPFb019153; Mon, 22 Apr 2019 10:39:25 -0400 Received: by ceviche.home (Postfix, from userid 20848) id ED7EF6619A; Mon, 22 Apr 2019 10:39:24 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Phil Sainty <psainty@HIDDEN> Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <jwvlg02qfbk.fsf-monnier+emacs@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> Date: Mon, 22 Apr 2019 10:39:24 -0400 In-Reply-To: <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> (Phil Sainty's message of "Mon, 22 Apr 2019 20:16:33 +1200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6530=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6530> : inlines <7058> : streams <1819406> : uri <2835737> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Yes, I think I like that least of all -- having the macro set up > everything based on a different name to the mode that people are > expected to be using just seems wrong to me. I tend to view this as the fact that those "modes" should distinguish between the mode and the command that invokes it, because that command does more than setup the mode (e.g. it arranges to be able to go back to the earlier modes). E.g. in your case the mode could be called `so-long-mode` and the command to enter it could be `so-long`. > I'm now unsure whether :after-hook was intended to be interpreted > as "this is a bit like a *hook* which runs *after* everything > else has happened"; or if it meant "do this thing *after* the > mode *hook*" (or indeed after after-change-major-mode-hook). Oh, you're absolutely right, it's called ":after-hook" because it runs after the mode-hook. > In the initial commit I've used an approach which will run the > parent's :before-hook That seems backward to me. > Possibly it should be child-before-parent on the basis that the > author then has more influence over the order in which things > happen? Exactly. Stefan
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 22 Apr 2019 08:16:41 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 22 04:16:41 2019 Received: from localhost ([127.0.0.1]:49656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIU81-00039L-Ak for submit <at> debbugs.gnu.org; Mon, 22 Apr 2019 04:16:41 -0400 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:60118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hIU7y-00039C-DN for 35351 <at> debbugs.gnu.org; Mon, 22 Apr 2019 04:16:39 -0400 Received: from [150.107.172.17] (port=44713 helo=[192.168.20.103]) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hIU7t-0000rE-L1; Mon, 22 Apr 2019 20:16:34 +1200 Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code To: Stefan Monnier <monnier@HIDDEN>, 35351 <at> debbugs.gnu.org References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> From: Phil Sainty <psainty@HIDDEN> Message-ID: <7db75b50-1925-8c1e-acc5-c393b701e6a3@HIDDEN> Date: Mon, 22 Apr 2019 20:16:33 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 35351 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On 22/04/19 8:54 AM, Stefan Monnier wrote: > Usually this is done with something akin to: > (define-derived-mode my-actual-mode > ...) > (defun my-mode () > (my-save-local-vars) > (my-actual-mode)) > > or something similar (or not using define-derived-mode). > Of course, this comes with its own drawbacks. Yes, I think I like that least of all -- having the macro set up everything based on a different name to the mode that people are expected to be using just seems wrong to me. I'd say the fact that there's a known "usual" hack for this suggests that there's good reason to implement it directly in the macro. > Indeed what you're asking for is like a :before-hook symmetric I've pushed an implementation to branch origin/fix/bug-35351 as a starter. https://git.savannah.gnu.org/cgit/emacs.git/log?h=fix/bug-35351 Previous Emacs versions will ignore the unrecognised keyword and its value; so libraries using the new keyword and still wanting to support older versions of Emacs can safely use the new keyword and *conditionally* add advice when the Emacs version is < 27, to run the same code before the mode function and achieve the same effect. > (FWIW, I think the "-hook" part of the name was probably not > the best choice). I've used the name :before-hook to match the existing :after-hook, but we can certainly change it to something else. (We could potentially deprecate the name :after-hook as well, and add an alias for that with a better name at the same time.) I'm now unsure whether :after-hook was intended to be interpreted as "this is a bit like a *hook* which runs *after* everything else has happened"; or if it meant "do this thing *after* the mode *hook*" (or indeed after after-change-major-mode-hook). The name ":before-hook" only really matches the former interpretation. ("before the mode hook" would be more change-major-mode-after-body-hook than change-major-mode-hook). Would :eval-before and :eval-after be good? It might also be nice if symbol values for these keywords were interpreted as the name of a function to call. I don't think that change would be *expected* to break anything, as a symbol value would in effect be a no-op for the current :after-hook, and so I wouldn't expect any existing modes to be using a symbol value. In the initial commit I've used an approach which will run the parent's :before-hook before the child's :before-hook, using the change-major-mode-hook technique I mentioned at the end of my original message, although I'm still uncertain about which order is *best*. Possibly it should be child-before-parent on the basis that the author then has more influence over the order in which things happen? i.e.: If we implement it like this: ,child-before-hook (delay-mode-hooks (,(or parent 'kill-all-local-variables)) Which gives us the sequence: child-before-hook parent-before-hook change-major-mode-hook Then child-before-hook could, if it wanted, do this: (add-hook 'change-major-mode-hook FOO nil :local) And then FOO would run *after* the parent-before-hook, effectively reversing that sequence. (Whereas the code I've pushed initially is already using that change-major-mode-hook approach, so there's no scope to manipulate the order.) Child-before-parent also means :before-hook *really is* the very first thing that happens in the child mode, just as :after-hook is the very last; so perhaps that's still a good/intuitive way around, even if it's the reverse of the parent->child order used in all the other phases of the mode's execution. Child-before-parent would also match the order when 'before' advice was being used to mimic the :before-hook behaviour in older versions of Emacs. I'm not sure I have a strong opinion on the matter, and the cases in which it would even matter would be limited, but I think I've now argued myself around to being slightly in favour of child- before-parent; so if no one else has strong feelings about it, I'll most likely change it to that. -Phil
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 21 Apr 2019 20:55:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 21 16:55:02 2019 Received: from localhost ([127.0.0.1]:49178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hIJUM-00071u-E9 for submit <at> debbugs.gnu.org; Sun, 21 Apr 2019 16:55:02 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:42422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1hIJUL-00071S-4m for 35351 <at> debbugs.gnu.org; Sun, 21 Apr 2019 16:55:01 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3LKsurf004905; Sun, 21 Apr 2019 16:54:57 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 2EB1E66184; Sun, 21 Apr 2019 16:54:55 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: 35351 <at> debbugs.gnu.org Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <jwv4l6rrsw8.fsf-monnier+emacs@HIDDEN> References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cancel-Lock: sha1:bpqvxISS+t8fl/8nB958SaPCFwo= Date: Sun, 21 Apr 2019 16:54:55 -0400 In-Reply-To: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> (Phil Sainty's message of "Sun, 21 Apr 2019 14:35:35 +1200") MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6529=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6529> : inlines <7058> : streams <1819336> : uri <2835456> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: Phil Sainty <psainty@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > I'm currently using `change-major-mode-hook' for this, but it has > occurred to me that it would be nicer if this hook code of mine > only ever ran in the case where it is useful (i.e. the major mode > being changed to is in fact my mode). There's no need for a "hook" for that. You just need to put the code to save the old values before calling kill-all-local-variables. > (A vaguely analogous facility currently in `define-derived-mode' > is the :after-hook keyword, for running code very *late* in the > proceedings.) Indeed what you're asking for is like a :before-hook symmetric (FWIW, I think the "-hook" part of the name was probably not the best choice). Usually this is done with something akin to: (define-derived-mode my-actual-mode ...) (defun my-mode () (my-save-local-vars) (my-actual-mode)) or something similar (or not using define-derived-mode). Of course, this comes with its own drawbacks. Stefan
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at 35351) by debbugs.gnu.org; 21 Apr 2019 06:02:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 21 02:02:01 2019 Received: from localhost ([127.0.0.1]:47296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hI5Y9-0001Yl-0b for submit <at> debbugs.gnu.org; Sun, 21 Apr 2019 02:02:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37103) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <rms@HIDDEN>) id 1hI5Y6-0001YY-Vu for 35351 <at> debbugs.gnu.org; Sun, 21 Apr 2019 02:01:59 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rms@HIDDEN>) id 1hI5Y1-00009j-CT; Sun, 21 Apr 2019 02:01:53 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from <rms@HIDDEN>) id 1hI5Xz-0007hl-CQ; Sun, 21 Apr 2019 02:01:51 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman <rms@HIDDEN> To: Phil Sainty <psainty@HIDDEN> In-Reply-To: <09a9ac76-ed6c-e6c2-9967-761a61fcfda4@HIDDEN> (message from Phil Sainty on Sun, 21 Apr 2019 14:45:15 +1200) Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> <09a9ac76-ed6c-e6c2-9967-761a61fcfda4@HIDDEN> Message-Id: <E1hI5Xz-0007hl-CQ@HIDDEN> Date: Sun, 21 Apr 2019 02:01:51 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35351 Cc: 35351 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: rms@HIDDEN Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > I forgot to mention the other hack solution which occurred to me, > which is for the library which defines the major mode to add its > own before-advice for that major mode function. We have adopted the design principle that advice is for users to add, and nothing else. This is because developers investigating why a call to the function foo doesn't work as expected will not think of the possibility that foo has advice. Thus, our design rule is that, if you want some code to be run before or after calls to foo, add code to foo to run a hook. This way, the code for foo will show developers that a hook is called. -- Dr Richard Stallman President, Free Software Foundation (https://gnu.org, https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 21 Apr 2019 02:45:29 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 20 22:45:29 2019 Received: from localhost ([127.0.0.1]:47228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hI2Tw-0004kp-NQ for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:45:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hI2Tv-0004kb-F7 for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:45:28 -0400 Received: from lists.gnu.org ([209.51.188.17]:37288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2Tp-0003o7-KN for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:45:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2To-0005L0-HS for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:45:21 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_20,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2Tm-0003kC-4U for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:45:20 -0400 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:52039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2Tl-0003jc-Du for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:45:18 -0400 Received: from [150.107.172.17] (port=44172 helo=[192.168.20.103]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hI2Tj-0002Bl-Gk for bug-gnu-emacs@HIDDEN; Sun, 21 Apr 2019 14:45:15 +1200 Subject: Re: bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code To: bug-gnu-emacs@HIDDEN References: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> From: Phil Sainty <psainty@HIDDEN> Message-ID: <09a9ac76-ed6c-e6c2-9967-761a61fcfda4@HIDDEN> Date: Sun, 21 Apr 2019 14:45:15 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 60.234.4.59 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) I forgot to mention the other hack solution which occurred to me, which is for the library which defines the major mode to add its own before-advice for that major mode function. This also seems a bit ugly to me -- but maybe not quite as ugly as using a 'fake parent' mode. It's a slightly more flexible solution, at any rate. -Phil
bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 21 Apr 2019 02:40:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 20 22:40:22 2019 Received: from localhost ([127.0.0.1]:47220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hI2Oz-0004cb-Ug for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:40:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <psainty@HIDDEN>) id 1hI2Ox-0004cO-Da for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:40:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:51208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2Oo-0001Ts-SB for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 22:40:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2On-0004h3-Ab for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:40:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2KU-0006zl-80 for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:35:43 -0400 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:59751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <psainty@HIDDEN>) id 1hI2KT-0006xG-Tr for bug-gnu-emacs@HIDDEN; Sat, 20 Apr 2019 22:35:42 -0400 Received: from [150.107.172.17] (port=56784 helo=[192.168.20.103]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from <psainty@HIDDEN>) id 1hI2KO-0001kI-Am for bug-gnu-emacs@HIDDEN; Sun, 21 Apr 2019 14:35:36 +1200 To: bug-gnu-emacs@HIDDEN From: Phil Sainty <psainty@HIDDEN> Subject: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code Message-ID: <85237c18-768d-089b-221a-fe70b0ba4379@HIDDEN> Date: Sun, 21 Apr 2019 14:35:35 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 60.234.4.59 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) The library I'm working on (so-long.el) defines a major mode which needs to remember various buffer-local values as they were in the original mode, *before* my major mode takes effect. I'm currently using `change-major-mode-hook' for this, but it has occurred to me that it would be nicer if this hook code of mine only ever ran in the case where it is useful (i.e. the major mode being changed to is in fact my mode). `change-major-mode-hook' has no knowledge of the mode which has just been invoked, so it must necessarily run for *every* mode change -- which isn't relevant to my library in the vast majority of cases. I think `change-major-mode-hook' would more commonly be used by modes to handle any subsequent 'unloading' needs of that same mode in case it gets replaced later on (i.e. the mode body could set a buffer-local hook value), so my scenario of the new mode wanting to know things about the previous mode is doubtless a bit of a niche case; but I thought I'd raise it for discussion. `define-derived-mode' creates the mode function like so: (defun ,child () ,docstring (interactive) ; Run the parent. (delay-mode-hooks (,(or parent 'kill-all-local-variables)) Where PARENT must likewise `kill-all-local-variables' (which runs `change-major-mode-hook'). What would be nice is a way for the mode definition to provide code which would be evaluated before that (delay-mode-hooks...) form, and consequently acted like a `change-major-mode-hook' which only ever happened if this mode was called. (A vaguely analogous facility currently in `define-derived-mode' is the :after-hook keyword, for running code very *late* in the proceedings.) I could always define my mode without using the macro, and then do whatever I wanted before calling `kill-all-local-variables'; but I *want* to have the benefits of using the macro, so I don't want to resort to that; I just want the equivalent ability, while still using the macro. A hack which works in my case (because my mode was not already derived from another) is: (defun my-mode-parent () (do-my-custom-thing) (kill-all-local-variables)) (define-derived-mode my-mode my-mode-parent ...) This feels a little ugly, and `derived-mode-make-docstring' will point out the existence of the parent, so it's not ideal; but I'm still tempted to use this approach, and simply document it sufficiently such that the docstring reference won't cause undue confusion for those who follow it. That hack obviously can't be used in cases where a parent is already defined, but my suggested new feature could still work in those cases. Something like: (defun ,child () ,docstring (interactive) ,@before-hook ; Run the parent. (delay-mode-hooks (,(or parent 'kill-all-local-variables)) If the new child mode is used directly then things pan out almost identically to the hack version. More generally, we end up with: ,@child-before-hook (delay-mode-hooks ,@parent-before-hook (delay-mode-hooks ,@grandparent-before-hook (delay-mode-hooks (kill-all-local-variables) ;; runs change-major-mode-hook ,@grandparent-body) (run-mode-hooks 'grandparent-mode-hook) ,@parent-body) (run-mode-hooks 'parent-mode-hook) ,@child-body) (run-mode-hooks 'child-mode-hook) Which creates the following sequence of events: ,@child-before-hook ,@parent-before-hook ,@grandparent-before-hook (kill-all-local-variables) ;; runs change-major-mode-hook ,@grandparent-body ,@parent-body ,@child-body (run-hooks 'change-major-mode-after-body-hook) (run-hooks 'grandparent-mode-hook) (run-hooks 'parent-mode-hook) (run-hooks 'child-mode-hook) (run-hooks 'after-change-major-mode-hook) Obviously that sequence of 'before-hook' instances is in the reverse sequence to the 'body' and 'mode-hook' sequences. That's possibly a desirable thing, but I'm not absolutely certain. A simply way of reversing that sequence would be for each :before-hook to be added as a buffer-local change-major-mode-hook entry -- (add-hook 'change-major-mode-hook FOO nil :local) -- rather than evaluating them immediately, which would then build up a buffer-local hook sequence like: '(grandparent-before-hook parent-before-hook child-before-hook) And then `kill-all-local-variables' would run them in that order (and still ahead of any other pre-existing buffer-local values for `change-major-mode-hook'). What do people think? -Phil
Phil Sainty <psainty@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#35351
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.