Subject: Re: bug#30578: 26.0; Dired: moving current directory (./)

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 14 Jul 2019 16:40:04 +0200

Drew Adams <[email-masked]> writes:

> See https://emacs.stackexchange.com/a/39010/105.
>
> Putting point on the current-directory line of a Dired listing, i.e.,
> `.', and using `R' to move/rename that directory, works, but you get an
> error message, and you don't end up in a Dired listing for that
> (now-renamed) directory.
>
> This is the error message you get, where /some/dir1/dir2/ccc/ is the
> directory listed in Dired, i.e., the dir that corresponds to `.' in the
> Dired listing:
>
> Expected to find /some/dir1/dir2/ccc/./ in headerline of
> /some/dir1/dir2/ccc/

This seems to be still present on the Emacs trunk, and here's the
backtrace (which you should include in bug reports like this).

If I understand the code correctly, it simply doesn't understand that
"." is the directory itself, and treats it as any subdirectory: It
removes the line with "." from the buffer and then wants to adjust the
header line.

Instead, I guess it should...  point the current directory to the new
location?  But keep all the contents in the buffer (you may have marked
files and the like)?

Alternatively, for a really easy fix, it could just error out
immediately when you try this.  :-/

Debugger entered--Lisp error: (error "Expected to find ‘/tmp/foo1/./’ in headerline of /tmp/foo1/")
  signal(error ("Expected to find ‘/tmp/foo1/./’ in headerline of /tmp/foo1/"))
  error("Expected to find `%s' in headerline of %s" "/tmp/foo1/./" "/tmp/foo1/")
  dired-rename-subdir-2(("/tmp/foo1/" . #<marker at 1 in foo1>) "/tmp/foo1/./" "/tmp/lala1/")
  dired-rename-subdir-1("/tmp/foo1/./" "/tmp/lala1/")
  apply(dired-rename-subdir-1 ("/tmp/foo1/./" "/tmp/lala1/"))
  dired-fun-in-all-buffers("/tmp/foo1/./" nil dired-rename-subdir-1 "/tmp/foo1/./" "/tmp/lala1/")
  dired-rename-subdir("/tmp/foo1/." "/tmp/lala1")
  dired-rename-file("/tmp/foo1/." "/tmp/lala1" nil)
  dired-create-files(dired-rename-file "Move" ("/tmp/foo1/.") #f(compiled-function (from) #<bytecode 0x156ba85788fd>) t)
  dired-do-create-files(move dired-rename-file "Move" nil t "Rename")
  dired-do-rename(nil)
  
-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no