From 7fd8180412949cbca95fc1c5afc5af634d7cae62 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Fri, 29 Nov 2024 13:26:21 +0200 Subject: . --- home/dots/.emacs | 58 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/home/dots/.emacs b/home/dots/.emacs index 57540f2..610f285 100644 --- a/home/dots/.emacs +++ b/home/dots/.emacs @@ -133,7 +133,7 @@ (ediff-split-window-function #'split-window-horizontally)) (use-package emacs - :config + :init (fset 'yes-or-no-p 'y-or-n-p) (menu-bar-mode -1) (tool-bar-mode -1) @@ -151,34 +151,28 @@ (undo-outer-limit 20000000) (create-lockfiles nil) (idle-update-delay 1.0) - - - + (custom-safe-themes + '(default "~/.emacs.d/BOGO-theme.el" "~/.emacs.d/BOGO-dark-theme.el")) (auto-save-list-file-prefix - (expand-file-name "autosave/" user-emacs-directory)) + (expand-file-name "autosave/" user-emacs-directory)) (tramp-auto-save-directory - (expand-file-name "tramp-autosave/" user-emacs-directory)) - + (expand-file-name "tramp-autosave/" user-emacs-directory)) ;; Auto save options (kill-buffer-delete-auto-save-files t) - ;; Revert other buffers (e.g, Dired) (global-auto-revert-non-file-buffers t) - -;;; recentf + ;;; recentf ;; `recentf' is an Emacs package that maintains a list of recently ;; accessed files, making it easier to reopen files you have worked on ;; recently. (recentf-max-saved-items 300) ; default is 20 (recehvntf-auto-cleanup 'mode) - ;;; saveplace ;; `save-place-mode` enables Emacs to remember the last location within a file ;; upon reopening. This feature is particularly beneficial for resuming work at ;; the precise point where you previously left off. (save-place-file (expand-file-name "saveplace" user-emacs-directory)) (save-place-limit 600) - ;;; savehist ;; `savehist` is an Emacs feature that preserves the minibuffer history between ;; sessions. It saves the history of inputs in the minibuffer, such as commands, @@ -189,16 +183,13 @@ ;; Resizing the Emacs frame can be costly when changing the font. Disable this ;; to improve startup times with fonts larger than the system default. (frame-resize-pixelwise t) - ;; However, do not resize windows pixelwise, as this can cause crashes in some ;; cases when resizing too many windows at once or rapidly. (window-resize-pixelwise nil) (resize-mini-windows 'grow-only) - (fast-but-imprecise-scrolling t) (blink-cursor-mode -1) (x-stretch-cursor t) - (tab-always-indent 'complete) (text-mode-ispell-word-completion nil) (read-extended-command-predicate #'command-completion-default-include-p )) @@ -1233,6 +1224,9 @@ (use-package flyspell :diminish flyspell-mode + :bind + (:map flyspell-mode-map + ("C-." . nil)) :defer t) (use-package face-remap @@ -1279,17 +1273,41 @@ (interactive) (rmail-reply t)) - (defun rmail-write-for-patch () - "Writes the mail to an mbox file that you can later run git am on to apply it." - (interactive) - (rmail-output-as-seen "/tmp/new-patch.patch")) + (defmacro without-yes-or-no (&rest body) + "Override `yes-or-no-p' & `y-or-n-p', not to prompt for input and return t." + (declare (indent 1)) + `(cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) + ((symbol-function 'y-or-n-p) (lambda (&rest _) t))) + ,@body)) + + ;; Copied from the pipe of mu4e + (defun rmail-process-file-through-pipe (path pipecmd) + "Process file at PATH through a pipe with PIPECMD." + (let ((buf (get-buffer-create "*rmail-output"))) + (with-current-buffer buf + (let ((inhibit-read-only t)) + (erase-buffer) + (call-process-shell-command pipecmd path t t) + (view-mode))) + (display-buffer buf))) + + (defun rmail-pipe-email (cmd) + (interactive "sShell command: ") + (let ((path + (concat "/tmp/rmail-pipe-msg-" + (number-to-string (time-convert (current-time) 'integer)) + ".mbox"))) + (without-yes-or-no + (rmail-output-as-seen path nil t) + (rmail-process-file-through-pipe path cmd)))) + :bind (("C-c m" . rmail-open) ("C-c M" . rmail-open-no-check) :map rmail-mode-map ("r" . rmail-reply-t) ("R" . rmail-reply) - ("O" . rmail-write-for-patch)) + ("|" . rmail-pipe-email)) :config (defun rmail-no-check () (interactive) -- cgit v1.2.3