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: Thu, 06 Jul 2023 14:30:16 -0600 Message-ID: <878rbspyuf.fsf@t510.orion.oneofus.la> References: <87pm5h4iy1.fsf@t510.orion.oneofus.la> <83h6qtw3tq.fsf@gnu.org> <87wmzp2e0d.fsf@t510.orion.oneofus.la> <831qhwx5qf.fsf@gnu.org> <87zg4k76es.fsf@orphne.orion.oneofus.la> <83mt0jvmfu.fsf@gnu.org> <87r0pva66g.fsf@t510.orion.oneofus.la> <834jmrv3p6.fsf@gnu.org> <87o7kz9wej.fsf@t510.orion.oneofus.la> <83wmzmuaq7.fsf@gnu.org> <87wmzmb5fl.fsf@t510.orion.oneofus.la> <83a5wita0p.fsf@gnu.org> <87ttuqax6d.fsf@t510.orion.oneofus.la> <835y75tsn7.fsf@gnu.org> <87r0ps7v92.fsf@t510.orion.oneofus.la> <831qhqq0kf.fsf@gnu.org> <837crfll1t.fsf@gnu.org> <87h6qjfh2y.fsf@t510.orion.oneofus.la> 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="35221"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 28.2 Cc: 64311@debbugs.gnu.org, Eli Zaretskii To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 06 22:31:22 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 1qHVdJ-0008xQ-4y for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Jul 2023 22:31:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHVd2-0008AL-L5; Thu, 06 Jul 2023 16:31:04 -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 1qHVd0-0008AC-M3 for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:31:02 -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 1qHVd0-0002LA-EQ for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qHVcz-0000F1-VT for bug-gnu-emacs@gnu.org; Thu, 06 Jul 2023 16:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vladimir Sedach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Jul 2023 20:31:01 +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.1688675423882 (code B ref 64311); Thu, 06 Jul 2023 20:31:01 +0000 Original-Received: (at 64311) by debbugs.gnu.org; 6 Jul 2023 20:30:23 +0000 Original-Received: from localhost ([127.0.0.1]:42124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHVcM-0000EA-RH for submit@debbugs.gnu.org; Thu, 06 Jul 2023 16:30:23 -0400 Original-Received: from robust-software.ca ([174.136.98.50]:2568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHVcJ-0000Dx-1y for 64311@debbugs.gnu.org; Thu, 06 Jul 2023 16:30:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=virgo1; bh=FeS4DHtRKFfio jCcva9S4UR2ft/QN8Mnp5/JKKF7rhA=; h=date:in-reply-to:subject:cc:to: from:references; d=oneofus.la; b=Jdgzyg+ajy/e8DdUT5MZ5qmy+lIcHPp7nVgXR WyiusEymtcM4ksnffBAfu09y7epZ7LXi3DbDRYyIsYdOThTBJ+q0+dc96KV0aBE+xXrEB5 9X22xqQ17Aw7+qsc5AJbEiaDjZJl7/Sf6cY0hoWc7yc0bZ3gqHbfrgtXS1+FdZV8= Original-Received: from t510.orion.oneofus.la (node-1w7jra28qzk6wfx48h3rdwwcc.ipv6.telus.net [2001:56a:f913:3c01:18c0:ef97:141b:54bc]) by virgo1.oneofus.la (OpenSMTPD) with ESMTPSA id 95503d41 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 6 Jul 2023 13:30:17 -0700 (PDT) In-reply-to: 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:264698 Archived-At: --=-=-= Content-Type: text/plain Attached is a patch that keeps defvaralias, and does not obsolete anything. -- 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 9edd92e6e2763f5e2d7bf6dc5009ce857f3d36ae 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: ; remove redundant declaration of shell-dirtrackp ; 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 | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index b74442f1961..47e7fa4b535 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -346,10 +346,9 @@ 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.") +(defvaralias 'shell-dirtrackp 'shell-dirtrack-mode + "Non-nil in a shell buffer means directory tracking is enabled. +Superseded by the minor mode variable `shell-dirtrack-mode'.") =20 (defvar shell-last-dir nil "Keep track of last directory for ksh `cd -' command.") @@ -997,6 +996,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 +1026,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 +1180,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 --=-=-=--