From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vladimir Sedach Newsgroups: gmane.emacs.bugs Subject: bug#64311: [PATCH] Fix shell-dirtrack-mode showing up as enabled in unrelated buffers Date: Tue, 27 Jun 2023 18:07:27 -0600 Message-ID: <87zg4k76es.fsf@orphne.orion.oneofus.la> References: <87pm5h4iy1.fsf@t510.orion.oneofus.la> <83h6qtw3tq.fsf@gnu.org> <87wmzp2e0d.fsf@t510.orion.oneofus.la> <831qhwx5qf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8592"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.92 Cc: 64311@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 28 02:56:04 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 1qEJTX-00020h-NC for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Jun 2023 02:56:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEJSd-0005bM-64; Tue, 27 Jun 2023 20:55:07 -0400 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 1qEJSZ-0005ac-PH for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 20:55:04 -0400 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 1qEJSZ-0004ST-50 for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 20:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qEJSY-00019c-Ph for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 20:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vladimir Sedach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Jun 2023 00:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64311 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64311-submit@debbugs.gnu.org id=B64311.16879136834382 (code B ref 64311); Wed, 28 Jun 2023 00:55:02 +0000 Original-Received: (at 64311) by debbugs.gnu.org; 28 Jun 2023 00:54:43 +0000 Original-Received: from localhost ([127.0.0.1]:49714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEJSF-00018b-8G for submit@debbugs.gnu.org; Tue, 27 Jun 2023 20:54:43 -0400 Original-Received: from robust-software.ca ([174.136.98.50]:27415) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEJSA-00018P-Ul for 64311@debbugs.gnu.org; Tue, 27 Jun 2023 20:54:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=virgo1; bh=2VzK4KXD442h3 84XZLN16Wl6tsiTbn9SRPFITlCFxWY=; h=in-reply-to:date:subject:cc:to: from:references; d=oneofus.la; b=nqXvV/vOGeH1M8B1uJ1FL2sosRCC+Rnj+LWmZ T3vQ7E81qkK9GUwsKf66op9ytelVkGCLg/rmhyqrzPAPXgxU3bbn0Ngov8JjUaIRkvkZQf ziA9tfZ617tf/NwZdF06V7BkGwtYf6BrbU88F6A6mK+3aBfsgUYTJWmZ74MmQLdY= Original-Received: from orphne.orion.oneofus.la (node-1w7jra28qzk6zp350rgpfps17.ipv6.telus.net [2001:56a:f913:3c01:eec6:50e:d532:8d2b]) by virgo1.oneofus.la (OpenSMTPD) with ESMTPSA id 40c8c87c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 27 Jun 2023 17:54:37 -0700 (PDT) In-reply-to: <831qhwx5qf.fsf@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:264186 Archived-At: Eli Zaretskii writes: > Why is that a problem. I understand when it causes irrelevant minor > mode to be shown by "C-h m", but why should anyone care that some > global variable is non-nil? My understanding is that (define-minor-mode X-mode ...) defines a variable X-mode (the docstring for define-minor-mode calls this a "control variable") that is supposed to be t when the mode is enabled, and nil when the mode is not enabled. Right now the variable shell-dirtrack-mode has a value of t, even when the mode is not enabled. > In any case, I don't think a fix (if we need one) should be so > complicated. Why do we need all those changes, including making the > variable obsolete and moving the mode from its place in shell.el to > another place there? If all you want is to make this variable > buffer-local, just making it buffer-local is all that's needed, > right? shell-dirtrack-mode is already made buffer-local by define-minor-mode. The problem is shell-dirtrackp and its default value. What is shell-dirtrackp? Looking at VC-history for shell-dirtrackp, there are 2 commits: --8<---------------cut here---------------start------------->8--- commit 9c3eeba4db26ddaeead100beea7a96f9fa640918 Author: Glenn Morris Date: Fri Apr 20 18:34:39 2018 -0400 The tedious game of whack-a-mole with compiler warnings continues ... diff --git a/lisp/shell.el b/lisp/shell.el --- a/lisp/shell.el +++ b/lisp/shell.el @@ -317,4 +317,6 @@ +(defvaralias 'shell-dirtrack-mode 'shell-dirtrackp) + (defvar shell-dirtrackp t "Non-nil in a shell buffer means directory tracking is enabled.") commit b493a9b2af805a3097fe53fd472884c268248146 Author: Richard M. Stallman Date: Wed Mar 2 16:55:16 1994 +0000 (shell-dirtrackp): Variable definition added. diff --git a/lisp/shell.el b/lisp/shell.el --- a/lisp/shell.el +++ b/lisp/shell.el @@ -226,1 +223,4 @@ +(defvar shell-dirtrackp t + "Non-nil in a shell buffer means directory tracking is enabled.") + --8<---------------cut here---------------end--------------->8--- So it looks like in 1994 rms introduced the variable shell-dirtrackp, before define-minor-mode and the X-mode variable convention. Judging by the documentation string, shell-dirtrackp was intended to do what the automatically defined X-mode variables do now. Then in 2018 rgm aliased shell-dirtrackp to shell-dirtrack-mode to fix a compiler warning. This introduced an incorrect default value for shell-dirtrack-mode. The variable shell-dirtrackp should also have been marked obsolete in rgm's commit. I moved the definition of shell-dirtrack-mode above the first use of the variable shell-dirtrack-mode so there would be no compiler warning (this is noted in the commit message). This also puts the definition of shell-dirtrack-mode right after the long comment for the Directory tracking section explaining the mode's purpose, a nice unintended benefit. > But first, let's talk about the problem: why is shell-dirtrack-mode > being t a problem? If you have a hook that tests if shell-dirtrack-mode is turned on by looking at the value of the variable shell-dirtrack-mode, that hook will not work correctly. -- Vladimir Sedach