From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dale Sedivec Newsgroups: gmane.emacs.bugs Subject: bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it Date: Sun, 16 May 2021 03:45:36 -0500 Message-ID: <805388FF-A600-435A-81B3-D163A481ED1A@codefu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8546"; mail-complaints-to="usenet@ciao.gmane.io" To: 48461@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 16 10:46:11 2021 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 1liCPb-00020s-1h for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 May 2021 10:46:11 +0200 Original-Received: from localhost ([::1]:54080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liCPZ-0003gt-2H for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 May 2021 04:46:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liCPS-0003gi-A1 for bug-gnu-emacs@gnu.org; Sun, 16 May 2021 04:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1liCPS-00020l-1s for bug-gnu-emacs@gnu.org; Sun, 16 May 2021 04:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1liCPR-00025K-Ut for bug-gnu-emacs@gnu.org; Sun, 16 May 2021 04:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dale Sedivec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 May 2021 08:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48461 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16211547457985 (code B ref -1); Sun, 16 May 2021 08:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 May 2021 08:45:45 +0000 Original-Received: from localhost ([127.0.0.1]:49688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liCPA-00024j-I0 for submit@debbugs.gnu.org; Sun, 16 May 2021 04:45:44 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liCP9-00024c-Cw for submit@debbugs.gnu.org; Sun, 16 May 2021 04:45:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liCP9-0003gP-4m for bug-gnu-emacs@gnu.org; Sun, 16 May 2021 04:45:43 -0400 Original-Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:35346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1liCP6-0001m5-Jy for bug-gnu-emacs@gnu.org; Sun, 16 May 2021 04:45:42 -0400 Original-Received: by mail-io1-xd35.google.com with SMTP id d24so2882918ios.2 for ; Sun, 16 May 2021 01:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codefu-org.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=2ilkHjM5DCypP26vtljhOPU1vjhBIdlwedNlFTH0jgg=; b=IqyfpoOYuLOVZWkADkHWcKhcOpWPKFQl2DkVl8rx5cjsVVpb4h7tsR6CmmYI+n1+Xz 73B4G2iCaRtiH+TrqTpfSwnXIe7WLXnaNVGlNzgLIvjt9naXmZfOL1od6FCVr93F/tpx IF+bCvYCMX3uGvKVIOptsT6O4QAGgtgqgj/RUgDmioJmrBbn67r8rOsN8UFzDKI40oiP G/fRub1gUlo0dQQN3fFFk4V3M9ds6PFXMJYspPO3tgcyYvQBdhGgNeY9Ax6KS89EEZc/ tROT+k14iNduugMQiaFio6XY8tcAT379nGjdPe4c8b8gVr2aKGrGtD4d18KGbQqnw+d5 5Y0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=2ilkHjM5DCypP26vtljhOPU1vjhBIdlwedNlFTH0jgg=; b=oVSO0irw07reJWM5i4tuu0+/wNUv8oxEJAEQ5hhdmNvBB5gwzbDONGmfBQhDIV2q7E vKBoNG/zXYskMOCTVDeNyXXevhULppQAYusRcKwQHXccM4VhjPvYhopGadud5QAMOUNz 7kg4Ck8TxQRvDVX0XlRuKxV+tZTW1TGofee6jVfSs6s52fNTwR5j9q/IuvSXbaG37ZRB aZSnByK+b0Uk0++FXpsZgzmn/PPdKyFinVQ74EBRa2wONkvsGYS15o7jJZLEKWr9evRZ C6Bwsjnbektx8TS2bHc/H4IGWgyv5wsTYyAzUTV3cdgXcQrwRSd3vUy/edHhxZRTNQR4 A9Vw== X-Gm-Message-State: AOAM532cwDarxsfwtRTTkxmGDou/hBl8Eun8Nmykm10KfG+7Yxx8bA6V KHsLr4tzH9yI9kWgAKyUWX1uNKzmh8xj8g== X-Google-Smtp-Source: ABdhPJwuNzCgwHIaCuWV03KUjtHrPauRdtpcEx+vg39gO6YOW1tZQUkYn7Mw8rsFMDR/blwEjb1H2A== X-Received: by 2002:a02:c652:: with SMTP id k18mr3137782jan.105.1621154737858; Sun, 16 May 2021 01:45:37 -0700 (PDT) Original-Received: from smtpclient.apple (136-30-160-152.cab.webpass.net. [136.30.160.152]) by smtp.gmail.com with ESMTPSA id s17sm6113427ilt.77.2021.05.16.01.45.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 May 2021 01:45:37 -0700 (PDT) X-Mailer: Apple Mail (2.3654.80.0.2.43) Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=dale@codefu.org; helo=mail-io1-xd35.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:206645 Archived-At: If you rename a directory via dired, buffers within that directory will not also have their paths updated with the new directory. Steps to reproduce: 1. Start "emacs -Q"" 2. Evaluate the following: (let* ((temp-dir (make-temp-file "dired_bug" t)) (subdir (expand-file-name "foo" temp-dir)) (a-file (expand-file-name "zzzz" subdir))) (make-directory subdir) (find-file a-file) (insert "blah blah blah") (save-buffer) (dired temp-dir)) This should create a temporary directory, a subdirectory "foo" within that temp dir, it opens a buffer for a file "zzzz" within that subdirectory "foo", and then a dired buffer on the temp dir. For example, you'll now have a buffer on file "/tmp/dired_bug-123abc/foo/zzzz" and a dired buffer on directory "/tmp/dired_bug-123abc". 3. In the dired buffer, rename the directory "foo" to "bar" 4. Go back to the buffer on "bar" and look at its path (i.e. eval buffer-file-name, or C-x C-w and look at the path, or just try to modify the file and then save it) Expected result: The buffer that was visiting ".../foo/zzzz" will now visit ".../bar/zzzz" because ".../foo" was renamed to ".../bar" Observed result: The buffer visiting ".../foo/zzzz" is still visiting the old path I think function `dired-rename-subdir' would actually update the file's path, but when `dired-rename-file' is called to rename the directory, I think it never calls `dired-rename-subdir' because of the condition guarding it (dired-aux.el, end of `dired-rename-file', ca. line 1797): ;; See if it's an inserted subdir, and rename that, too. (when (file-directory-p file) (dired-rename-subdir file newname)) `file' here is the *old* file name, as far as I can tell. Because the rename has already been performed, I think `file-directory-p' will always return nil here. I suspect changing `file' to `newname' in that invocation of `file-directory-p' might yield the desired result. A little work with "git blame" says this condition was added in commit 9e5fd29bede, which says that it "[Fixes a] previous manual mis-merge of dired-aux". However, it looks like the lines surrounding this change were not modified in quite a long time. I could be misreading, though! In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.4.0, NS = appkit-2022.44 Version 11.3 (Build 20E232)) of 2021-04-28 built on Dale Repository revision: e62e87d51651d8dba9e6e612004e689c23428f99 Repository branch: master System Description: macOS 11.3 Configured using: 'configure --without-x --with-modules --with-threads --with-xwidgets --with-zlib --with-xml2 --with-json --with-cairo --with-gnutls --with-xpm --with-jpeg --with-tiff --with-gif --with-png --with-rsvg --with-native-compilation --with-ns --enable-ns-self-contained 'CFLAGS=3D-O2 -I/opt/local/include/gcc10' = LDFLAGS=3D-L/opt/local/lib/gcc10' Configured features: ACL GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TOOLKIT_SCROLL_BARS XIM XWIDGETS ZLIB Important settings: value of $LC_COLLATE: C value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: show-paren-mode: t electric-pair-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs password-cache json map time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail comp comp-cstr warnings subr-x rx cl-seq rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils dired-aux dired dired-loaddefs vc-git diff-mode easy-mmode vc-dispatcher cl-extra shortdoc text-property-search seq paren cl-print debug backtrace find-func cus-start cus-load elec-pair thingatpt help-fns radix-tree help-mode cl-macs cl-loaddefs cl-lib pcase term/screen term/xterm xterm byte-opt gv bytecomp byte-compile cconv jka-compr iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads xwidget-internal kqueue cocoa ns lcms2 multi-tty make-network-process nativecomp emacs) Memory information: ((conses 16 216885 12751) (symbols 48 9937 1) (strings 32 29808 2866) (string-bytes 1 983898) (vectors 16 16676) (vector-slots 8 315497 10417) (floats 8 85 37) (intervals 56 31760 0) (buffers 992 16))