unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it
@ 2021-05-16  8:45 Dale Sedivec
  2022-07-13 11:51 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Dale Sedivec @ 2021-05-16  8:45 UTC (permalink / raw)
  To: 48461

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))





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it
  2021-05-16  8:45 bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it Dale Sedivec
@ 2022-07-13 11:51 ` Lars Ingebrigtsen
  2022-07-17 21:56   ` Dale Sedivec
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-13 11:51 UTC (permalink / raw)
  To: Dale Sedivec; +Cc: 48461

Dale Sedivec <dale@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@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it
  2022-07-13 11:51 ` Lars Ingebrigtsen
@ 2022-07-17 21:56   ` Dale Sedivec
  2022-07-22 15:07     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Dale Sedivec @ 2022-07-17 21:56 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 48461

On Jul 13, 2022, at 06:51, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Dale Sedivec <dale@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@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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it
  2022-07-17 21:56   ` Dale Sedivec
@ 2022-07-22 15:07     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-22 15:07 UTC (permalink / raw)
  To: Dale Sedivec; +Cc: 48461

Dale Sedivec <dale@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-22 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16  8:45 bug#48461: 28.0.50; Renaming a directory in dired doesn't update buffers visiting files within it Dale Sedivec
2022-07-13 11:51 ` Lars Ingebrigtsen
2022-07-17 21:56   ` Dale Sedivec
2022-07-22 15:07     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).