summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/emacs.el
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/emacs.el')
-rw-r--r--accounts/gkleen@sif/emacs.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/emacs.el b/accounts/gkleen@sif/emacs.el
index c57118b4..ad04c9ea 100644
--- a/accounts/gkleen@sif/emacs.el
+++ b/accounts/gkleen@sif/emacs.el
@@ -188,3 +188,26 @@ necessarily running."
188 (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) 188 (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling))
189 189
190(add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) 190(add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer)
191
192(defun move-file (new-location)
193 "Write this file to NEW-LOCATION, and delete the old one."
194 (interactive (list (expand-file-name
195 (if buffer-file-name
196 (read-file-name "Move file to: ")
197 (read-file-name "Move file to: "
198 default-directory
199 (expand-file-name (file-name-nondirectory (buffer-name))
200 default-directory))))))
201 (when (file-exists-p new-location)
202 (delete-file new-location))
203 (let ((old-location (expand-file-name (buffer-file-name))))
204 (message "old file is %s and new file is %s"
205 old-location
206 new-location)
207 (write-file new-location t)
208 (when (and old-location
209 (file-exists-p new-location)
210 (not (string-equal old-location new-location)))
211 (delete-file old-location))))
212
213(bind-key "C-x C-m" #'move-file)