From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rah Guzar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61098: 29.0.60; Confusing behavior of show-paren-mode Date: Mon, 30 Jan 2023 20:21:33 +0100 Message-ID: <87y1pjstse.fsf@zohomail.eu> References: <877cx8ose0.fsf@zohomail.eu> <83o7qiam16.fsf@gnu.org> Reply-To: Rah Guzar Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16759"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.60 Cc: 61098@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 30 20:33:14 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 1pMZty-00047x-5j for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Jan 2023 20:33:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMZtp-0003Xu-58; Mon, 30 Jan 2023 14:33:05 -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 1pMZtm-0003Xi-T1 for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 14:33: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 1pMZtm-0007gq-Jw for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 14:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMZtm-0004PV-3a for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 14:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Rah Guzar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Jan 2023 19:33: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.167510713916901 (code B ref 61098); Mon, 30 Jan 2023 19:33:02 +0000 Original-Received: (at 61098) by debbugs.gnu.org; 30 Jan 2023 19:32:19 +0000 Original-Received: from localhost ([127.0.0.1]:50625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMZt5-0004OW-Bk for submit@debbugs.gnu.org; Mon, 30 Jan 2023 14:32:19 -0500 Original-Received: from sender11-pp-o91.zoho.eu ([31.186.226.249]:25236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMZt3-0004OO-Nz for 61098@debbugs.gnu.org; Mon, 30 Jan 2023 14:32:18 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1675107127; cv=none; d=zohomail.eu; s=zohoarc; b=dC0mehrpmmwjSJ8v8yT2ABrpYllyA0d/TrepkTho802m83u2B+e7i5oowMeNp/Mk645qhppsFyCc5XzCit2eyu6kYd67HtI6C1DNGzmX7blAqrbnBZEE0iswQcnMVE+XOucWlPcpL+qpJnIdZPFGEPnpIkV7Qnq10ksY2Uvk59M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1675107127; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=7kJAUzAojrrV2uSCsFSdyo8quCEZlT6rDkjMXtq96iQ=; b=INQHa1LTimNtzFE7bxxP163MXwASd2khzYy4fLDMN+4lC3IT103gV/x/0voSxhretKR8bJlpuAtBW2sjootMc11wSWqOqB0D5/mtBJXcAWZXtH8NBhD0TKliLoxK7ArH9uTAggEvjEXzhumpqrH15JdkX5yxjSBl7Y2vVrPQsCs= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=zohomail.eu; spf=pass smtp.mailfrom=rahguzar@zohomail.eu; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1675107127; s=zoho; d=zohomail.eu; i=rahguzar@zohomail.eu; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To; bh=7kJAUzAojrrV2uSCsFSdyo8quCEZlT6rDkjMXtq96iQ=; b=KMcXQNYZYvIRxe3neKeW7YOz3BEm4fanWqHZL/04nIwzss+OrOmjLeOSg18B9GJG doxoqTIif18586NOrux4EaX6gZIjmhgf9IhxHR81KWVL+ihCO4dVSsbyxtsR+2rnY+x hMGTWPlztdDIC5bUhZsZvOWjXQamB8ky/+DvI40o= Original-Received: from localhost (81-231-79-170-no600.tbcn.telia.com [81.231.79.170]) by mx.zoho.eu with SMTPS id 1675107124528891.3523744217221; Mon, 30 Jan 2023 20:32:04 +0100 (CET) In-reply-to: <83o7qiam16.fsf@gnu.org> X-ZohoMailClient: External 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:254476 Archived-At: Hi, Thanks for the patch, it works as you described. However I have questions about the show-paren-predicate variable. When I see its default value (not (derived-mode . special-mode)) it makes me think there is some dsl involved. The customize interface mentions Lisp Expression as a possibility but the documentation doesn't explain what form this expression is supposed to take. This makes me think that the default is just a pseudo sentence intended to convey what it does and there are only three possibilities. If the latter is correct, I think a simpler way would be to disable the mode in the body of special-mode if the value of `show-paren-predicate` demands it. I think this will get rid of the problem that the mode is disabled the first time show-paren-local-mode is called. I am using the equivalent of this which adds a hook to special-mode-hook to achieve the outcome and I am pretty happy with it. Thanks again, Rahguzar Eli Zaretskii writes: >> Date: Fri, 27 Jan 2023 17:03:14 +0100 >> From: Rah Guzar via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> >> Dear Emacs maintainers, >> After updating to Emacs 29, I saw in NEWS that show-paren-mode >> is no longer enabled in special-mode buffers. I think that is a >> welcome change. However in some cases (like reading the elisp >> manual) it is helpful to have it enabled. My impression after >> reading the NEWS entry, the manual entry for show-paren-mode >> and documentation for show-paren-local-mode was that I should >> be able to able to turn on show-paren-mode buffer locally by >> >> M-x show-paren-local-mode RET >> >> However this doesn't work and after much confusion I realized >> that calling show-paren-local-mode has effect only if I customize >> show-paren-predicate. My (incorrect) impression after reading >> the documentation was that show-paren-predicate determines only >> whether show-paren-mode is enabled in a buffer by default but >> doesn't prohibit the possibility of turning it off. > > Your impression was correct: there should be no need to customize > show-paren-predicate to turn on show-paren-local-mode in a buffer that > is under a descendant of special-mode. The patch below fixes the bug > and allows you to do what you want without messing with > show-paren-predicate. > > However, there's one glitch: after applying the patch, when you invoke > > M-x show-paren-local-mode RET > > in a special-mode buffer, it says the mode is _disabled_, and indeed > disables the mode. You need to enable it by invoking the same command > again. > > I'm not sure I understand the reason, but it is probably related to > the fact that we use the same show-paren-mode variable for the > localized mode, and the default value of that variable is t. > > Stefan, can you help here? how do we make show-paren-local-mode be > enabled when the user explicitly invokes it? > > Here's the patch I promised above: > > diff --git a/lisp/paren.el b/lisp/paren.el > index b2a7962..de14de2 100644 > --- a/lisp/paren.el > +++ b/lisp/paren.el > @@ -167,8 +167,11 @@ show-paren-local-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. > + ((or > + ;; Locally enabled, but globally disabled. > + (not (default-value 'show-paren-mode)) > + ;; Disabled by 'show-paren-predicate'. > + (not (buffer-match-p show-paren-predicate (current-buffer)))) > (show-paren-mode 1) ; Setup the timer. > (setq-default show-paren-mode nil) ; But keep it globally disabled. > )