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 08:09:22 -0600 Message-ID: <87wmzp2e0d.fsf@t510.orion.oneofus.la> References: <87pm5h4iy1.fsf@t510.orion.oneofus.la> <83h6qtw3tq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38571"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 28.2 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 Tue Jun 27 16:10:17 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 1qE9Oa-0009nc-Gq for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Jun 2023 16:10:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE9OQ-0005zl-3B; Tue, 27 Jun 2023 10:10:06 -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 1qE9ON-0005ye-AE for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 10:10:03 -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 1qE9ON-0006VT-1Q for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 10:10:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qE9OM-0001GQ-L5 for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 10:10: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: Tue, 27 Jun 2023 14:10: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.16878749704778 (code B ref 64311); Tue, 27 Jun 2023 14:10:02 +0000 Original-Received: (at 64311) by debbugs.gnu.org; 27 Jun 2023 14:09:30 +0000 Original-Received: from localhost ([127.0.0.1]:49328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qE9Nq-0001Eu-7Z for submit@debbugs.gnu.org; Tue, 27 Jun 2023 10:09:30 -0400 Original-Received: from robust-software.ca ([174.136.98.50]:3307) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qE9Nl-0001Ed-FS for 64311@debbugs.gnu.org; Tue, 27 Jun 2023 10:09:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=virgo1; bh=bDaFlS2C+gC9b ymI0GXwkWqQICOdY2gOcZ4xBHR03xA=; h=date:in-reply-to:subject:cc:to: from:references; d=oneofus.la; b=f0BhDuIU9LEI+z1+YEbtuabmPpblvlmr6rimt non6NBtg4cYUKuOUyVkBKXl9opOiXftSdARYbMFQYI7aGwsMxD5DEW4rUsA4cZ4xQR45Z2 6h0Mp3iKXkYeNqAjylhXWMzUNZeLfGZRSJW3SDqjuberffwxMQOE3irOywgLE7PA= Original-Received: from t510.orion.oneofus.la (node-1w7jra28qzk6xhh5ry179dtfm.ipv6.telus.net [2001:56a:f913:3c01:5d5b:103:904d:8b42]) by virgo1.oneofus.la (OpenSMTPD) with ESMTPSA id 45ab35f4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 27 Jun 2023 07:09:23 -0700 (PDT) In-reply-to: <83h6qtw3tq.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:264163 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > In what version of Emacs do you see this? (You didn't include in your > report the information collected by "M-x report-emacs-bug", so I > cannot know what version and on what OS are you using.) I cannot > reproduce this in Emacs 29: "C-h m" after "M-x shell" shows > shell-dirtrack-mode only in the *shell* buffer. I do see it in > *scratch* in Emacs 28, so I guess we already fixed this? You are right about the steps to reproduce. What changed in Emacs 29 was describe-mode no longer using minor-mode-list, but (buffer-local-value 'local-minor-modes buffer) instead. This changed in commit 3c059f269e0182bd19df37871585e0b0bf1d47e5 Redo `C-h m' output Wed Apr 13 03:50:06 2022 +0200 This only hides the problem, which is: the default value of shell-dirtrack-mode being t. Revised steps to reproduce: 1. emacs -q 2. M-x shell 3. M-: shell-dirtrack-mode in *scratch* or *GNU Emacs* This is also demonstrated in the test shell-dirtrack-should-not-be-on-in-unrelated-modes from the first patch, which fails without the fix being applied. Attached is a revised patch for the fix, with the obsolete variable version filled in, and updated commit message. Thank you for looking at this. -- Vladimir Sedach --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-Fix-shell-dirtrack-mode-showing-up-as-enabled-in-unr.patch Content-Transfer-Encoding: quoted-printable >From 971ac829043c6659acf7b315c0d610de1c7b0d10 Mon Sep 17 00:00:00 2001 From: Vladimir Sedach Date: Mon, 26 Jun 2023 22:32:07 -0600 Subject: [PATCH 2/2] Fix shell-dirtrack-mode showing up as enabled in unrelated buffers MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit ; shell-dirtrack-mode always shows up in unrelated buffers. ; Steps to reproduce: ; 1. emacs -q ; 2. M-x shell ; 3. M-: shell-dirtrack-mode in *scratch* or *GNU Emacs* ; This is because shell-dirtrack-mode is aliased to shell-dirtrackp, ; which has default value t. ; Changes in this patch: ; mark shell-dirtrackp obsolete ; replace existing occurrences of shell-dirtrackp with shell-dirtrack-mode ; add :interactive (shell-mode) suggestion to shell-dirtrack-mode ; shell-dirtrack-mode is still turned on by default. There is an ; explicit call to (shell-dirtrack-mode 1) in the definition of ; shell-mode. ; Definition of shell-dirtrack-mode is moved to quiet warning about ; reference to free variable =E2=80=98shell-dirtrack-mode=E2=80=99. --- lisp/shell.el | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index b74442f1961..e6f1c2629f3 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -346,10 +346,10 @@ shell-dirstack "List of directories saved by pushd in this buffer's shell. Thus, this does not include the shell's current directory.") =20 -(defvaralias 'shell-dirtrack-mode 'shell-dirtrackp) - -(defvar shell-dirtrackp t - "Non-nil in a shell buffer means directory tracking is enabled.") +(define-obsolete-variable-alias 'shell-dirtrackp 'shell-dirtrack-mode + "30.1" + "Non-nil in a shell buffer means directory tracking is enabled. +Use the minor mode variable `shell-dirtrack-mode' instead.") =20 (defvar shell-last-dir nil "Keep track of last directory for ksh `cd -' command.") @@ -997,6 +997,20 @@ shell ;; replace it with a process filter that watches for and strips out ;; these messages. =20 +(define-minor-mode shell-dirtrack-mode + "Toggle directory tracking in this shell buffer (Shell Dirtrack mode). + +The `dirtrack' package provides an alternative implementation of +this feature; see the function `dirtrack-mode'. Also see +`comint-osc-directory-tracker' for an escape-sequence based +solution." + :lighter nil + :interactive (shell-mode) + (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) + (if shell-dirtrack-mode + (add-hook 'comint-input-filter-functions #'shell-directory-tracker n= il t) + (remove-hook 'comint-input-filter-functions #'shell-directory-tracker = t))) + (defun shell-directory-tracker (str) "Tracks cd, pushd and popd commands issued to the shell. This function is called on each input passed to the shell. @@ -1013,7 +1027,7 @@ shell-directory-tracker and `shell-pushd-dunique' control the behavior of the relevant command. =20 Environment variables are expanded, see function `substitute-in-file-name'= ." - (if shell-dirtrackp + (if shell-dirtrack-mode ;; We fail gracefully if we think the command will fail in the shell. ;;; (with-demoted-errors "Directory tracker failure: %s" ;; This fails so often that it seems better to just ignore errors (?= ). @@ -1167,23 +1181,10 @@ shell-extract-num (and (string-match "^\\+[1-9][0-9]*$" str) (string-to-number str))) =20 -(define-minor-mode shell-dirtrack-mode - "Toggle directory tracking in this shell buffer (Shell Dirtrack mode). - -The `dirtrack' package provides an alternative implementation of -this feature; see the function `dirtrack-mode'. Also see -`comint-osc-directory-tracker' for an escape-sequence based -solution." - :lighter nil - (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) - (if shell-dirtrack-mode - (add-hook 'comint-input-filter-functions #'shell-directory-tracker n= il t) - (remove-hook 'comint-input-filter-functions #'shell-directory-tracker = t))) - (defun shell-cd (dir) "Do normal `cd' to DIR, and set `list-buffers-directory'." (cd dir) - (if shell-dirtrackp + (if shell-dirtrack-mode (setq list-buffers-directory default-directory))) =20 (defun shell-resync-dirs () --=20 2.20.1 --=-=-=--