From 2be95ea0ff7285624268e75135d52b7a3b68d1ef Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sat, 30 Apr 2016 16:49:03 +0100 Subject: [PATCH 1/2] Use read-from-minibuffer for the new file name `read-file-name` works great for existing file names, but this command is often used to renaming files to names that aren't currently used. If a user is using a completion backend like ido or helm, `read-file-name` will prompt them for an *existing* file name. Instead, allow them to input arbitrary strings. --- crux.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crux.el b/crux.el index e88bc0c..8c167f9 100644 --- a/crux.el +++ b/crux.el @@ -232,7 +232,7 @@ point reaches the beginning or end of the buffer, stop there." (let ((filename (buffer-file-name))) (if (not (and filename (file-exists-p filename))) (rename-buffer (read-from-minibuffer "New name: " (buffer-name))) - (let ((new-name (read-file-name "New name: " filename))) + (let ((new-name (read-from-minibuffer "New name: " filename))) (cond ((vc-backend filename) (vc-rename-file filename new-name)) (t From 1967a754832d8e02c0b230ea8fc026fda400d417 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sat, 30 Apr 2016 16:52:58 +0100 Subject: [PATCH 2/2] Allow users to create directories with crux-rename-file-and-buffer --- crux.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crux.el b/crux.el index 8c167f9..ff88d40 100644 --- a/crux.el +++ b/crux.el @@ -232,7 +232,9 @@ point reaches the beginning or end of the buffer, stop there." (let ((filename (buffer-file-name))) (if (not (and filename (file-exists-p filename))) (rename-buffer (read-from-minibuffer "New name: " (buffer-name))) - (let ((new-name (read-from-minibuffer "New name: " filename))) + (let* ((new-name (read-from-minibuffer "New name: " filename)) + (containing-dir (file-name-directory new-name))) + (make-directory containing-dir t) (cond ((vc-backend filename) (vc-rename-file filename new-name)) (t