From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier 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: Sun, 05 Feb 2023 10:19:24 -0500 Message-ID: References: <877cx8ose0.fsf@zohomail.eu> <83o7qiam16.fsf@gnu.org> <87y1pjstse.fsf@zohomail.eu> <83r0va3o8f.fsf@gnu.org> <83k011z38k.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38529"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: rahguzar@zohomail.eu, dgutov@yandex.ru, 61098@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 16:20:16 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 1pOgoR-0009ou-N2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 16:20:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOgoG-0002Iw-Ps; Sun, 05 Feb 2023 10:20: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 1pOgoF-0002IW-2A for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:20: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 1pOgoE-0000tu-Q9 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOgoE-0002ww-FD for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 10:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Feb 2023 15:20: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.167561037511297 (code B ref 61098); Sun, 05 Feb 2023 15:20:02 +0000 Original-Received: (at 61098) by debbugs.gnu.org; 5 Feb 2023 15:19:35 +0000 Original-Received: from localhost ([127.0.0.1]:46288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgnn-0002w9-3L for submit@debbugs.gnu.org; Sun, 05 Feb 2023 10:19:35 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOgnl-0002vw-FB for 61098@debbugs.gnu.org; Sun, 05 Feb 2023 10:19:33 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 177BA4407EE; Sun, 5 Feb 2023 10:19:28 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1A787440858; Sun, 5 Feb 2023 10:19:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1675610366; bh=x6J3goP/gWEGjIzF5Zsgkat7x8ZRidzLW2eNIjObG1Y=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Z+JDZtmmZrkf0r2Pq2UlZyNshyedHt9dY76DI9r1NGhs+iP7JmyuzBb7my6m1+hbl Mh51MCGCVQk1hYjjVdw3ClplKUm+Ncqe5BYhLuUOMxOL/rZN3rC3ptvCu4+pUB7TpX b2P0JMVm7JdxK9gfDNsD0ZGtUOMMmNcijPf0gJoa7vUHAKCIIO8i98/BsIF3qVFBo+ vjkP0LV90EAaLUVmNjD6qblYaXFxmf87BNJZjuMHMy/RyEXFjScMynPO8xtz0Vdt6e LHHXxK+pzcqwHylDGUop5plYg3SFiCr5BFvkszMVqWY+NVp+AKJf21jWg2IOvAn1nZ 5iqPTw9yciwlQ== Original-Received: from pastel (unknown [104.247.245.112]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BA05D122512; Sun, 5 Feb 2023 10:19:25 -0500 (EST) In-Reply-To: <83k011z38k.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 01 Feb 2023 19:48:11 +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:254864 Archived-At: > 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. -- Stefan