diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lisp/general.el | 34 |
2 files changed, 24 insertions, 11 deletions
@@ -10,6 +10,7 @@ Emacs configuration file - Grep in project: `s-F` - Refactor : `F2` - Move line up/down: `M-<UP/DOWN>` +- Find references: `M-?` ## Per-language Features diff --git a/lisp/general.el b/lisp/general.el index 6def4b8..68e3521 100644 --- a/lisp/general.el +++ b/lisp/general.el @@ -141,10 +141,11 @@ (bind-key* (kbd "M-x") 'counsel-M-x) (bind-key* (kbd "C-;") 'neotree-toggle) -(defun my-create-file () - "Create a file and refresh neotree." - (interactive) - (call-interactively #'make-empty-file) +(defun my-create-file (filename) + "Create a file and refresh neotree. FILENAME File to create." + (interactive (list (read-file-name "Enter your file name: " nil nil nil (file-name-nondirectory "")))) + (make-empty-file filename) + (find-file filename) (neotree-show) (neotree-refresh) (other-window -1)) @@ -178,13 +179,24 @@ (other-window -1)) (bind-key* (kbd "M-D") 'my-delete-directory) -(defun my-rename-file () - "Rename a file and refresh neotree." - (interactive) - (call-interactively #'rename-file) - (neotree-show) - (neotree-refresh) - (other-window -1)) +;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file +(defun my-rename-file (new-name) + "Renames both current buffer and file it's visiting to NEW-NAME." + (interactive "sNew name: ") + (let ((name (buffer-name)) + (filename (buffer-file-name))) + (if (not filename) + (message "Buffer '%s' is not visiting a file!" name) + (if (get-buffer new-name) + (message "A buffer named '%s' already exists!" new-name) + (progn + (rename-file filename new-name 1) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil) + (neotree-show) + (neotree-refresh) + (other-window -1)))))) (bind-key* (kbd "M-r") 'my-rename-file) ;; Company mode for code completion |