Received: (at 69511) by debbugs.gnu.org; 3 Mar 2024 08:19:33 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 03 03:19:33 2024 Received: from localhost ([127.0.0.1]:39732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rgh4G-0006H6-QY for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 03:19:33 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:39399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rgh4E-0006Gs-9W for 69511 <at> debbugs.gnu.org; Sun, 03 Mar 2024 03:19:31 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id E9D0060004; Sun, 3 Mar 2024 08:18:34 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#69511: Restore any state after revert-buffer In-Reply-To: <867cikpkpm.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 02 Mar 2024 20:11:49 +0200") Organization: LINKOV.NET References: <86y1b0r00p.fsf@HIDDEN> <867cikpkpm.fsf@HIDDEN> Date: Sun, 03 Mar 2024 09:59:24 +0200 Message-ID: <864jdnpw83.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69511 Cc: 69511 <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 (-) >> This patch adds a new variable 'revert-buffer-state-functions' >> that will allow any state to be saved and restored, >> not only the currently hard-coded 'read-only' state: > > It isn't clear what you mean by "state" here. It seems like you are > talking about functions to be called after reverting a buffer in order > to do whatever is appropriate after reverting. And if so, why > "state"? For example, one of your examples, with > outline-minor-mode-highlight-buffer, is not about "state", but about > re-highlighting the buffer after reverting it. "state" here is in the same sense as is already used in 'revert-buffer': (let ((state (and (boundp 'read-only-mode--state) (list read-only-mode--state)))) (prog1 (funcall (or revert-buffer-function #'revert-buffer--default) ignore-auto noconfirm) (when state (setq buffer-read-only (car state)) (setq-local read-only-mode--state (car state))))) > So I would suggest calling this "revert-buffer-post-revert-functions", > and updating the doc string to make it clear that the purpose is more > general. "post" can't be used because these functions are called before 'revert-buffer-function'. "pre" would be better but still has no hint that the returned lambdas will be called after 'revert-buffer-function' to restore a state. >> +(defvar-local revert-buffer-state-functions nil >> + "Functions to save and restore any state during `revert-buffer'. >> +This variable is a list of functions that are called before >> +reverting the buffer. These functions should return a lambda >> +that will be called after reverting the buffer >> +to restore a previous state saved in that lambda.") > > The last sentence needs to be reworded, because it is not clear how > functions (in plural) can return a lambda (in singular). Also, the > doc string should describe how the function is called (with no > arguments, I guess?), and that all those functions will be called one > by one in the order of the list. Here is an improved docstring: (defvar-local revert-buffer-state-functions nil "Functions to save and restore any state during `revert-buffer'. This variable is a list of functions that are called before reverting the buffer. Each of these functions are called without arguments and should return a lambda that can restore a previous state of the buffer. Then after reverting the buffer each of these lambdas will be called one by one in the order of the list to restore previous states of the buffer. An example of the buffer state is keeping the buffer read-only, or keeping minor modes, etc.") > Finally, this needs to be documented in NEWS and the ELisp reference > manual. If this docstring is ok, then it could be adapted to the ELisp reference manual.
bug-gnu-emacs@HIDDEN
:bug#69511
; Package emacs
.
Full text available.Received: (at 69511) by debbugs.gnu.org; 3 Mar 2024 08:19:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 03 03:19:10 2024 Received: from localhost ([127.0.0.1]:39729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rgh3u-0006GX-FB for submit <at> debbugs.gnu.org; Sun, 03 Mar 2024 03:19:10 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:53193) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rgh3s-0006Fr-4g for 69511 <at> debbugs.gnu.org; Sun, 03 Mar 2024 03:19:09 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id A4B841C0005; Sun, 3 Mar 2024 08:18:30 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Michael Heerdegen <michael_heerdegen@HIDDEN> Subject: Re: bug#69511: Restore any state after revert-buffer In-Reply-To: <87plwcvxqp.fsf@HIDDEN> (Michael Heerdegen's message of "Sun, 03 Mar 2024 03:46:06 +0100") Organization: LINKOV.NET References: <86y1b0r00p.fsf@HIDDEN> <87plwcvxqp.fsf@HIDDEN> Date: Sun, 03 Mar 2024 09:55:46 +0200 Message-ID: <86o7bvpwy5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69511 Cc: 69511 <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 (-) >> + (add-hook 'revert-buffer-state-functions >> + (lambda () >> + (when (bound-and-true-p outline-minor-mode) >> + (lambda () >> + (outline-minor-mode-highlight-buffer)))))) > > Side note: most of the time it's better to avoid to add lambdas to hooks > for several reasons (non-trivial identity checks; inspection of the > variable by the user) when possible. I remember Alan said this in bug#66750.
bug-gnu-emacs@HIDDEN
:bug#69511
; Package emacs
.
Full text available.Received: (at 69511) by debbugs.gnu.org; 3 Mar 2024 02:46:15 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 02 21:46:15 2024 Received: from localhost ([127.0.0.1]:39504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rgbrj-0002QQ-BD for submit <at> debbugs.gnu.org; Sat, 02 Mar 2024 21:46:15 -0500 Received: from mout.web.de ([212.227.15.4]:60067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1rgbrf-0002Q6-O8 for 69511 <at> debbugs.gnu.org; Sat, 02 Mar 2024 21:46:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1709433936; x=1710038736; i=michael_heerdegen@HIDDEN; bh=a8M3SeYwwA6qPqKfR5nNNQR3bo9Xf9vObwlLBDFgMNs=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References: Date; b=WcNyYIhITPn1sQvZaF1cKxSLNoGd8yHMynirOZ3tz4p3qwC50vT3Sbpee4UQRmjD BnRz5JpkC/ogJ9uhB1ZyWFBGxWQtFuNHWNHzuPUPZ9imXf4u1eHVQ2s2jgnzHtajA BOyTYoHkdTzcPTa/QywAO/0L18WgZuTUrDxFHF/QYyK2Zel69iZdNHzHqGz1qPC/X LC0fnjMCGrFa1nv5R+IGXOo6VZhOadsVGMgsF8oRoRU+5izeLXW7MF6kNzmly24Ob eIHaJZygF/urT67VsS9MKcit2PQjD/L8+zTxg+ok6P1yievS0LnKapz6ltlET3JRj HHkies9tTgA9bVAGrA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.76.229.82]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MpTxo-1r6A7I0ItY-00pnQP; Sun, 03 Mar 2024 03:45:36 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Juri Linkov <juri@HIDDEN> Subject: Re: bug#69511: Restore any state after revert-buffer In-Reply-To: <86y1b0r00p.fsf@HIDDEN> (Juri Linkov's message of "Sat, 02 Mar 2024 19:55:50 +0200") References: <86y1b0r00p.fsf@HIDDEN> Date: Sun, 03 Mar 2024 03:46:06 +0100 Message-ID: <87plwcvxqp.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:CSZN05/vFekxnMbFlmEBZS4lDusS6rrCWyHm2635e/pdgL+SK2K fv+Dc82mLPxhty+i4f2tWRYGB8iV7T7tkD4/Jd9N65QzEhs7xSFFnBNMToCjMoeFA5yb3l3 SLR4De4dSxKdU/80J2TNAMCmnZZZF/BjyUJuQ+Gs2fB6TTVSQxXkoHSscQ1dOkjFDkaKlyb Jip+kETUcQ5/1g8O+5IQg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:nz2uuFJvAJE=;nktJ+JaPdV/zo2TTawlqZMsZUIS kZigCdXeGUI/UA79VUxbzjzS7dWTcuij7qisyaioFbrkgZjOPhmfHRIJPNMlrWAR4gJWUOMQL ynQnOPAPrE02JUN5CSHm6mpXhN81Uxm2dNpbYJ/0dbmF284s33JuQEUo8j1hdK/mFCTby7ryr r/L/oZE/xOj5tmn1t/h0kyk/2e5HVpHlGGM7EY3GjTV5fvespBC8zS3e6myKdVDpoLt9POHWK s1kP94zjtFu7D7Fwb1f4DbDAu7Yv68IJII/0LBJ0KsjKYQNAK9JL+hGNhR5pwfY13kHJZj90H 6/xAzAhXfexvfhahy/iMmBihGiyRYalcWkjarA7jITEWeiZA8N3sbRNzk8k5joHL1+/mof35t UMjqAa2Un9P1JvlzD9hqTLtFDFit/a/WvWEXgwxHhe3VvCojDIfZimt7Qoij4YqAXcSpqp3ii dTL0vtC3XVy7mtqsMs45BjYHcnOvDBzWD3Xd+kmWGCqbuIZrOMvjjx9wbE3ibAb5sqoMX2xBB Nwdm4KQQ2ZatbTHY67BR0rxZedTk5aetpu6n82f+vesTyG176L+qmghmngHOB7I3d2t5HQl82 3gM0xM+4m73FfYf5v7kD19yowAuRbDmdV/37KmF44awaHfMeBOPZLEBbCAjK5My1F3ySYILCe DnJ12FhSzQ5YGqgEQevNyBTnR9Dw+sWOO2K9CTkh+Gcf0OHDAsgsh6iuub1dpi12SDCBoq+sJ X5bnMsjOhB2DliCphdpSSTrWW0L0Sn4G7RPG5jyl+ReKelz7kR4pdZZejBkMAZKft4JpuH6c+ DpP+d7Mo4eNgEjkvn9+0vqhtqJFboIxcy6Ce11OrLGcQs= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69511 Cc: 69511 <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 (-) Juri Linkov <juri@HIDDEN> writes: > + (add-hook 'revert-buffer-state-functions > + (lambda () > + (when (bound-and-true-p outline-minor-mode) > + (lambda () > + (outline-minor-mode-highlight-buffer)))))) Side note: most of the time it's better to avoid to add lambdas to hooks for several reasons (non-trivial identity checks; inspection of the variable by the user) when possible. Michael.
bug-gnu-emacs@HIDDEN
:bug#69511
; Package emacs
.
Full text available.Received: (at 69511) by debbugs.gnu.org; 2 Mar 2024 18:12:33 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 02 13:12:33 2024 Received: from localhost ([127.0.0.1]:39353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rgTqa-00060J-ND for submit <at> debbugs.gnu.org; Sat, 02 Mar 2024 13:12:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1rgTqV-0005zz-Uk for 69511 <at> debbugs.gnu.org; Sat, 02 Mar 2024 13:12:31 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1rgTpx-0005Be-Dv; Sat, 02 Mar 2024 13:11:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=r7FqtcuRBJdmG7WRusq+BFkPG5RN5E2MlVDRn5p4O6A=; b=ayyZrtNmVaCB WMro0NkwIaRwUakheGlZVXLXzJDs3hiF8/u83Q2bGFJpX7xks8T20a7aDYy6vqqSz9i+xFpSVFPpW au2YCFeEBi54DEEwq5XLo+UGIY035v+PCgOwYY61YMCSy8xPo6Zx8pFm/0mcWjKoP/U9NuTuYb53T VB3J5er0AVOVNf674oDb0cf4AqNba/zWQdEq1saPt3My3UDtPLbfgr5Z4JMJXHYsUUYjfHgqRX88I N8p6A5PTJVlWqxKbxd70AAc6nAwt8dq3XhsKCTq03i5e0mDbkxi09Y9ExWVoqgCz7JLP/mIMMbR6R PVv741QGAP4k3eHa9lOpNw==; Date: Sat, 02 Mar 2024 20:11:49 +0200 Message-Id: <867cikpkpm.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Juri Linkov <juri@HIDDEN> In-Reply-To: <86y1b0r00p.fsf@HIDDEN> (message from Juri Linkov on Sat, 02 Mar 2024 19:55:50 +0200) Subject: Re: bug#69511: Restore any state after revert-buffer References: <86y1b0r00p.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 69511 Cc: 69511 <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 (---) > From: Juri Linkov <juri@HIDDEN> > Date: Sat, 02 Mar 2024 19:55:50 +0200 > > This patch adds a new variable 'revert-buffer-state-functions' > that will allow any state to be saved and restored, > not only the currently hard-coded 'read-only' state: It isn't clear what you mean by "state" here. It seems like you are talking about functions to be called after reverting a buffer in order to do whatever is appropriate after reverting. And if so, why "state"? For example, one of your examples, with outline-minor-mode-highlight-buffer, is not about "state", but about re-highlighting the buffer after reverting it. So I would suggest calling this "revert-buffer-post-revert-functions", and updating the doc string to make it clear that the purpose is more general. > +(defvar-local revert-buffer-state-functions nil > + "Functions to save and restore any state during `revert-buffer'. > +This variable is a list of functions that are called before > +reverting the buffer. These functions should return a lambda > +that will be called after reverting the buffer > +to restore a previous state saved in that lambda.") The last sentence needs to be reworded, because it is not clear how functions (in plural) can return a lambda (in singular). Also, the doc string should describe how the function is called (with no arguments, I guess?), and that all those functions will be called one by one in the order of the list. Finally, this needs to be documented in NEWS and the ELisp reference manual. Thanks.
bug-gnu-emacs@HIDDEN
:bug#69511
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 2 Mar 2024 18:00:20 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 02 13:00:20 2024 Received: from localhost ([127.0.0.1]:39339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rgTel-0005g0-PY for submit <at> debbugs.gnu.org; Sat, 02 Mar 2024 13:00:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:34164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1rgTeh-0005fp-Kv for submit <at> debbugs.gnu.org; Sat, 02 Mar 2024 13:00:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1rgTeE-0000Au-RF for bug-gnu-emacs@HIDDEN; Sat, 02 Mar 2024 12:59:46 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1rgTeC-00087V-Jk for bug-gnu-emacs@HIDDEN; Sat, 02 Mar 2024 12:59:46 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1CB20FF802 for <bug-gnu-emacs@HIDDEN>; Sat, 2 Mar 2024 17:59:40 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: Restore any state after revert-buffer Organization: LINKOV.NET Date: Sat, 02 Mar 2024 19:55:50 +0200 Message-ID: <86y1b0r00p.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: juri@HIDDEN Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@HIDDEN; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.7 (-) 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.7 (--) --=-=-= Content-Type: text/plain This patch adds a new variable 'revert-buffer-state-functions' that will allow any state to be saved and restored, not only the currently hard-coded 'read-only' state: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=revert-buffer-state-functions.patch diff --git a/lisp/files.el b/lisp/files.el index ed18bc5841e..e8ecb351759 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6804,6 +6805,13 @@ revert-buffer-internal-hook ;; `preserve-modes' argument of `revert-buffer'. (defvar revert-buffer-preserve-modes) +(defvar-local revert-buffer-state-functions nil + "Functions to save and restore any state during `revert-buffer'. +This variable is a list of functions that are called before +reverting the buffer. These functions should return a lambda +that will be called after reverting the buffer +to restore a previous state saved in that lambda.") + (defun revert-buffer (&optional ignore-auto noconfirm preserve-modes) "Replace current buffer text with the text of the visited file on disk. This undoes all changes since the file was visited or saved. @@ -6854,13 +6862,16 @@ revert-buffer (let ((revert-buffer-in-progress-p t) (revert-buffer-preserve-modes preserve-modes) (state (and (boundp 'read-only-mode--state) - (list read-only-mode--state)))) + (list read-only-mode--state))) + (state-functions + (delq nil (mapcar #'funcall revert-buffer-state-functions)))) ;; Return whatever 'revert-buffer-function' returns. (prog1 (funcall (or revert-buffer-function #'revert-buffer--default) ignore-auto noconfirm) (when state (setq buffer-read-only (car state)) - (setq-local read-only-mode--state (car state)))))) + (setq-local read-only-mode--state (car state))) + (mapc #'funcall state-functions)))) (defun revert-buffer--default (ignore-auto noconfirm) "Default function for `revert-buffer'. --=-=-= Content-Type: text/plain One of numerous examples is to save and restore hidden outlines after doing 'revert-buffer': (add-hook 'Buffer-menu-mode-hook (lambda () (add-hook 'revert-buffer-state-functions (lambda () (let ((regexp (outline-hidden-headings-regexp))) (when regexp (lambda () (outline-hide-by-heading-regexp regexp)))))))) Currently this handles outlines only in the buffer list. But probably this settings should be added to outline-minor-mode. And here is the immediate need to use it to rehighlight the outlines after reverting the buffer list: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=outline-minor-mode-highlight-buffer.patch diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index ec5337e3fda..ae3f3e0035e 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -274,7 +276,12 @@ Buffer-menu-mode :interactive nil (setq-local buffer-stale-function (lambda (&optional _noconfirm) 'fast)) - (add-hook 'tabulated-list-revert-hook 'list-buffers--refresh nil t)) + (add-hook 'tabulated-list-revert-hook 'list-buffers--refresh nil t) + (add-hook 'revert-buffer-state-functions + (lambda () + (when (bound-and-true-p outline-minor-mode) + (lambda () + (outline-minor-mode-highlight-buffer)))))) (defun buffer-menu--display-help () (message "%s" --=-=-=--
Juri Linkov <juri@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#69511
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.