diff options
Diffstat (limited to 'lisp/mk.el')
-rw-r--r-- | lisp/mk.el | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lisp/mk.el b/lisp/mk.el new file mode 100644 index 0000000..634f09a --- /dev/null +++ b/lisp/mk.el @@ -0,0 +1,74 @@ +;;; Code: + +(defun mk/kill-other-buffers () + "Kill all other buffers." + (interactive) + (mapc (lambda (buffer) + (when (and (buffer-file-name buffer) (not (eq buffer (current-buffer)))) + (kill-buffer buffer))) + (buffer-list))) + +(defun mk/format-xml () + (interactive) + (shell-command-on-region 1 (point-max) "xmllint --format -" (current-buffer) t) + ) + +;; Copy the entire buffer. +(defun mk/copy-all () + "Copy entire buffer to clipboard." + (interactive) + (clipboard-kill-ring-save (point-min) (point-max))) + +(defun mk/create-directory () + "Create a directory and refresh neotree." + (interactive) + (call-interactively #'make-directory) + (other-window -1)) +(bind-key* (kbd "C-c d n") 'mk/create-directory) + +(defun mk/delete-file () + "Delete a file and refresh neotree." + (interactive) + (call-interactively #'delete-file)) +(bind-key* (kbd "C-c f d") 'mk/delete-file) + +(defun mk/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)) + +(bind-key* (kbd "C-c f n") 'mk/create-file) + + + +(defun mk/delete-directory () + "Delete a file and refresh neotree." + (interactive) + (call-interactively #'delete-directory)) +(bind-key* (kbd "C-c d d") 'mk/delete-directory) + + +;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file +(defun mk/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 "C-c f r") 'mk/rename-file) + + +(provide 'mk) +;;; mk.el ends here |