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#61098: 29.0.60; Confusing behavior of show-paren-mode Date: Sun, 05 Feb 2023 17:24:57 +0200 Message-ID: <83tu00qgmu.fsf@gnu.org> References: <877cx8ose0.fsf@zohomail.eu> <83o7qiam16.fsf@gnu.org> <87y1pjstse.fsf@zohomail.eu> <83r0va3o8f.fsf@gnu.org> <83k011z38k.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21820"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rahguzar@zohomail.eu, dgutov@yandex.ru, 61098@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 16:25:12 2023 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 1pOgtE-0005Vb-Id for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 16:25:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOgt6-0002s8-G4; Sun, 05 Feb 2023 10:25:04 -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 1pOgt4-0002rl-Lj for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:25:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOgt4-0001oH-D7 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOgt4-00034y-5R for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:25: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: Sun, 05 Feb 2023 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61098 X-GNU-PR-Package: emacs Original-Received: via spool by 61098-submit@debbugs.gnu.org id=B61098.167561069711820 (code B ref 61098); Sun, 05 Feb 2023 15:25:02 +0000 Original-Received: (at 61098) by debbugs.gnu.org; 5 Feb 2023 15:24:57 +0000 Original-Received: from localhost ([127.0.0.1]:46293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgsy-00034a-Sg for submit@debbugs.gnu.org; Sun, 05 Feb 2023 10:24:57 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgsw-00034M-TT for 61098@debbugs.gnu.org; Sun, 05 Feb 2023 10:24:55 -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 1pOgsq-0001mu-Fr; Sun, 05 Feb 2023 10:24:48 -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=Q6TZmeMndIRbQSWC/gc4auX4lNnp5x1kEarE/KpMnhY=; b=UCJNZABDjCBK y/SLDWJFMIoyK53u/S5BOZ6ZVTf3uFRINmjwIzKLoLK0C42ABptztVDrGCZ4kyx6lONWRbJDyMg/6 XtvBQIcIEKfGUYMd3CI0Z/sbQNKGs7ruLj5Bg4Aak03Y+CzKgh9nQunxsm1iuQedc5OtrDsf9zUtJ Rnm+Nd8bxEOGB14ef4YmWoI+y47oPLafONOIcRpAMNWm9HEHf7udx3RnzPVgkxiTHckHVAQYXR0ar bjcfL3sS5Qc8Mu6t9TkKhQK/dft86mQezc1aopjBXLpqZcffZulrJrzRjLZHMTyiY4kKIZH5IYx+0 9hHOzPN9RfCU8KLP5mTRSg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOgsp-0002IF-Sy; Sun, 05 Feb 2023 10:24:48 -0500 In-Reply-To: (message from Stefan Monnier on Sun, 05 Feb 2023 10:19:24 -0500) 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:254865 Archived-At: > From: Stefan Monnier > Cc: rahguzar@zohomail.eu, 61098@debbugs.gnu.org, dgutov@yandex.ru > Date: Sun, 05 Feb 2023 10:19:24 -0500 > > > I guess I don't understand what show-paren-local-mode does, then. Let > > me explain my line of reasoning: > > > > (define-minor-mode show-paren-local-mode > > "Toggle `show-paren-mode' only in this buffer." > > :variable ( show-paren-mode . > > (lambda (val) (setq-local show-paren-mode val))) > > (cond > > ((eq show-paren-mode (default-value 'show-paren-mode)) > > (unless show-paren-mode > > (show-paren--delete-overlays)) > > (kill-local-variable 'show-paren-mode)) > > ((not (default-value 'show-paren-mode)) > > ;; Locally enabled, but globally disabled. > > (show-paren-mode 1) ; Setup the timer. > > (setq-default show-paren-mode nil) ; But keep it globally disabled. > > ) > > (t ;; Locally disabled only. > > (show-paren--delete-overlays)))) > > > > When I looked at the above function and stepped through it in the OP's > > scenario, what I saw was that the 2nd condition of 'cond' doesn't > > fire, because the default-value of show-paren-mode is t nowadays. So > > I concluded that this code relies on the mode being globally off by > > default, and attempted to fix the condition that turns the mode on > > locally even though it is on globally. > > But if the mode is already globally enabled, the (setq-default show-paren-mode nil) > will definitely not be right: you'd end up disabling it globally (while > maybe keeping it enabled locally). > > > The predicate used by the timer requires either a match of the buffer > > (which doesn't happen in this case) or that the local value of > > show-paren-mode is non-nil. Setting the local value non-nil is the > > job of the mode function, isn't it? > > Yes, but the first branch of the `cond` incorrectly does > `kill-local-variable` under the assumption that the local value doesn't > matter if it's the same as the global one, but that's not true here > because (as a wise man said): > > The predicate used by the timer requires either a match of the buffer > (which doesn't happen in this case) or that the local value of > show-paren-mode is non-nil. This answers only half of my questions, but if you and Dmitry think Dmitry's patch will solve this problem, then Dmitry, please install it and close this bug. Thanks.