[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0332142e8e: Fix rename-visited-file when renaming to a directory
From: |
Lars Ingebrigtsen |
Subject: |
master 0332142e8e: Fix rename-visited-file when renaming to a directory name |
Date: |
Fri, 30 Sep 2022 09:07:55 -0400 (EDT) |
branch: master
commit 0332142e8e78b49b4f98438be21d2868e738986b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix rename-visited-file when renaming to a directory name
* lisp/files.el (rename-visited-file): Allow renaming to a
directory file name (bug#58182).
---
lisp/files.el | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lisp/files.el b/lisp/files.el
index 5463f3b5ec..10b156fb30 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4866,6 +4866,14 @@ Interactively, this prompts for NEW-LOCATION."
(expand-file-name
(file-name-nondirectory (buffer-name))
default-directory)))))
+ ;; If the user has given a directory name, the file should be moved
+ ;; there (under the same file name).
+ (when (file-directory-p new-location)
+ (unless buffer-file-name
+ (user-error "Can't rename buffer to a directory file name"))
+ (setq new-location (expand-file-name
+ (file-name-nondirectory buffer-file-name)
+ new-location)))
(when (and buffer-file-name
(file-exists-p buffer-file-name))
(rename-file buffer-file-name new-location))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0332142e8e: Fix rename-visited-file when renaming to a directory name,
Lars Ingebrigtsen <=