GNU bug report logs - #48461
28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it

Previous Next

Package: emacs;

Reported by: Dale Sedivec <dale <at> codefu.org>

Date: Sun, 16 May 2021 08:46:01 UTC

Severity: normal

Tags: moreinfo

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48461 in the body.
You can then email your comments to 48461 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48461; Package emacs. (Sun, 16 May 2021 08:46:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dale Sedivec <dale <at> codefu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 16 May 2021 08:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dale Sedivec <dale <at> codefu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 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
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=-O2 -I/opt/local/include/gcc10' LDFLAGS=-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))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48461; Package emacs. (Wed, 13 Jul 2022 11:53:02 GMT) Full text and rfc822 format available.

Message #8 received at 48461 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dale Sedivec <dale <at> codefu.org>
Cc: 48461 <at> debbugs.gnu.org
Subject: Re: bug#48461: 28.0.50; Renaming a directory in dired doesn't
 update buffers visiting files within it
Date: Wed, 13 Jul 2022 13:51:57 +0200
Dale Sedivec <dale <at> codefu.org> writes:

> If you rename a directory via dired, buffers within that directory will
> not also have their paths updated with the new directory.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

It looks like this was fixed in a patch series ending with:

commit e71c7a7c600bae3337de95d193dd106e9bfa2b4c
Author:     Eli Zaretskii <eliz <at> gnu.org>
AuthorDate: Mon Apr 11 14:31:04 2022 +0300

    Fix default-directory of buffers visiting files in renamed directories

Do you still see this problem in the current Emacs tree?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 13 Jul 2022 11:53:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48461; Package emacs. (Sun, 17 Jul 2022 21:57:02 GMT) Full text and rfc822 format available.

Message #13 received at 48461 <at> debbugs.gnu.org (full text, mbox):

From: Dale Sedivec <dale <at> codefu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 48461 <at> debbugs.gnu.org
Subject: Re: bug#48461: 28.0.50; Renaming a directory in dired doesn't update
 buffers visiting files within it
Date: Sun, 17 Jul 2022 16:56:07 -0500
On Jul 13, 2022, at 06:51, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> 
> Dale Sedivec <dale <at> codefu.org> writes:
> 
>> If you rename a directory via dired, buffers within that directory will
>> not also have their paths updated with the new directory.
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> It looks like this was fixed in a patch series ending with:
> 
> commit e71c7a7c600bae3337de95d193dd106e9bfa2b4c
> Author:     Eli Zaretskii <eliz <at> gnu.org>
> AuthorDate: Mon Apr 11 14:31:04 2022 +0300
> 
>    Fix default-directory of buffers visiting files in renamed directories
> 
> Do you still see this problem in the current Emacs tree?

Yes, I think this is now fixed.  Thank you to Eli for fixing it, and to you for following up.

Dale





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48461; Package emacs. (Fri, 22 Jul 2022 15:09:01 GMT) Full text and rfc822 format available.

Message #16 received at 48461 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dale Sedivec <dale <at> codefu.org>
Cc: 48461 <at> debbugs.gnu.org
Subject: Re: bug#48461: 28.0.50; Renaming a directory in dired doesn't
 update buffers visiting files within it
Date: Fri, 22 Jul 2022 17:07:52 +0200
Dale Sedivec <dale <at> codefu.org> writes:

> Yes, I think this is now fixed.  Thank you to Eli for fixing it, and
> to you for following up.

Thanks for checking; I'm closing this bug report, then.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 48461 <at> debbugs.gnu.org and Dale Sedivec <dale <at> codefu.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 22 Jul 2022 15:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 20 Aug 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 221 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.