Fix file rename target path when buffer name is uniquified

When the buffer's name is uniquified (because multiple buffers have
the same short name), it is no longer equal to the basename of the
buffer's file name, so it is incorrect to use the buffer name in the
rename operation.
This commit is contained in:
Aaron L. Zeng 2021-08-16 19:08:01 -04:00 committed by Maxi Wolff
parent 2f0f7a3fe7
commit 1a9ebf42df

View file

@ -415,8 +415,8 @@ projectile cache and updates recentf list."
;; originally from magnars
(defun spacemacs/rename-buffer-visiting-a-file (&optional arg)
(let* ((old-short-name (buffer-name))
(old-filename (buffer-file-name))
(let* ((old-filename (buffer-file-name))
(old-short-name (file-name-nondirectory (buffer-file-name)))
(old-dir (file-name-directory old-filename))
(new-name (let ((path (read-file-name "New name: " (if arg old-dir old-filename))))
(if (string= (file-name-nondirectory path) "")