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: Wed, 01 Feb 2023 19:48:11 +0200 Message-ID: <83k011z38k.fsf@gnu.org> References: <877cx8ose0.fsf@zohomail.eu> <83o7qiam16.fsf@gnu.org> <87y1pjstse.fsf@zohomail.eu> <83r0va3o8f.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39379"; 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 Wed Feb 01 18:49:20 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 1pNHEV-000A4b-BR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Feb 2023 18:49:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNHEG-0002h6-8j; Wed, 01 Feb 2023 12:49: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 1pNHEE-0002gy-QQ for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 12:49:03 -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 1pNHEE-00043o-IM for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 12:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNHEE-0005b3-EO for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 12:49: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: Wed, 01 Feb 2023 17:49: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.167527370121428 (code B ref 61098); Wed, 01 Feb 2023 17:49:02 +0000 Original-Received: (at 61098) by debbugs.gnu.org; 1 Feb 2023 17:48:21 +0000 Original-Received: from localhost ([127.0.0.1]:59784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNHDZ-0005ZX-6h for submit@debbugs.gnu.org; Wed, 01 Feb 2023 12:48:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNHDX-0005Yq-ES for 61098@debbugs.gnu.org; Wed, 01 Feb 2023 12:48:19 -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 1pNHDR-0003jx-QV; Wed, 01 Feb 2023 12:48:13 -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=vqXwnsq6xOPuX0B0hq+R54hU/uLU06A2TFmS3gOX01A=; b=UBTEkRMQS19s h3/uO8P8n99PpE34tKubc+kLuYLntajbV7iIk8G8EZBTxkmiPyLQqiJVf3O43qnxLd6QXGR7m8AVg FstXhBYLeM7ri3LKOadHtHRT4msqvW9P9MC2kWOH18avvf+I7NTNKjVq7YqUwohSPYEst0r+WFDpx 4klvy64fMN6a7SAxhb6/Y7f1MYHFCGGaq4NRQlXuyLw4sU3znlr3pURZ/uh2jgUXDp81I4QeoLDHV WB/8XBOZE/QrK9doUVvL4wYPHczDQ+r+JuktQHgy6fScq5XCnhdYU8DiK5aWNBWrbwspJRxLrBqmd tLSSFmFedTR+e/DAjXdlzA==; 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 1pNHDR-0006Ib-6M; Wed, 01 Feb 2023 12:48:13 -0500 In-Reply-To: (message from Stefan Monnier on Tue, 31 Jan 2023 17:42:09 -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:254592 Archived-At: > From: Stefan Monnier > Cc: Rah Guzar , 61098@debbugs.gnu.org > Date: Tue, 31 Jan 2023 17:42:09 -0500 > > > I'm still waiting for Stefan to help me understand why after that > > patch "M-x show-paren-local-mode" _disables_ the mode rather than > > enabling it. Stefan, any wisdom? > > Not sure. I don't quite understand how your patch intends to work. > >From where I sit I get the impression that it will result in an > inconsistent state in various "corner" cases. > > Dmitry's patch seems closer to my intuition (I might even suggest > removing the `kill-local-variable` altogether). 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. 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? So I tried to get the mode function do its job in this scenario. What Dmitry's patch does, and why it is supposed to fix this, I simply don't understand, perhaps for the same reason that I misinterpret what the mode function does.