From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74091: 31.0.50; string-pixel-width in mode line disables region Date: Sat, 09 Nov 2024 20:35:40 +0200 Message-ID: <86ses0l0g3.fsf@gnu.org> References: <86y1254owq.fsf@gnu.org> <86ldy54m2g.fsf@gnu.org> <86ed3w33g1.fsf@gnu.org> <8634k0mkgy.fsf@gnu.org> <86ttcgl1f0.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9125"; mail-complaints-to="usenet@ciao.gmane.io" Cc: me@eshelyaron.com, 74091@debbugs.gnu.org To: monnier@iro.umontreal.ca Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 09 19:36:24 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t9qJs-0002FE-3l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Nov 2024 19:36:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9qJb-00033d-IV; Sat, 09 Nov 2024 13:36:07 -0500 Original-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 1t9qJX-00033J-1x for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 13:36:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9qJW-00044j-QE for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 13:36:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=vey6dHJQZ65dFEZEDz0Wx+mZWEBEeI1tz+yPxgONxyA=; b=VmDB0a+BfmaLN+Rw1UtfCSgrXLe/J/F3Nb1dhnK0Mg7/od1yh13sqn9MsdqZeX2GH7mir9PnwKPE8KSoegYA155a3k9pwKEZo1K0C9hGq0RZM85KDD5h8Q8fAJQWkaqATJ6BpIX+pTcr7bbrVbpIfpywX7y7QuTcg+vaSWX92afscV9Z1jPxM6DRTVYjwfOu7QRFXNMlUPgWBuX9H2iWuAKE0uUyN8MbkWRCsciyU70z4bmnxtbVbNM/C9WpapXPSRcp1ijqJfWB3Rs0lcxlZ17rJaFkYOpX77BXtI/xiCqetWz7o03tu0MouQV3IhzU5VGfKzRNcBDM6fpyN5tJvQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9qJW-0001A4-Co for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 13:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Nov 2024 18:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74091 X-GNU-PR-Package: emacs Original-Received: via spool by 74091-submit@debbugs.gnu.org id=B74091.17311773544447 (code B ref 74091); Sat, 09 Nov 2024 18:36:02 +0000 Original-Received: (at 74091) by debbugs.gnu.org; 9 Nov 2024 18:35:54 +0000 Original-Received: from localhost ([127.0.0.1]:54449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9qJN-00019f-Nv for submit@debbugs.gnu.org; Sat, 09 Nov 2024 13:35:54 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9qJK-00019M-1m for 74091@debbugs.gnu.org; Sat, 09 Nov 2024 13:35:52 -0500 Original-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 1t9qJD-00044H-RH; Sat, 09 Nov 2024 13:35:43 -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=vey6dHJQZ65dFEZEDz0Wx+mZWEBEeI1tz+yPxgONxyA=; b=HKEqQ66HMFVM Nj5sth1yQbn8TY0lmtN8Hi0kWrhi8sukP2b0N5ztaXqR13bu+Uot4m51I7e8e21AbD+SsxTBMY5Kh BTtu70mLEvRQ8JWw06Dvrhc1Y90o8jHSsO0XXI9FuoQ6SPWaXdDQDPi5pKB6Nd6YguisbR6bAkrk1 dkyf97dlrmRjq3UlBtCjO+8AREs+8RomyjYwdeTD9G+rLzI1/eVZXIpn2QwyoMlIR/6BxP9SoXSKA JlPohivru0wmB9H1G3fGjVFklTBWvQIoHUGJ2uIgbwF4fabjm15oqH9BYTA+buNwJmjf5xWl69u9X G4WM4ewY7V+rvwaBHW3XwA==; In-Reply-To: <86ttcgl1f0.fsf@gnu.org> (message from Eli Zaretskii on Sat, 09 Nov 2024 20:14:43 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295154 Archived-At: > Cc: me@eshelyaron.com, 74091@debbugs.gnu.org > Date: Sat, 09 Nov 2024 20:14:43 +0200 > From: Eli Zaretskii > > > From: Stefan Monnier > > Cc: me@eshelyaron.com, 74091@debbugs.gnu.org > > Date: Sat, 09 Nov 2024 13:06:13 -0500 > > > > AFAICT the problem is new with the addition of the `kill-permanent` > > arg to `kill-all-local-variables`. > > > > Here's an example of a problem: > > > > src/emacs -Q --batch --eval '(message "%s" (list (setq-default foo nil) (setq-local foo t) (kill-all-local-variables t) (local-variable-p `foo) foo (default-value `foo) (with-temp-buffer foo) foo))' > > > > => > > > > (nil t nil t t nil nil nil) > > > > If we call `kill-all-local-variables` without the additional argument, we > > get the correct answer: > > > > (nil t nil nil nil nil nil nil) > > This feature was introduced in Emacs 29, so we should preferably fix > it in Emacs 30. Any suggestions? I think calling reset_buffer_local_variables with 2nd arg non-zero is not TRT to implement this new argument of kill-all-local-variables, because it does this: /* Reset all (or most) per-buffer variables to their defaults. */ if (permanent_too) bset_local_var_alist (b, Qnil); I think we should instead ignore the permanent-local property of variables. How about the patch below? diff --git a/src/buffer.c b/src/buffer.c index 744b0ef..9e93e0f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -113,7 +113,7 @@ #define OVERLAY_COUNT_MAX \ static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3); -static void reset_buffer_local_variables (struct buffer *, bool); +static void reset_buffer_local_variables (struct buffer *, int); /* Alist of all buffer names vs the buffers. This used to be a Lisp-visible variable, but is no longer, to prevent lossage @@ -1112,10 +1112,11 @@ reset_buffer (register struct buffer *b) Instead, use Fkill_all_local_variables. If PERMANENT_TOO, reset permanent buffer-local variables. - If not, preserve those. */ + If not, preserve those. PERMANENT_TOO = 2 means ignore + the permanent-local property of non-builtin variables. */ static void -reset_buffer_local_variables (struct buffer *b, bool permanent_too) +reset_buffer_local_variables (struct buffer *b, int permanent_too) { int offset, i; @@ -1141,7 +1142,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) bset_invisibility_spec (b, Qt); /* Reset all (or most) per-buffer variables to their defaults. */ - if (permanent_too) + if (permanent_too == 1) bset_local_var_alist (b, Qnil); else { @@ -1170,7 +1171,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) swap_in_global_binding (XSYMBOL (sym)); } - if (!NILP (prop)) + if (!NILP (prop) && permanent_too) { /* If permanent-local, keep it. */ last = tmp; @@ -3001,7 +3002,7 @@ DEFUN ("kill-all-local-variables", Fkill_all_local_variables, /* Actually eliminate all local bindings of this buffer. */ - reset_buffer_local_variables (current_buffer, !NILP (kill_permanent)); + reset_buffer_local_variables (current_buffer, !NILP (kill_permanent) ? 2 : 0); /* Force mode-line redisplay. Useful here because all major mode commands call this function. */