diff options
author | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-05-30 20:01:34 -0400 |
---|---|---|
committer | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-05-30 20:01:34 -0400 |
commit | f43fbf5c39982c21e552bfa96fe14aa4b814cc20 (patch) | |
tree | 09f1b416ef0c0336631b26eea6c1500cf2e593cb | |
parent | Improve default `isearch` functionality (diff) | |
download | mmosmacs-f43fbf5c39982c21e552bfa96fe14aa4b814cc20.tar.gz mmosmacs-f43fbf5c39982c21e552bfa96fe14aa4b814cc20.tar.bz2 mmosmacs-f43fbf5c39982c21e552bfa96fe14aa4b814cc20.zip |
Add function to kill buffer after deleting file
-rw-r--r-- | init.el | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -571,6 +571,30 @@ | |||
571 | 571 | ||
572 | 572 | ||
573 | ;; --------------------------------- | 573 | ;; --------------------------------- |
574 | ;; Delete files | ||
575 | ;; ------------ | ||
576 | ;; Make deleting files a lot more | ||
577 | ;; convenient. | ||
578 | ;; --------------------------------- | ||
579 | |||
580 | ;; It's possible to delete a file | ||
581 | ;; and forget about it, then save | ||
582 | ;; buffer again. This function kills | ||
583 | ;; the buffer after deleting the | ||
584 | ;; file. | ||
585 | (defun mm/delete-visited-file (buffer-name) | ||
586 | "Delete the file visited by BUFFER-NAME." | ||
587 | (interactive "bDelete file visited by buffer ") | ||
588 | (let* ((buffer (get-buffer buffer-name)) | ||
589 | (filename (buffer-file-name buffer))) | ||
590 | (when buffer | ||
591 | (when (and filename | ||
592 | (file-exists-p filename)) | ||
593 | (delete-file filename)) | ||
594 | (kill-buffer buffer)))) | ||
595 | |||
596 | |||
597 | ;; --------------------------------- | ||
574 | ;; Project management | 598 | ;; Project management |
575 | ;; ------------------ | 599 | ;; ------------------ |
576 | ;; `Projectile' provides features | 600 | ;; `Projectile' provides features |