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: Sat, 28 Jan 2023 14:20:05 +0200 Message-ID: <83o7qiam16.fsf@gnu.org> References: <877cx8ose0.fsf@zohomail.eu> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13778"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61098@debbugs.gnu.org To: Rah Guzar , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 28 13:21:23 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 1pLkCw-0003KP-TH for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Jan 2023 13:21:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLkCe-0004R7-8p; Sat, 28 Jan 2023 07:21: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 1pLkCc-0004Qs-HD for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 07:21: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 1pLkCc-00082C-0t for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 07:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pLkCb-0000qo-TO for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 07:21:01 -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, 28 Jan 2023 12:21:01 +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.16749084263210 (code B ref 61098); Sat, 28 Jan 2023 12:21:01 +0000 Original-Received: (at 61098) by debbugs.gnu.org; 28 Jan 2023 12:20:26 +0000 Original-Received: from localhost ([127.0.0.1]:39751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLkC1-0000pf-Pi for submit@debbugs.gnu.org; Sat, 28 Jan 2023 07:20:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLkC0-0000pT-3p for 61098@debbugs.gnu.org; Sat, 28 Jan 2023 07:20:24 -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 1pLkBu-0007rE-PM; Sat, 28 Jan 2023 07:20:18 -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=mUAkpHcvW7d69WzTT2O7/fxaX0ijM9kQLZfihRrM9JM=; b=DE7BCFfucot4 7KGr88PIcFVTZ/9pqfCNp37FXhkjy7ACMFQChsPvwLD/JCwiQNd+b4ZAE6SgzzeKnfPV2W6KWncbh 9svyydIr79LrquCGXs++1oOD12wr1wvCoExhFkkYjPWoBd5+3U5lO1QwJsh+Xxwg3Vd+DMFuILVuo VJot/GZYH0QiwCQ7cO+oByegvwCjQ0EqjYCt7ZVi7v+dPN+b7R6j6FQM4f+u7Fql9jjxA5lhJMG04 IHgtHwURTp8JP/CHw0yzlXb9Q95yFBiNuerCwQQVzu2k+dlWGDDKLy8QGx+6mQ9DEAX/rVzc2FU9+ yuY3Kk3bqy9vT2xeIPWa5g==; 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 1pLkBu-0006iU-6d; Sat, 28 Jan 2023 07:20:18 -0500 In-Reply-To: <877cx8ose0.fsf@zohomail.eu> (bug-gnu-emacs@gnu.org) 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:254296 Archived-At: > 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. )