diff --git a/README.md b/README.md index df2d158..c6e45de 100644 --- a/README.md +++ b/README.md @@ -294,7 +294,7 @@ Keybinding | Description C-c D | Delete current file and buffer. C-c d | Duplicate the current line (or region). C-c M-d | Duplicate and comment the current line (or region). -C-c r | Rename the currently visited file and buffer. +C-c r | Rename the current buffer and its visiting file if any. C-c t | Open a terminal emulator (`ansi-term`). C-c k | Kill all open buffers except the one you're currently in. C-c TAB | Indent and copy region to clipboard diff --git a/core/prelude-core.el b/core/prelude-core.el index 538ea54..9216f9d 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -251,12 +251,12 @@ there's a region, all lines that region covers will be duplicated." (setq end (point)))) (goto-char (+ origin (* (length region) arg) arg)))) -(defun prelude-rename-file-and-buffer () - "Renames current buffer and file it is visiting." +(defun prelude-rename-buffer-and-file () + "Rename current buffer and if the buffer is visiting a file, rename it too." (interactive) (let ((filename (buffer-file-name))) (if (not (and filename (file-exists-p filename))) - (message "Buffer is not visiting a file!") + (rename-buffer (read-from-minibuffer "New name: " (buffer-name))) (let ((new-name (read-file-name "New name: " filename))) (cond ((vc-backend filename) (vc-rename-file filename new-name)) @@ -434,7 +434,7 @@ Doesn't mess with special buffers." "Press to search in GitHub." "Press to search in YouTube." "Press to search in DuckDuckGo." - "Press to rename the current buffer and file it's visiting." + "Press to rename the current buffer and the file it's visiting if any." "Press to open a terminal in Emacs." "Press to kill all the buffers, but the active one." "Press or to run magit-status." diff --git a/core/prelude-mode.el b/core/prelude-mode.el index dadfc56..20a21d4 100644 --- a/core/prelude-mode.el +++ b/core/prelude-mode.el @@ -58,7 +58,7 @@ (define-key map (kbd "C-c D") 'prelude-delete-file-and-buffer) (define-key map (kbd "C-c d") 'prelude-duplicate-current-line-or-region) (define-key map (kbd "C-c M-d") 'prelude-duplicate-and-comment-current-line-or-region) - (define-key map (kbd "C-c r") 'prelude-rename-file-and-buffer) + (define-key map (kbd "C-c r") 'prelude-rename-buffer-and-file) (define-key map (kbd "C-c t") 'prelude-visit-term-buffer) (define-key map (kbd "C-c k") 'prelude-kill-other-buffers) (define-key map (kbd "C-c TAB") 'prelude-indent-rigidly-and-copy-to-clipboard) @@ -89,7 +89,7 @@ ("Files" ["Open with..." prelude-open-with] ["Delete file and buffer" prelude-delete-file-and-buffer] - ["Rename file and buffer" prelude-rename-file-and-buffer] + ["Rename buffer and file" prelude-rename-buffer-and-file] ["Copy file name to clipboard" prelude-copy-file-name-to-clipboard]) ("Buffers"