mu4e: add command mu4e-sexp-at-point

Add command ~mu4e-sexp-at-point~ for showing/hiding the s-expression for the
message-at-point. Useful for development / debugging. Bound to ~,~ in headers and
view mode.
This commit is contained in:
Dirk-Jan C. Binnema 2022-05-14 20:45:33 +03:00
parent 619c1c81fe
commit aea2f58c77
4 changed files with 24 additions and 10 deletions

View File

@ -119,6 +119,10 @@
- Removed header-fields ~:attachments~, ~:signature~, ~:encryption~ and
~:user-agent~. They're obsolete with the Gnus-based message viewer.
- Add command ~mu4e-sexp-at-point~ for showing/hiding the s-expression for the
message-at-point. Useful for development / debugging. Bound to ~,~ in headers
and view mode.
- undo is now supported across message-saves
- a lot of the internals have been changed:

View File

@ -932,6 +932,8 @@ after the end of the search results."
(define-key map "t" 'mu4e-headers-mark-subthread)
(define-key map "T" 'mu4e-headers-mark-thread)
(define-key map "," #'mu4e-sexp-at-point)
;; navigation between messages
(define-key map "p" 'mu4e-headers-prev)
(define-key map "n" 'mu4e-headers-next)

View File

@ -30,6 +30,7 @@
(require 'mu4e-contacts)
(require 'flow-fill)
(require 'shr)
(require 'pp)
(declare-function mu4e-error "mu4e-helpers")
(declare-function mu4e-warn "mu4e-helpers")
@ -47,9 +48,9 @@
(defsubst mu4e-message-field-raw (msg field)
"Retrieve FIELD from message plist MSG.
FIELD is one of :from, :to, :cc, :bcc, :subject, :data,
:message-id, :path, :maildir, :priority, :attachments,
:references, :in-reply-to, :body-txt, :body-html
See \"mu fields\" for the full list of field, in particular the
\"sexp\" column.
Returns nil if the field does not exist.
@ -66,13 +67,6 @@ A message plist looks something like:
:maildir \"/INBOX\"
:priority normal
:flags (seen)
:attachments
((:index 2 :name \"photo.jpg\" :mime-type \"image/jpeg\" :size 147331)
(:index 3 :name \"book.pdf\" :mime-type \"application/pdf\" :size 192220))
:references (\"238C8384574032D81EE81AF0114E4E74@123213.mail.example.com\"
\"6BDC23465F79238203498230942D81EE81AF0114E4E74@123213.mail.example.com\")
:in-reply-to \"238203498230942D81EE81AF0114E4E74@123213.mail.example.com\"
:body-txt \"Hi Tom, ...\"
\)).
Some notes on the format:
- The address fields are lists of plist (:name NAME :email EMAIL),
@ -228,6 +222,19 @@ If MSG is nil, use `mu4e-message-at-point'."
(kill-new path)
(mu4e-message "Saved '%s' to kill-ring" path)))
(defconst mu4e--sexp-buffer-name " *mu4e-sexp-at-point"
"Buffer name for sexp buffers.")
(defun mu4e-sexp-at-point ()
"Show or hide the s-expression for the message-at-point, if any."
(interactive)
(if-let ((win (get-buffer-window mu4e--sexp-buffer-name)))
(delete-window win)
(when-let ((msg (mu4e-message-at-point 'noerror)))
(with-current-buffer-window mu4e--sexp-buffer-name nil nil
;; the "pretty-printing" is not very pretty...
(insert (pp-to-string msg))))))
;;;
(provide 'mu4e-message)
;;; mu4e-message.el ends here

View File

@ -887,6 +887,7 @@ This is useful for advising some Gnus-functionality that does not work in mu4e."
(define-key map "E" #'mu4e-compose-edit)
(define-key map "." #'mu4e-view-raw-message)
(define-key map "," #'mu4e-sexp-at-point)
(define-key map "|" #'mu4e-view-pipe)
(define-key map "a" #'mu4e-view-action)
(define-key map "A" #'mu4e-view-mime-part-action)