Mercurial > dotfiles
annotate .elisp/settings/99.move-file.el @ 530:dbb75edda2ff default tip
cleanup: remove ancient distnoted reaper script
Surely this bug has been fixed in the 9+ years that the script has
been run once a minute by cron on my laptop. To my surprise, it looks
like the Migration Assistant even managed to carry it across laptops!
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Sat, 03 Jan 2026 19:12:16 -0500 |
| parents | 2f24474b1f84 |
| children |
| rev | line source |
|---|---|
|
454
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1 ;; emacs move-file function from http://zck.me/emacs-move-file |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2 |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
3 (defun move-file (new-location) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
4 "Write this file to NEW-LOCATION, and delete the old one." |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
5 (interactive (list (if buffer-file-name |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
6 (read-file-name "Move file to: ") |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
7 (read-file-name "Move file to: " |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
8 default-directory |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
9 (expand-file-name (file-name-nondirectory (buffer-name)) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
10 default-directory))))) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
11 (when (file-exists-p new-location) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
12 (delete-file new-location)) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
13 (let ((old-location (buffer-file-name))) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
14 (write-file new-location t) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
15 (when (and old-location |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
16 (file-exists-p new-location)) |
|
2f24474b1f84
move-file: new function for emacs to move a file and fix up the buffer
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
17 (delete-file old-location)))) |
