dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 015206c7d86434148c0a700aa3d262025f8eb25b
parent bc525ea530233ea9608b2bfdbe2943c7537c32fe
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Thu,  7 Jul 2022 23:22:04 +0200

emacs: delete by trash+keybinding to delete current buffer & its file

Diffstat:
Memacs/config.org | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/emacs/config.org b/emacs/config.org @@ -106,6 +106,13 @@ The second one actually loads them. (setq custom-file (expand-file-name (concat user-emacs-directory "custom.el"))) (load custom-file) #+end_src +** Delete by trash +#+begin_src emacs-lisp + (setq delete-by-moving-to-trash t) + (unless (fboundp 'system-move-file-to-trash) + (setq trash-directory "~/.Trash")) +#+end_src + * Theme Icons required for some parts of the doom theme: @@ -422,7 +429,6 @@ To be able to link to emails via notmuch, I use ol-notmuch: #+begin_src emacs-lisp (use-package ol-notmuch :quelpa) #+end_src - *** Agenda & GTD **** Agenda mode settings Fix tag display by dynamically calculating the column. @@ -2041,6 +2047,26 @@ I like to be able to kill a buffer instantly: (za/global-set-key (kbd "s-<backspace>") 'kill-current-buffer) #+end_src +** Delete this file (and kill the buffer) +#+begin_src emacs-lisp + (defun za/delete-this-file () + "Kill the current buffer and delete its associated file." + (interactive) + (let ((fname (buffer-file-name)) + (buf (current-buffer))) + (unless (and fname (file-exists-p fname)) + (user-error (format "Buffer has no associated file."))) + + (unless (y-or-n-p (format "Really delete %s and its buffer?" fname)) + (user-error "User cancelled.")) + + (delete-file fname 'trash-if-enabled) + (kill-buffer buf) + (message "Deleted %s and killed its buffer." fname))) + + (za/global-set-key (kbd "C-c s-<backspace>") #'za/delete-this-file) +#+end_src + ** Toggle fullscreen I'll use the keybinding that's standard on macOS: