From unknown Sun Sep 07 13:36:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#79306 <79306@debbugs.gnu.org> To: bug#79306 <79306@debbugs.gnu.org> Subject: Status: Broken follow-mode Reply-To: bug#79306 <79306@debbugs.gnu.org> Date: Sun, 07 Sep 2025 20:36:14 +0000 retitle 79306 Broken follow-mode reassign 79306 emacs submitter 79306 Juri Linkov severity 79306 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 25 02:33:23 2025 Received: (at submit) by debbugs.gnu.org; 25 Aug 2025 06:33:23 +0000 Received: from localhost ([127.0.0.1]:47969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uqQle-0006AZ-LB for submit@debbugs.gnu.org; Mon, 25 Aug 2025 02:33:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:39774) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uqQlZ-0006AH-Ca for submit@debbugs.gnu.org; Mon, 25 Aug 2025 02:33:18 -0400 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 ) id 1uqQlR-0006FI-Hd for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 02:33:09 -0400 Received: from mout-p-201.mailbox.org ([80.241.56.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1uqQlJ-00043o-Bi for bug-gnu-emacs@gnu.org; Mon, 25 Aug 2025 02:33:09 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4c9LZZ5v97z9tHh for ; Mon, 25 Aug 2025 08:32:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756103574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=XFb+aNRNbEOm6JQaHxUHvDLgjDClpXIfXucYQQThhMk=; b=V77bH+ukpBpWVxyChRO09qrZUCCUkVblYUJmCErBiqW+6V9V3MFk8K+ZEo2qoBCkkstOgN xWT3GrQjVq8xASSFDBdmCQcVrEzNV0HuGgopjifaoQgOGbCfQp5JuxbBNe2kp5RZNKZbPY c/fs1dWyOV+Pj/8pafb7Gr52Y/5pN2QAUHeOe0P2RBVzjJHUS62ESti+ZBVEwA58UIcGO5 XXb4rIjg+kyor5rLmaYW50iSnpklt5UNs6NJT0p4sxd4hJ+CP58/RpxNVnrFyzPNUBTuwn QvrdZSSHF9eOC4U5JJ8wisvriUvFy0GkYEZAzDL1gBAp/gZL/iZE5S6HkynOpQ== From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: Broken follow-mode Organization: LINKOV.NET Date: Mon, 25 Aug 2025 09:30:10 +0300 Message-ID: <87qzwz2a40.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=80.241.56.171; envelope-from=juri@linkov.net; helo=mout-p-201.mailbox.org X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Some recent change in master broke display for follow-mode: 0. emacs -Q 1. visit a file in fundamental-mode, e.g. C-x C-f etc/COPYING RET 2. split horizontally C-x 3 3. M-x follow-mode RET 4. scroll down a few screens 5. type 'M-<' (beginning-of-buffer) It displays the message "Back to top level", but doesn't move to the beginning of the buffer. Typing 'C-l' updates the screen, and reveals that 'M-<' actually moved to the beginning of the buffer, but didn't update the screen. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 25 08:55:09 2025 Received: (at 79306) by debbugs.gnu.org; 25 Aug 2025 12:55:09 +0000 Received: from localhost ([127.0.0.1]:48973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uqWj6-0002LY-K6 for submit@debbugs.gnu.org; Mon, 25 Aug 2025 08:55:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36622) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uqWix-0002Kr-6x for 79306@debbugs.gnu.org; Mon, 25 Aug 2025 08:55:04 -0400 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 ) id 1uqWin-00060T-27; Mon, 25 Aug 2025 08:54:49 -0400 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=dlqNfxRJqNkqOvzDq48sxa4ciX29YH+LWrO5W8/CUrQ=; b=VG+fGqQo9ZF7 q2rKyjvR7REwpG8t3uozvWi6Wh0XwXnbiDQbeSM14bdjWDW2ZG9FXSD1oyVMm02kxJ/5Wtb7cAnBD TEx2KqlIFa0Q7rZC7vzR2TE0RE4pg49JXh8Sx3Ch3htF2OfQAsk64Laiv2IjGNpaEBXn0c43SgxUu AB1/epwGbbAQbOLZSiSlkwMCOrHJJdVMcwObZg0ksc+j/bO0Gt0OwyUW6wiB+LDUDLE0Adc+xFWVx 1FSAzoo9R6GIGE6Tmk+twIIhdMVt7K7BnkBfJ3C92I+RFwg5voPXvNOCDN6s4JoVW8ZaaGr3+t5po YWj1ICUuUm3y00s4PLlRGA==; Date: Mon, 25 Aug 2025 15:54:17 +0300 Message-Id: <86h5xvwohy.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov , Stefan Monnier In-Reply-To: <87qzwz2a40.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 25 Aug 2025 09:30:10 +0300) Subject: Re: bug#79306: Broken follow-mode References: <87qzwz2a40.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306 Cc: 79306@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Date: Mon, 25 Aug 2025 09:30:10 +0300 > > Some recent change in master broke display for follow-mode: > > 0. emacs -Q > 1. visit a file in fundamental-mode, e.g. > C-x C-f etc/COPYING RET > 2. split horizontally > C-x 3 > 3. M-x follow-mode RET > 4. scroll down a few screens > 5. type 'M-<' (beginning-of-buffer) > > It displays the message "Back to top level", > but doesn't move to the beginning of the buffer. Looks like the trap set by Stefan a month ago finally caught its first victim: follow-mode calls redisplay recursively, from pre-redisplay-function: Thread 1 hit Breakpoint 4, redisplay_internal () at xdisp.c:17122 17122 struct window *w = XWINDOW (selected_window); (gdb) bt #0 redisplay_internal () at xdisp.c:17122 #1 0x0104197e in redisplay_preserve_echo_area (from_where=2) at xdisp.c:18040 #2 0x00fe51f4 in Fredisplay (force=XIL(0)) at dispnew.c:7004 #3 0x0123da19 in funcall_subr (subr=0x13ee240 , numargs=0, args=0xa019120) at eval.c:3242 #4 0x012aa6a8 in exec_byte_code (fun=XIL(0xa0000000103368c0), args_template=514, nargs=2, args=0xa019128) at bytecode.c:805 #5 0x0123e30c in funcall_lambda (fun=XIL(0xa000000010336cd0), nargs=1, arg_vector=0xa019050) at eval.c:3333 #6 0x0123d3d2 in funcall_general (fun=XIL(0xa000000010336cd0), numargs=1, args=0xa019050) at eval.c:3125 #7 0x0123d6fb in Ffuncall (nargs=2, args=0xa019048) at eval.c:3174 #8 0x0123c472 in Fapply (nargs=2, args=0xa019048) at eval.c:2788 #9 0x0123dea4 in funcall_subr (subr=0x13fc600 , numargs=2, args=0xa019048) at eval.c:3265 #10 0x012aa6a8 in exec_byte_code (fun=XIL(0xa00000001033a090), args_template=128, nargs=1, args=0xbfdcd0) at bytecode.c:805 #11 0x0123e30c in funcall_lambda (fun=XIL(0xa00000001033a090), nargs=1, arg_vector=0xbfdcd0) at eval.c:3333 #12 0x0123d3d2 in funcall_general (fun=XIL(0xa00000001033a090), numargs=1, args=0xbfdcd0) at eval.c:3125 #13 0x0123d6fb in Ffuncall (nargs=2, args=0xbfdcc8) at eval.c:3174 #14 0x012386f0 in internal_condition_case_n (bfun=0x123d5af , nargs=2, args=0xbfdcc8, handlers=XIL(0x30), hfun=0x10151d3 ) at eval.c:1770 #15 0x01015307 in dsafe__call (inhibit_quit=true, f=0x123d5af , nargs=2, args=0xbfdcc8) at xdisp.c:3102 #16 0x0103711d in prepare_menu_bars () at xdisp.c:14054 #17 0x0103f95e in redisplay_internal () at xdisp.c:17283 #18 0x0103e65d in redisplay () at xdisp.c:16844 #19 0x011456ef in read_char (commandflag=1, map=XIL(0xc00000001711a630), prev_event=XIL(0), used_mouse_menu=0xbff31f, end_time=0x0) at keyboard.c:2672 #20 0x0115ee45 in read_key_sequence (keybuf=0xbff5f8, prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false, disable_text_conversion_p=false) at keyboard.c:11146 #21 0x011412ca in command_loop_1 () at keyboard.c:1424 #22 0x01238416 in internal_condition_case (bfun=0x1140c68 , handlers=XIL(0x90), hfun=0x113fcc1 ) at eval.c:1690 #23 0x011406cd in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1163 #24 0x012375a2 in internal_catch (tag=XIL(0x12a80), func=0x1140696 , arg=XIL(0x90)) at eval.c:1370 #25 0x01140638 in command_loop () at keyboard.c:1141 #26 0x0113f721 in recursive_edit_1 () at keyboard.c:749 #27 0x0113f9bf in Frecursive_edit () at keyboard.c:832 #28 0x0113a9aa in main (argc=2, argv=0xf02638) at emacs.c:2629 Lisp Backtrace: "redisplay" (0xa019120) "follow-adjust-window" (0xa0190b8) "follow-post-command-hook" (0xa019080) "follow-pre-redisplay-function" (0xa019050) "apply" (0xa019048) 0x1033a090 PVEC_CLOSURE "redisplay_internal (C function)" (0x0) Then we catch this and throw to top-level: int redisplay_counter_before = redisplay_counter; /* Use Qt to ensure debugger does not run, to reduce the risk of wanting to redisplay. */ val = internal_condition_case_n (f, nargs, args, Qt, dsafe_eval_handler); if (redisplay_counter_before != redisplay_counter) /* A nested redisplay happened, abort this one! */ /* FIXME: Rather than jump all the way to `top-level` we should exit only the current redisplay. */ Ftop_level (); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Is it allowed to perform redisplay from pre-redisplay-function? If so, we need to refine the above test, or maybe disable it when we call pre-redisplay-function. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 00:58:46 2025 Received: (at 79306) by debbugs.gnu.org; 4 Sep 2025 04:58:46 +0000 Received: from localhost ([127.0.0.1]:44483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uu23a-0001N6-7N for submit@debbugs.gnu.org; Thu, 04 Sep 2025 00:58:46 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46298) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uu23X-0001Mr-8V for 79306@debbugs.gnu.org; Thu, 04 Sep 2025 00:58:43 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 39F9580BF9; Thu, 4 Sep 2025 00:58:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1756961916; bh=IKRLFHknLdUF0HhzgoVa37eEKmwU6mYzo23EEDGh5h0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jd1+vYHk/C7mqW0zwvEDbWY+WLGukWOd7jjBpJXP1b+SwZYUDEtWzxf9UkYhDzJYL vGw+DUCxEaDlUXi1mldPxzyeYSppscjHF8L7qFPni9hc1PcF1J5M/Hzq6G8cEg6F4m /bovzhxTaCVAS9T3b1Qs0TE1I70vXKZT3B3XzUS42Xqc8hy5hYzWKh3/j73viRmUY0 WTsTMcK4kQU6DcgJn6UuRAYW8t3QW7QXYPAEC2IEXIXVm23g9dtsM8hiipwfByJGkt OF4KRiVRZ2ZL09HeVpLsWGG7Sma840pFFQ5vyx/jOGBA3QJ1MppFFXqwdJg6cA2zxC 4ZXb3YdUOatMQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id EDBED8081F; Thu, 4 Sep 2025 00:58:35 -0400 (EDT) Received: from alfajor (69-165-161-194.dsl.teksavvy.com [69.165.161.194]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 67E881205D4; Thu, 4 Sep 2025 00:58:35 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#79306: Broken follow-mode In-Reply-To: <86h5xvwohy.fsf@gnu.org> Message-ID: References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> Date: Thu, 04 Sep 2025 00:58:34 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.190 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306 Cc: 79306@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Is it allowed to perform redisplay from pre-redisplay-function? Yeah, I think `pre-redisplay-function` is still early enough that it happens before we start messing with the state, so it's safe. I guess that means it can be called with a normal `call` rather than `safe_call`. > If so, we need to refine the above test, or maybe disable it when we > call pre-redisplay-function. Agreed. Maybe with something like the patch below? Stefan diff --git a/src/xdisp.c b/src/xdisp.c index 89561d750b6..e486eb177c1 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14059,7 +14059,8 @@ prepare_menu_bars (void) windows = Fcons (this, windows); } } - dsafe_calln (true, Vpre_redisplay_function, windows); + /* FIXME: Bind 'inhibit_quit'. */ + calln (true, Vpre_redisplay_function, windows); } /* Update all frame titles based on their buffer names, etc. We do From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 02:16:05 2025 Received: (at 79306) by debbugs.gnu.org; 4 Sep 2025 06:16:05 +0000 Received: from localhost ([127.0.0.1]:44816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uu3GO-0006Cr-Nk for submit@debbugs.gnu.org; Thu, 04 Sep 2025 02:16:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53776) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uu3GK-0006By-9A for 79306@debbugs.gnu.org; Thu, 04 Sep 2025 02:16:03 -0400 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 ) id 1uu3GD-0002DU-V5; Thu, 04 Sep 2025 02:15:53 -0400 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=7hc+4tKCbJ8J3tqkj/QZGwLbYQrYrV4+5GawFLTrowo=; b=onTRZbQe4yzJ nt7rTWdH8aSY5rtKxvGqJCbL4hcijGFm8ncSExmbMDQ3vL6685+FtqzCHfP1N1+sazrdMjRiBA7jQ PAQWyX7TcRblmVA8Oa7JTbFN07+CV+R2x8HVn2gdpPA3MTWKcChybcVP5KYy7ub7x5rxdXSBCqTet Rxd/Z14RK5LxxnRpGqSCMvDlmotdaqY+vX0iwlV65c5Q3/NJ5p5bGv3HBpmYt/RtEfOQxGLbD+Z+K eAf0C1LBwNj/rxuHiDOqkiw2QP1y1gt1+rpatQi1M8A55RHQ9QgwhfylK92YqH+MXkfn/TGjYrvTx O3RXgPvXWOwbAN9Vyuwa/w==; Date: Thu, 04 Sep 2025 09:15:51 +0300 Message-Id: <86a53akajs.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Thu, 04 Sep 2025 00:58:34 -0400) Subject: Re: bug#79306: Broken follow-mode References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306 Cc: 79306@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: Juri Linkov , 79306@debbugs.gnu.org > Date: Thu, 04 Sep 2025 00:58:34 -0400 > > > Is it allowed to perform redisplay from pre-redisplay-function? > > Yeah, I think `pre-redisplay-function` is still early enough that it > happens before we start messing with the state, so it's safe. I guess > that means it can be called with a normal `call` rather than > `safe_call`. > > > If so, we need to refine the above test, or maybe disable it when we > > call pre-redisplay-function. > > Agreed. Maybe with something like the patch below? I guess so (but we need a comment there explaining the reason for not calling dsafe_call). And why didn't you bind inhibit_quit? One other thing we should perhaps consider: before you introduced the redisplay_counter thing, redisplay_internal would in this case return immediately at the beginning: /* I don't think this happens but let's be paranoid. In particular, this was observed happening when Emacs shuts down due to losing X connection, in which case accessing SELECTED_FRAME and the frame structure is likely to barf. */ if (redisplaying_p) return; In case of follow-mode, this means the call to 'redisplay' in follow-adjust-window would previously do nothing. So the change you propose will avoid the top-level throw, but it might produce behavior in follow-mode that is different from what we had in Emacs 30. I don't use follow-mode, so I don't know what that could cause, but maybe someone who does could run with the patch and see if anything unexpected happens? From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 18:41:38 2025 Received: (at 79306) by debbugs.gnu.org; 4 Sep 2025 22:41:38 +0000 Received: from localhost ([127.0.0.1]:49615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuIe9-00015Y-HD for submit@debbugs.gnu.org; Thu, 04 Sep 2025 18:41:37 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13372) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uuIe2-00015A-GV for 79306@debbugs.gnu.org; Thu, 04 Sep 2025 18:41:34 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D589880966; Thu, 4 Sep 2025 18:41:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1757025683; bh=3atbKNCltAaWIlP/LNL6QKoHJBAc5PzjfAct05SEwas=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=X53mCE75hwthUt9B3BYXPalORAi4PtuevU0OZvOZYtV+u/33bPQCF2hWSxr5BIXXY k6CM1r/KGGhmSCoLDLKA4LZ/KpNeKmWo2t4r4RMLJ2VwkdCOBfaWluRuQRv3RXat7p HE4T/BUNyrBPBOnYFxX2fx2hEMcYbvqrGx3TZpI3ddRpGutKmX6/VTH1poSULSJcOQ 313C41UpuGgPhSa6AmIFlRFge3Zxk7+/R5zDlqhVNFmdqMatQ4p9gJHNwdOfNojjEK PA1kebjdvq1GsqpTByBjPOSjbKQw9UKyIs+HHJj4cB0hw3zxAep5cPl+p2X4jTEFV0 V+8VnUQpSLr+w== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id EAAF28034C; Thu, 4 Sep 2025 18:41:22 -0400 (EDT) Received: from alfajor (69-165-161-194.dsl.teksavvy.com [69.165.161.194]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B8ABC120607; Thu, 4 Sep 2025 18:41:22 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#79306: Broken follow-mode In-Reply-To: <86a53akajs.fsf@gnu.org> Message-ID: References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> <86a53akajs.fsf@gnu.org> Date: Thu, 04 Sep 2025 18:41:21 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.132 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306 Cc: 79306@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I guess so (but we need a comment there explaining the reason for not > calling dsafe_call). And why didn't you bind inhibit_quit? I just wanted to express the intent. > One other thing we should perhaps consider: before you introduced the > redisplay_counter thing, redisplay_internal would in this case return > immediately at the beginning: > > /* I don't think this happens but let's be paranoid. In particular, > this was observed happening when Emacs shuts down due to losing X > connection, in which case accessing SELECTED_FRAME and the frame > structure is likely to barf. */ > if (redisplaying_p) > return; Oh, very good point. So maybe we just need the last two hunks below and the not the first. Stefan diff --git a/src/xdisp.c b/src/xdisp.c index 89561d750b6..763d9902486 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14059,7 +14059,15 @@ prepare_menu_bars (void) windows = Fcons (this, windows); } } - dsafe_calln (true, Vpre_redisplay_function, windows); + { + /* We used to use 'dsafe_call' here, but actually we have not touched + the redisplay state yet, so it's still safe to exit non-locally. */ + specpdl_ref count = SPECPDL_INDEX (); + specbind (Qinhibit_quit, Qt); + specbind (Qinhibit_redisplay, Qt); + calln (Vpre_redisplay_function, windows); + unbind_to (count, val); + } } /* Update all frame titles based on their buffer names, etc. We do @@ -17137,8 +17145,6 @@ redisplay_internal (void) bool polling_stopped_here = false; Lisp_Object tail, frame; - redisplay_counter++; - /* Set a limit to the number of retries we perform due to horizontal scrolling, this avoids getting stuck in an uninterruptible infinite loop (Bug #24633). */ @@ -17197,6 +17203,8 @@ redisplay_internal (void) return; #endif + redisplay_counter++; + /* Record a function that clears redisplaying_p when we leave this function. */ specpdl_ref count = SPECPDL_INDEX (); From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 02:24:07 2025 Received: (at 79306) by debbugs.gnu.org; 5 Sep 2025 06:24:07 +0000 Received: from localhost ([127.0.0.1]:50644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuPrj-0001sK-74 for submit@debbugs.gnu.org; Fri, 05 Sep 2025 02:24:07 -0400 Received: from mout-p-103.mailbox.org ([2001:67c:2050:0:465::103]:46948) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uuPrc-0001rW-0H for 79306@debbugs.gnu.org; Fri, 05 Sep 2025 02:24:03 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4cJ5s430nwz9tcd; Fri, 5 Sep 2025 08:23:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1757053432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OPEYKmQeidcBQIh9kJchWQ/tc8LzfXZJB/F/RXtPlUU=; b=X2+3QbFxMNpIlkYgbTFj3oFJnn10K7T5k2GvYY6XjcwsEqLU1q/HSheeMXv+jMXz64uLQF RWmzhgeL+mQUVoU32KoZQk783gvRwzCG/grB9ul21l3jE9V4jO3zrbA+BLpo/PKPskD4Oh xeVkeNQf57T+rGNnmjFfH2vqRVH8O3fge02mO5oHSzVjn4O5yep8x3C97YPjGUSxPWKxBD 9zaQuwIL2A+QA7LF6yXMu8HK9kM8QKu2bSuR8ifTFUqocL9lttzpE4PIMbpiP554Z5r0cH ZkSTr9lBPzaRHWINNmxepgnX5WHp2OCVB1N9euia2x7iL/s+IiYFR+Oxv5LoXw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: Stefan Monnier Subject: Re: bug#79306: Broken follow-mode In-Reply-To: Organization: LINKOV.NET References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> <86a53akajs.fsf@gnu.org> Date: Fri, 05 Sep 2025 09:20:07 +0300 Message-ID: <871pola0a0.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4cJ5s430nwz9tcd X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79306 Cc: Eli Zaretskii , 79306@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > So maybe we just need the last two hunks below and the not the first. The first patch produced compilation warnings and crashed, the first hunk of this patch even doesn't compile. But with the last two hunks follow-mode works correctly as before. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 02:45:44 2025 Received: (at 79306) by debbugs.gnu.org; 5 Sep 2025 06:45:45 +0000 Received: from localhost ([127.0.0.1]:50741 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuQCe-0003He-FR for submit@debbugs.gnu.org; Fri, 05 Sep 2025 02:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47132) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uuQCb-0003HK-6Q for 79306@debbugs.gnu.org; Fri, 05 Sep 2025 02:45:42 -0400 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 ) id 1uuQCT-0000L5-JA; Fri, 05 Sep 2025 02:45:34 -0400 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=3Tn2hf+/JMbgi3R82EAgRuI25IdWvGZIYxz5GVQhoZE=; b=gzpf8y/JuHCm v+EvDO8r6jjG/WxP9uJ919YBOJMpJ8sqSoA9NH5ej4NWiyroPpy7v5spqMRP9ujTqiJbVgLlUz7/0 A42fk58X6Du0TySR2DP/tZylfN7VhXgfSm084zUYyztgbZV2S53jS3i0ReI3s7mBpnvFdsO830gyo MKQnb+PJuxZrDIwNWoF8gezFvdSz2caj9GdODqHdV+ox5OO8PPYqyxSq74niFud6bWb9bqTVv7kIP 1Oct8j4AyRjQY+b/q71Q1av/ywDUOiHjKS1fGlOul8FHckGO3wj8GWie9J0YiFMpGLR01nI4QXZvU 0IFDKoGxzIbcpGhO4BuIag==; Date: Fri, 05 Sep 2025 09:45:30 +0300 Message-Id: <86plc5ieid.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Thu, 04 Sep 2025 18:41:21 -0400) Subject: Re: bug#79306: Broken follow-mode References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> <86a53akajs.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306 Cc: 79306@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: juri@linkov.net, 79306@debbugs.gnu.org > Date: Thu, 04 Sep 2025 18:41:21 -0400 > > > I guess so (but we need a comment there explaining the reason for not > > calling dsafe_call). And why didn't you bind inhibit_quit? > > I just wanted to express the intent. > > > One other thing we should perhaps consider: before you introduced the > > redisplay_counter thing, redisplay_internal would in this case return > > immediately at the beginning: > > > > /* I don't think this happens but let's be paranoid. In particular, > > this was observed happening when Emacs shuts down due to losing X > > connection, in which case accessing SELECTED_FRAME and the frame > > structure is likely to barf. */ > > if (redisplaying_p) > > return; > > Oh, very good point. > So maybe we just need the last two hunks below and the not the first. Sounds good, thanks. Though if we do this, wouldn't it render the entire machinery of redisplay_counter effectively disabled, since redisplaying_p is set right after we increment redisplay_counter? Juri, can you try those two hunks and see if there are any problems left in follow-mode? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 15:12:48 2025 Received: (at 79306-done) by debbugs.gnu.org; 5 Sep 2025 19:12:48 +0000 Received: from localhost ([127.0.0.1]:57527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uubrc-0004xg-53 for submit@debbugs.gnu.org; Fri, 05 Sep 2025 15:12:48 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35311) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uubrY-0004xP-3I for 79306-done@debbugs.gnu.org; Fri, 05 Sep 2025 15:12:45 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 706851002F0; Fri, 5 Sep 2025 15:12:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1757099557; bh=X9Bp6OWFYDYhiikef8CErm9fv/R/LkID/5EWVoTNPlU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PunRlDDS0JPHL8v7D47nFGtV+rup6jZ09znMgx8x8TC4GKgxBzMEhprixkYpLQBH2 DDkjnmUcfdt9d5C9YUUGBs/envcqgR+FhgiFNyXsLxF6jrqbBYibaa5HtLJt4I3KmM nyJZ/oHDNBEPNP6ZtWNECasoigY6WBY+1bLw3otirP8VOvh+pJbnJ/JbjmAs7f4v8e kZtJAoSdTkWTZC6y9j3pKTj4Z0YZOjD44qvp7LZtt+bJoZjRg/nyzwnGy9Vf+UUTKi tWnOWmqBwLhQ9nPvT2ROGpgp5uqo0Ulx3dNVedAxkgwKTgCYhzCXPV5EXaHIgHWfPZ xcUEzorsm45jA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 88614100034; Fri, 5 Sep 2025 15:12:37 -0400 (EDT) Received: from alfajor (modemcable103.88-202-24.mc.videotron.ca [24.202.88.103]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 68A281204EE; Fri, 5 Sep 2025 15:12:37 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#79306: Broken follow-mode In-Reply-To: <871pola0a0.fsf@mail.linkov.net> Message-ID: References: <87qzwz2a40.fsf@mail.linkov.net> <86h5xvwohy.fsf@gnu.org> <86a53akajs.fsf@gnu.org> <871pola0a0.fsf@mail.linkov.net> Date: Fri, 05 Sep 2025 15:12:36 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.048 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79306-done Cc: Eli Zaretskii , 79306-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli said: > Sounds good, thanks. Though if we do this, wouldn't it render the > entire machinery of redisplay_counter effectively disabled, since > redisplaying_p is set right after we increment redisplay_counter? No, `redisplaying_p` is reset to false in a few different cases. [ With the `redisplay_counter` mechanism, we could actually be more liberal w.r.t allowing to reset `redisplaying_p` to false (e.g. we could probably expose it to ELisp). ] Juri said: > But with the last two hunks follow-mode works correctly as before. Thanks, pushed to `master`, closing. Stefan