Edit some email stuff

This commit is contained in:
2026-02-20 07:47:47 -08:00
parent eca7942215
commit b26ff9e735
2 changed files with 74 additions and 56 deletions

View File

@ -16,27 +16,10 @@
(defvar-local org-mu4e--html-message-p t
"Weather or not the current message should be htmlized.")
(defvar-local org-mu4e--override-org-mode-check nil
"Internal variable.
See `org-mu4e--override-org-mode-check-advice' for information about what this
does.")
(defvar org-mu4e--internal-message-mode-function
(symbol-function 'mu4e-compose-mode)
"The `message-mode' (or derived mode) used by `org-mu4e-compose-mode'.")
(defun org-mu4e--override-org-mode-check-advice (oldfun &rest r)
"Around advice for various org mode functions.
This function will call OLDFUN with arguments R with `major-mode' let-bound to
\\='org-mode when `org-mu4e--override-org-mode-check' is t."
(let ((major-mode (if org-mu4e--override-org-mode-check
'org-mode
major-mode)))
(apply oldfun r)))
(advice-add 'org-element-at-point :around
'org-mu4e--override-org-mode-check-advice)
(defun org-mu4e-toggle-htmlize-mssage (&optional arg no-message)
"Toggle weather the current message should be htmlized.
If ARG is a positive number or zero, enable htmlization, if it is negative,
@ -206,17 +189,22 @@ ARG is passed directly to `message-send'."
t ;; this tells org that we have handled the C-c C-c
)
(defmacro org-mu4e--with-replaced-compse-func (&rest body)
"Evaluate BODY with `mu4e-compose-mode' rebound to `org-mu4e-compose-mode'.
This makes use of `cl-letf' internally."
`(let ((org-mu4e--internal-message-mode-function
(symbol-function 'mu4e-compose-mode)))
(cl-letf (((symbol-function 'mu4e-compose-mode) 'org-mu4e-compose-mode))
,@body)))
;;;###autoload
(defun org-mu4e-compose-new (&rest r)
"This is like `mu4e-compose-new', but it utilizes `org-mu4e-compose-mode'.
Each of the arguments in R are the same as `mu4e-compose-new', and are directly
passed to it."
(interactive)
;; Save local variables set by `mu4e-compose-new'
(let ((org-mu4e--internal-message-mode-function
(symbol-function 'mu4e-compose-mode)))
(cl-letf (((symbol-function 'mu4e-compose-mode) 'org-mu4e-compose-mode))
(apply 'mu4e-compose-new r))))
(org-mu4e--with-replaced-compse-func
(apply 'mu4e-compose-new r)))
;;;###autoload
(defun org-mu4e-compose-reply-to (&optional to wide)
@ -227,10 +215,8 @@ TO and WIDE are the same as `mu4e-compose-reply-to'."
(let ((html-part-p (seq-find (lambda (handle)
(equal (mm-handle-media-type (cdr handle))
"text/html"))
gnus-article-mime-handle-alist))
(org-mu4e--internal-message-mode-function
(symbol-function 'mu4e-compose-mode)))
(cl-letf (((symbol-function 'mu4e-compose-mode) 'org-mu4e-compose-mode))
gnus-article-mime-handle-alist)))
(org-mu4e--with-replaced-compse-func
(let ((buf (mu4e-compose-reply-to to wide)))
(with-current-buffer buf
(setq org-mu4e--html-message-p
@ -244,6 +230,13 @@ WIDE is the same as `mu4e-compose-reply'."
(interactive "P")
(org-mu4e-compose-reply-to nil wide))
;;;###autoload
(defun org-mu4e-compose-edit ()
"This is like `mu4e-compose-edit', but utilizes `org-mu4e-compose-mode'."
(interactive)
(org-mu4e--with-replaced-compse-func
(mu4e-compose-edit)))
;;;###autoload
(defvar-keymap org-mu4e-compose-mode-map
:parent org-mode-map
@ -340,13 +333,16 @@ This is derived from `org-mode', but it also essentially runs
;; Add `message-mode' keyword and quote highlighting on top of the org syntax
;; highlighting
(font-lock-add-keywords nil message-font-lock-keywords)
(setq-local org-mu4e--override-org-mode-check t)
(setq-local org-mu4e--override-org-mode-check t
org-export-with-toc nil)
(add-to-list (make-local-variable 'org-ctrl-c-ctrl-c-final-hook)
'org-mu4e-send-and-exit)
(add-to-list (make-local-variable 'mode-line-misc-info)
'(:eval (if org-mu4e--html-message-p
"Text/HTML "
"Text Only "))))
;;;###autoload(derived-mode-add-parents 'org-mu4e-compose-mode '(mu4e-compose-mode))
(derived-mode-add-parents 'org-mu4e-compose-mode '(mu4e-compose-mode))
;;;###autoload
(define-mail-user-agent 'org-mu4e-user-agent

66
init.el
View File

@ -2352,6 +2352,14 @@ Note that this erases the buffer before doing anything."
(advice-add 'jupyter-org--set-src-block-cache :around
#'my/-fix-jupyter-org--set-src-block-cache)
;; prevent warning in `execute-extended-command'
(defun my/-fix-jupyter-org--define-key-filter (oldfun &rest args)
"Prevent calling `jupyter-org--define-key-filter' outside of `org-mode'."
(when (derived-mode-p 'org-mode)
(apply oldfun args)))
(advice-add 'jupyter-org--define-key-filter :around
#'my/-fix-jupyter-org--define-key-filter)
(face-spec-set 'jupyter-repl-traceback
'((default . (:background unspecified)))
'face-override-spec)
@ -3317,30 +3325,44 @@ This will also update waybar."
;; mu4e compose HTML messages
(use-package org-mime)
(require 'org-mu4e-compose)
(setq ;; mail-user-agent 'org-mu4e-user-agent
(setq mail-user-agent 'org-mu4e-user-agent
org-mime-org-html-with-latex-default 'dvisvgm
org-mime-export-options '(:with-latex dvisvgm :with-footnotes t))
;; (evil-define-key '(normal visual) org-mu4e-compose-mode-map
;; "G" #'mu4e-compose-goto-bottom
;; "gg" #'mu4e-compose-goto-top)
;; (evil-define-key 'normal org-mu4e-compose-mode-map
;; "ZZ" #'message-send-and-exit
;; "ZD" #'message-dont-send
;; "ZQ" #'message-kill-buffer
;; "ZF" #'mml-attach-file)
;; (evil-define-key 'normal mu4e-view-mode-map
;; "R" 'org-mu4e-compose-reply
;; "cr" 'org-mu4e-compose-reply)
;; (evil-define-key 'normal mu4e-headers-mode-map
;; "R" 'org-mu4e-compose-reply
;; "cr" 'org-mu4e-compose-reply)
;; (defun my/-setup-org-mu4e-compose-mode ()
;; "Setup up stuff in `org-mu4e-compose' buffers."
;; (setq-local ltex-eglot-variable-save-method 'file)
;; ;; this should come last so it can pick up the above
;; ;; (my/eglot-if-trusted)
;; )
;; (add-hook 'org-mu4e-compose-mode-hook #'my/-setup-org-mu4e-compose-mode)
(evil-define-key '(normal visual) org-mu4e-compose-mode-map
"G" #'mu4e-compose-goto-bottom
"gg" #'mu4e-compose-goto-top)
(evil-define-key 'normal org-mu4e-compose-mode-map
"ZZ" #'message-send-and-exit
"ZD" #'message-dont-send
"ZQ" #'message-kill-buffer
"ZF" #'mml-attach-file)
(evil-define-key 'normal mu4e-view-mode-map
"R" #'org-mu4e-compose-reply
"cr" #'org-mu4e-compose-reply
"ce" #'org-mu4e-compose-edit)
(evil-define-key 'normal mu4e-headers-mode-map
"R" #'org-mu4e-compose-reply
"cr" #'org-mu4e-compose-reply
"E" #'org-mu4e-compose-edit
"ce" #'org-mu4e-compose-edit)
(evil-define-key 'normal mu4e-main-mode-map
"C" #'compose-mail
"cc" #'compose-mail)
(defun my/-setup-org-mu4e-compose-mode ()
"Setup up stuff in `org-mu4e-compose' buffers."
(setq-local ltex-eglot-variable-save-method 'file)
;; this should come last so it can pick up the above
;; (my/eglot-if-trusted)
)
(add-hook 'org-mu4e-compose-mode-hook #'my/-setup-org-mu4e-compose-mode)
(setopt mu4e-compose-switch 'display-buffer)
(defun my/-match-mu4e-message-buffer (buffer _action)
"Matcher for mu4e message buffers for `display-buffer-alist'.
BUFFER is the buffer-or-string to match against."
(provided-mode-derived-p (buffer-local-value 'major-mode (get-buffer buffer))
'mu4e-compose-mode))
(add-to-list 'display-buffer-alist
'(my/-match-mu4e-message-buffer . (display-buffer-same-window)))
;; elfeed
(use-package elfeed