mu4e-view: rename mu4e~view -> mu4e--view

Our long-running migration from mu4e~ -> mu4e-- takes another step.
This commit is contained in:
Dirk-Jan C. Binnema 2022-12-24 10:02:21 +02:00
parent 2bb270eb07
commit 1799c69451
6 changed files with 122 additions and 122 deletions

View File

@ -738,7 +738,7 @@ docid is not found."
(defun mu4e~headers-view-this-message-p (docid) (defun mu4e~headers-view-this-message-p (docid)
"Is DOCID currently being viewed?" "Is DOCID currently being viewed?"
(mu4e-get-view-buffers (mu4e-get-view-buffers
(lambda (_) (eq docid (plist-get mu4e~view-message :docid))))) (lambda (_) (eq docid (plist-get mu4e--view-message :docid)))))
;; note: this function is very performance-sensitive ;; note: this function is very performance-sensitive
(defun mu4e~headers-append-handler (msglst) (defun mu4e~headers-append-handler (msglst)

View File

@ -84,7 +84,7 @@
(gnus-icalendar-setup) (gnus-icalendar-setup)
(cl-defmethod gnus-icalendar-event:inline-reply-buttons :around (cl-defmethod gnus-icalendar-event:inline-reply-buttons :around
((event gnus-icalendar-event) handle) ((event gnus-icalendar-event) handle)
(if (and (boundp 'mu4e~view-rendering) (if (and (boundp 'mu4e--view-rendering)
(gnus-icalendar-event:rsvp event)) (gnus-icalendar-event:rsvp event))
(let ((method (gnus-icalendar-event:method event))) (let ((method (gnus-icalendar-event:method event)))
(when (or (string= method "REQUEST") (string= method "PUBLISH")) (when (or (string= method "REQUEST") (string= method "PUBLISH"))

View File

@ -110,7 +110,7 @@ no such message. If optional NOERROR is non-nil, do not raise an
error when there is no message at point." error when there is no message at point."
(or (cond (or (cond
((eq major-mode 'mu4e-headers-mode) (get-text-property (point) 'msg)) ((eq major-mode 'mu4e-headers-mode) (get-text-property (point) 'msg))
((eq major-mode 'mu4e-view-mode) mu4e~view-message)) ((eq major-mode 'mu4e-view-mode) mu4e--view-message))
(unless noerror (mu4e-warn "No message at point")))) (unless noerror (mu4e-warn "No message at point"))))
(defsubst mu4e-message-field-at-point (field) (defsubst mu4e-message-field-at-point (field)
@ -142,7 +142,7 @@ expressions, in which case any of those are tried for a match."
(seq-find (seq-find
(lambda (ct) (lambda (ct)
(let ((name (mu4e-contact-name ct)) (let ((name (mu4e-contact-name ct))
(email (mu4e-contact-email ct)) (email (mu4e-contact-email ct))
;; the 'rx' may be some `/rx/` from mu4e-personal-addresses; ;; the 'rx' may be some `/rx/` from mu4e-personal-addresses;
;; so let's detect and extract in that case. ;; so let's detect and extract in that case.
(rx (if (string-match-p "^\\(.*\\)/$" rx) (rx (if (string-match-p "^\\(.*\\)/$" rx)
@ -160,7 +160,7 @@ of the of the contacts in field CFIELD (either :to, :from, :cc or
which `mu4e-personal-address-p' return t. Returns the contact which `mu4e-personal-address-p' return t. Returns the contact
cell that matched, or nil." cell that matched, or nil."
(seq-find (lambda (cell) (seq-find (lambda (cell)
(mu4e-personal-address-p (mu4e-contact-email cell))) (mu4e-personal-address-p (mu4e-contact-email cell)))
(mu4e-message-field msg cfield))) (mu4e-message-field msg cfield)))
(defun mu4e-message-sent-by-me (msg) (defun mu4e-message-sent-by-me (msg)
@ -217,7 +217,7 @@ If MSG is nil, use `mu4e-message-at-point'."
(kill-buffer mu4e--sexp-buffer-name)) (kill-buffer mu4e--sexp-buffer-name))
(with-current-buffer-window (get-buffer-create mu4e--sexp-buffer-name) nil nil (with-current-buffer-window (get-buffer-create mu4e--sexp-buffer-name) nil nil
(lisp-data-mode) (lisp-data-mode)
(insert (pp-to-string msg)) (insert (pp-to-string msg))
(font-lock-ensure) (font-lock-ensure)
;; add basic `quit-window' bindings ;; add basic `quit-window' bindings
(view-mode 1))))) (view-mode 1)))))

View File

@ -369,8 +369,8 @@ header-view, not including, for instance, the message body.")
;; before calling `mu4e-view-mode'. However, changing the major mode ;; before calling `mu4e-view-mode'. However, changing the major mode
;; clobbers any local variables. Work around that by declaring the ;; clobbers any local variables. Work around that by declaring the
;; variable permanent-local. ;; variable permanent-local.
(defvar-local mu4e~view-message nil "The message being viewed in view mode.") (defvar-local mu4e--view-message nil "The message being viewed in view mode.")
(put 'mu4e~view-message 'permanent-local t) (put 'mu4e--view-message 'permanent-local t)
;;; _ ;;; _
(provide 'mu4e-vars) (provide 'mu4e-vars)
;;; mu4e-vars.el ends here ;;; mu4e-vars.el ends here

View File

@ -114,14 +114,14 @@ specified a function as viewer."
(defconst mu4e~view-raw-buffer-name " *mu4e-raw-view*" (defconst mu4e--view-raw-buffer-name " *mu4e-raw-view*"
"Name for the raw message view buffer.") "Name for the raw message view buffer.")
(defun mu4e-view-raw-message () (defun mu4e-view-raw-message ()
"Display the raw contents of message at point in a new buffer." "Display the raw contents of message at point in a new buffer."
(interactive) (interactive)
(let ((path (mu4e-message-readable-path)) (let ((path (mu4e-message-readable-path))
(buf (get-buffer-create mu4e~view-raw-buffer-name))) (buf (get-buffer-create mu4e--view-raw-buffer-name)))
(with-current-buffer buf (with-current-buffer buf
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
@ -137,7 +137,7 @@ Then, display the results."
(let ((path (mu4e-message-readable-path))) (let ((path (mu4e-message-readable-path)))
(mu4e-process-file-through-pipe path cmd))) (mu4e-process-file-through-pipe path cmd)))
(defmacro mu4e~view-in-headers-context (&rest body) (defmacro mu4e--view-in-headers-context (&rest body)
"Evaluate BODY in the context of the headers buffer." "Evaluate BODY in the context of the headers buffer."
`(progn `(progn
(let* ((msg (mu4e-message-at-point)) (let* ((msg (mu4e-message-at-point))
@ -180,7 +180,7 @@ If this succeeds, return the new docid. Otherwise, return nil.
Optionally, takes an integer N (prefix argument), to the Nth next Optionally, takes an integer N (prefix argument), to the Nth next
header." header."
(interactive "P") (interactive "P")
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e~headers-move (or n 1)))) (mu4e~headers-move (or n 1))))
(defun mu4e-view-headers-prev (&optional n) (defun mu4e-view-headers-prev (&optional n)
@ -189,16 +189,16 @@ If this succeeds, return the new docid. Otherwise, return nil.
Optionally, takes an integer N (prefix argument), to the Nth Optionally, takes an integer N (prefix argument), to the Nth
previous header." previous header."
(interactive "P") (interactive "P")
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e~headers-move (- (or n 1))))) (mu4e~headers-move (- (or n 1)))))
(defun mu4e~view-prev-or-next-unread (backwards) (defun mu4e--view-prev-or-next-unread (backwards)
"Move point to the next or previous message. "Move point to the next or previous message.
Go to the previous message if BACKWARDS is non-nil. Go to the previous message if BACKWARDS is non-nil.
unread message header in the headers buffer connected with this unread message header in the headers buffer connected with this
message view. If this succeeds, return the new docid. Otherwise, message view. If this succeeds, return the new docid. Otherwise,
return nil." return nil."
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e~headers-prev-or-next-unread backwards)) (mu4e~headers-prev-or-next-unread backwards))
(mu4e-select-other-view) (mu4e-select-other-view)
(mu4e-headers-view-message)) (mu4e-headers-view-message))
@ -207,13 +207,13 @@ return nil."
"Move point to the previous unread message header. "Move point to the previous unread message header.
If this succeeds, return the new docid. Otherwise, return nil." If this succeeds, return the new docid. Otherwise, return nil."
(interactive) (interactive)
(mu4e~view-prev-or-next-unread t)) (mu4e--view-prev-or-next-unread t))
(defun mu4e-view-headers-next-unread () (defun mu4e-view-headers-next-unread ()
"Move point to the next unread message header. "Move point to the next unread message header.
If this succeeds, return the new docid. Otherwise, return nil." If this succeeds, return the new docid. Otherwise, return nil."
(interactive) (interactive)
(mu4e~view-prev-or-next-unread nil)) (mu4e--view-prev-or-next-unread nil))
;;; Interactive functions ;;; Interactive functions
@ -233,7 +233,7 @@ Ask user for a kind of mark, (move, delete etc.), a field to
match and a regular expression to match with. Then, mark all match and a regular expression to match with. Then, mark all
matching messages with that mark." matching messages with that mark."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e-headers-mark-pattern))) (mu4e--view-in-headers-context (mu4e-headers-mark-pattern)))
(defun mu4e-view-mark-thread (&optional markpair) (defun mu4e-view-mark-thread (&optional markpair)
"Mark whole thread with a certain mark. "Mark whole thread with a certain mark.
@ -242,7 +242,7 @@ to all messages in the thread at point in the headers view. The
optional MARKPAIR can also be used to provide the mark optional MARKPAIR can also be used to provide the mark
selection." selection."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(if markpair (mu4e-headers-mark-thread nil markpair) (if markpair (mu4e-headers-mark-thread nil markpair)
(call-interactively 'mu4e-headers-mark-thread)))) (call-interactively 'mu4e-headers-mark-thread))))
@ -253,19 +253,19 @@ to all messages in the subthread at point in the headers view.
The optional MARKPAIR can also be used to provide the mark The optional MARKPAIR can also be used to provide the mark
selection." selection."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(if markpair (mu4e-headers-mark-subthread markpair) (if markpair (mu4e-headers-mark-subthread markpair)
(mu4e-headers-mark-subthread)))) (mu4e-headers-mark-subthread))))
(defun mu4e-view-search-narrow () (defun mu4e-view-search-narrow ()
"Run `mu4e-headers-search-narrow' in the headers buffer." "Run `mu4e-headers-search-narrow' in the headers buffer."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e-search-narrow))) (mu4e--view-in-headers-context (mu4e-search-narrow)))
(defun mu4e-view-search-edit () (defun mu4e-view-search-edit ()
"Run `mu4e-search-edit' in the headers buffer." "Run `mu4e-search-edit' in the headers buffer."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e-search-edit))) (mu4e--view-in-headers-context (mu4e-search-edit)))
(defun mu4e-mark-region-code () (defun mu4e-mark-region-code ()
"Highlight region marked with `message-mark-inserted-region'. "Highlight region marked with `message-mark-inserted-region'.
@ -299,10 +299,10 @@ Add this function to `mu4e-view-mode-hook' to enable this feature."
(defun mu4e-view-mark-custom () (defun mu4e-view-mark-custom ()
"Run some custom mark function." "Run some custom mark function."
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e-headers-mark-custom))) (mu4e-headers-mark-custom)))
(defun mu4e~view-split-view-p () (defun mu4e--view-split-view-p ()
"Return t if we're in split-view, nil otherwise." "Return t if we're in split-view, nil otherwise."
(member mu4e-split-view '(horizontal vertical))) (member mu4e-split-view '(horizontal vertical)))
@ -361,8 +361,8 @@ any further, go the next message."
Otherwise, warn user that unmarking only works in the header Otherwise, warn user that unmarking only works in the header
list." list."
(interactive) (interactive)
(if (mu4e~view-split-view-p) (if (mu4e--view-split-view-p)
(mu4e~view-in-headers-context (mu4e-mark-unmark-all)) (mu4e--view-in-headers-context (mu4e-mark-unmark-all))
(mu4e-message "Unmarking needs to be done in the header list view"))) (mu4e-message "Unmarking needs to be done in the header list view")))
(defun mu4e-view-unmark () (defun mu4e-view-unmark ()
@ -370,73 +370,73 @@ list."
Otherwise, warn user that unmarking only works in the header Otherwise, warn user that unmarking only works in the header
list." list."
(interactive) (interactive)
(if (mu4e~view-split-view-p) (if (mu4e--view-split-view-p)
(mu4e-view-mark-for-unmark) (mu4e-view-mark-for-unmark)
(mu4e-message "Unmarking needs to be done in the header list view"))) (mu4e-message "Unmarking needs to be done in the header list view")))
(defmacro mu4e~view-defun-mark-for (mark) (defmacro mu4e--view-defun-mark-for (mark)
"Define a function mu4e-view-mark-for- MARK." "Define a function mu4e-view-mark-for- MARK."
(let ((funcname (intern (format "mu4e-view-mark-for-%s" mark))) (let ((funcname (intern (format "mu4e-view-mark-for-%s" mark)))
(docstring (format "Mark the current message for %s." mark))) (docstring (format "Mark the current message for %s." mark)))
`(progn `(progn
(defun ,funcname () ,docstring (defun ,funcname () ,docstring
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e-headers-mark-and-next ',mark))) (mu4e-headers-mark-and-next ',mark)))
(put ',funcname 'definition-name ',mark)))) (put ',funcname 'definition-name ',mark))))
(mu4e~view-defun-mark-for move) (mu4e--view-defun-mark-for move)
(mu4e~view-defun-mark-for refile) (mu4e--view-defun-mark-for refile)
(mu4e~view-defun-mark-for delete) (mu4e--view-defun-mark-for delete)
(mu4e~view-defun-mark-for flag) (mu4e--view-defun-mark-for flag)
(mu4e~view-defun-mark-for unflag) (mu4e--view-defun-mark-for unflag)
(mu4e~view-defun-mark-for unmark) (mu4e--view-defun-mark-for unmark)
(mu4e~view-defun-mark-for something) (mu4e--view-defun-mark-for something)
(mu4e~view-defun-mark-for read) (mu4e--view-defun-mark-for read)
(mu4e~view-defun-mark-for unread) (mu4e--view-defun-mark-for unread)
(mu4e~view-defun-mark-for trash) (mu4e--view-defun-mark-for trash)
(mu4e~view-defun-mark-for untrash) (mu4e--view-defun-mark-for untrash)
(defun mu4e-view-marked-execute () (defun mu4e-view-marked-execute ()
"Execute the marked actions." "Execute the marked actions."
(interactive) (interactive)
(mu4e~view-in-headers-context (mu4e--view-in-headers-context
(mu4e-mark-execute-all))) (mu4e-mark-execute-all)))
;;; URL handling ;;; URL handling
(defvar mu4e~view-link-map nil (defvar mu4e--view-link-map nil
"A map of some number->url so we can jump to url by number.") "A map of some number->url so we can jump to url by number.")
(put 'mu4e~view-link-map 'permanent-local t) (put 'mu4e--view-link-map 'permanent-local t)
(defvar mu4e-view-active-urls-keymap (defvar mu4e-view-active-urls-keymap
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key map [down-mouse-1] 'mu4e~view-browse-url-from-binding) (define-key map [down-mouse-1] 'mu4e--view-browse-url-from-binding)
(define-key map [mouse-1] 'mu4e~view-browse-url-from-binding) (define-key map [mouse-1] 'mu4e--view-browse-url-from-binding)
(define-key map (kbd "M-<return>") 'mu4e~view-browse-url-from-binding) (define-key map (kbd "M-<return>") 'mu4e--view-browse-url-from-binding)
map) map)
"Keymap used for the urls inside the body.") "Keymap used for the urls inside the body.")
(defvar mu4e~view-beginning-of-url-regexp (defvar mu4e--view-beginning-of-url-regexp
"https?\\://\\|mailto:" "https?\\://\\|mailto:"
"Regexp that matches the beginning of certain URLs. "Regexp that matches the beginning of certain URLs.
Match-string 1 will contain the matched URL, if any.") Match-string 1 will contain the matched URL, if any.")
(defun mu4e~view-browse-url-from-binding (&optional url) (defun mu4e--view-browse-url-from-binding (&optional url)
"View in browser the url at point, or click location. "View in browser the url at point, or click location.
If the optional argument URL is provided, browse that instead. If the optional argument URL is provided, browse that instead.
If the url is mailto link, start writing an email to that address." If the url is mailto link, start writing an email to that address."
(interactive) (interactive)
(let* (( url (or url (mu4e~view-get-property-from-event 'mu4e-url)))) (let* (( url (or url (mu4e--view-get-property-from-event 'mu4e-url))))
(when url (when url
(if (string-match-p "^mailto:" url) (if (string-match-p "^mailto:" url)
(browse-url-mail url) (browse-url-mail url)
(browse-url url))))) (browse-url url)))))
(defun mu4e~view-get-property-from-event (prop) (defun mu4e--view-get-property-from-event (prop)
"Get the property PROP at point, or the location of the mouse. "Get the property PROP at point, or the location of the mouse.
The action is chosen based on the `last-command-event'. The action is chosen based on the `last-command-event'.
Meant to be evoked from interactive commands." Meant to be evoked from interactive commands."
@ -451,20 +451,20 @@ Meant to be evoked from interactive commands."
(get-text-property (point) prop))) (get-text-property (point) prop)))
;; this is fairly simplistic... ;; this is fairly simplistic...
(defun mu4e~view-activate-urls () (defun mu4e--view-activate-urls ()
"Turn things that look like URLs into clickable things. "Turn things that look like URLs into clickable things.
Also number them so they can be opened using `mu4e-view-go-to-url'." Also number them so they can be opened using `mu4e-view-go-to-url'."
(let ((num 0)) (let ((num 0))
(save-excursion (save-excursion
(setq mu4e~view-link-map ;; buffer local (setq mu4e--view-link-map ;; buffer local
(make-hash-table :size 32 :weakness nil)) (make-hash-table :size 32 :weakness nil))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward mu4e~view-beginning-of-url-regexp nil t) (while (re-search-forward mu4e--view-beginning-of-url-regexp nil t)
(let ((bounds (thing-at-point-bounds-of-url-at-point))) (let ((bounds (thing-at-point-bounds-of-url-at-point)))
(when bounds (when bounds
(let* ((url (thing-at-point-url-at-point)) (let* ((url (thing-at-point-url-at-point))
(ov (make-overlay (car bounds) (cdr bounds)))) (ov (make-overlay (car bounds) (cdr bounds))))
(puthash (cl-incf num) url mu4e~view-link-map) (puthash (cl-incf num) url mu4e--view-link-map)
(add-text-properties (add-text-properties
(car bounds) (car bounds)
(cdr bounds) (cdr bounds)
@ -480,14 +480,14 @@ Also number them so they can be opened using `mu4e-view-go-to-url'."
'face 'mu4e-url-number-face))))))))) 'face 'mu4e-url-number-face)))))))))
(defun mu4e~view-get-urls-num (prompt &optional multi) (defun mu4e--view-get-urls-num (prompt &optional multi)
"Ask the user with PROMPT for an URL number for MSG. "Ask the user with PROMPT for an URL number for MSG.
The number is [1..n] for URLs \[0..(n-1)] in the message. If The number is [1..n] for URLs \[0..(n-1)] in the message. If
MULTI is nil, return the number for the URL; otherwise (MULTI is MULTI is nil, return the number for the URL; otherwise (MULTI is
non-nil), accept ranges of URL numbers, as per non-nil), accept ranges of URL numbers, as per
`mu4e-split-ranges-to-numbers', and return the corresponding `mu4e-split-ranges-to-numbers', and return the corresponding
string." string."
(let* ((count (hash-table-count mu4e~view-link-map)) (def)) (let* ((count (hash-table-count mu4e--view-link-map)) (def))
(when (zerop count) (mu4e-error "No links for this message")) (when (zerop count) (mu4e-error "No links for this message"))
(if (not multi) (if (not multi)
(if (= count 1) (if (= count 1)
@ -502,16 +502,16 @@ string."
"Offer to go visit one or more URLs. "Offer to go visit one or more URLs.
If MULTI (prefix-argument) is non-nil, offer to go to a range of URLs." If MULTI (prefix-argument) is non-nil, offer to go to a range of URLs."
(interactive "P") (interactive "P")
(mu4e~view-handle-urls "URL to visit" (mu4e--view-handle-urls "URL to visit"
multi multi
(lambda (url) (mu4e~view-browse-url-from-binding url)))) (lambda (url) (mu4e--view-browse-url-from-binding url))))
(defun mu4e-view-save-url (&optional multi) (defun mu4e-view-save-url (&optional multi)
"Offer to save URLs to the kill ring. "Offer to save URLs to the kill ring.
If MULTI (prefix-argument) is nil, save a single one, otherwise, offer If MULTI (prefix-argument) is nil, save a single one, otherwise, offer
to save a range of URLs." to save a range of URLs."
(interactive "P") (interactive "P")
(mu4e~view-handle-urls "URL to save" multi (mu4e--view-handle-urls "URL to save" multi
(lambda (url) (lambda (url)
(kill-new url) (kill-new url)
(mu4e-message "Saved %s to the kill-ring" url)))) (mu4e-message "Saved %s to the kill-ring" url))))
@ -522,7 +522,7 @@ If MULTI (prefix-argument) is nil,
download a single one, otherwise, offer to fetch a range of download a single one, otherwise, offer to fetch a range of
URLs. The urls are fetched to `mu4e-attachment-dir'." URLs. The urls are fetched to `mu4e-attachment-dir'."
(interactive "P") (interactive "P")
(mu4e~view-handle-urls (mu4e--view-handle-urls
"URL to fetch" multi "URL to fetch" multi
(lambda (url) (lambda (url)
(let ((target (concat (mu4e~get-attachment-dir url) "/" (let ((target (concat (mu4e~get-attachment-dir url) "/"
@ -530,23 +530,23 @@ URLs. The urls are fetched to `mu4e-attachment-dir'."
(url-copy-file url target) (url-copy-file url target)
(mu4e-message "Fetched %s -> %s" url target))))) (mu4e-message "Fetched %s -> %s" url target)))))
(defun mu4e~view-handle-urls (prompt multi urlfunc) (defun mu4e--view-handle-urls (prompt multi urlfunc)
"Handle URLs. "Handle URLs.
If MULTI is nil, apply URLFUNC to a single uri, otherwise, apply If MULTI is nil, apply URLFUNC to a single uri, otherwise, apply
it to a range of uris. PROMPT is the query to present to the user." it to a range of uris. PROMPT is the query to present to the user."
(if multi (if multi
(mu4e~view-handle-multi-urls prompt urlfunc) (mu4e--view-handle-multi-urls prompt urlfunc)
(mu4e~view-handle-single-url prompt urlfunc))) (mu4e--view-handle-single-url prompt urlfunc)))
(defun mu4e~view-handle-single-url (prompt urlfunc &optional num) (defun mu4e--view-handle-single-url (prompt urlfunc &optional num)
"Apply URLFUNC to some URL with NUM in the current message. "Apply URLFUNC to some URL with NUM in the current message.
Prompting the user with PROMPT for the number." Prompting the user with PROMPT for the number."
(let* ((num (or num (mu4e~view-get-urls-num prompt))) (let* ((num (or num (mu4e--view-get-urls-num prompt)))
(url (gethash num mu4e~view-link-map))) (url (gethash num mu4e--view-link-map)))
(unless url (mu4e-warn "Invalid number for URL")) (unless url (mu4e-warn "Invalid number for URL"))
(funcall urlfunc url))) (funcall urlfunc url)))
(defun mu4e~view-handle-multi-urls (prompt urlfunc) (defun mu4e--view-handle-multi-urls (prompt urlfunc)
"Apply URLFUNC to a a range of URLs in the current message. "Apply URLFUNC to a a range of URLs in the current message.
Prompting the user with PROMPT for the numbers. Prompting the user with PROMPT for the numbers.
@ -557,16 +557,16 @@ of urls. You can type multiple values separated by space, e.g. 1
Furthermore, there is a shortcut \"a\" which means all urls, but as Furthermore, there is a shortcut \"a\" which means all urls, but as
this is the default, you may not need it." this is the default, you may not need it."
(let* ((linkstr (mu4e~view-get-urls-num (let* ((linkstr (mu4e--view-get-urls-num
"URL number range (or 'a' for 'all')" t)) "URL number range (or 'a' for 'all')" t))
(count (hash-table-count mu4e~view-link-map)) (count (hash-table-count mu4e--view-link-map))
(linknums (mu4e-split-ranges-to-numbers linkstr count))) (linknums (mu4e-split-ranges-to-numbers linkstr count)))
(dolist (num linknums) (dolist (num linknums)
(mu4e~view-handle-single-url prompt urlfunc num)))) (mu4e--view-handle-single-url prompt urlfunc num))))
(defun mu4e-view-for-each-uri (func) (defun mu4e-view-for-each-uri (func)
"Evaluate FUNC(uri) for each uri in the current message." "Evaluate FUNC(uri) for each uri in the current message."
(maphash (lambda (_num uri) (funcall func uri)) mu4e~view-link-map)) (maphash (lambda (_num uri) (funcall func uri)) mu4e--view-link-map))
(defun mu4e-view-message-with-message-id (msgid) (defun mu4e-view-message-with-message-id (msgid)
"View message with message-id MSGID. "View message with message-id MSGID.
@ -580,7 +580,7 @@ message."
(defvar gnus-icalendar-additional-identities) (defvar gnus-icalendar-additional-identities)
(defvar helm-comp-read-use-marked) (defvar helm-comp-read-use-marked)
(defvar-local mu4e~view-rendering nil) (defvar-local mu4e--view-rendering nil)
;; remember the mime-handles, so we can clean them up when ;; remember the mime-handles, so we can clean them up when
;; we quit this buffer. ;; we quit this buffer.
@ -620,8 +620,8 @@ As a side-effect, a message that is being viewed loses its
(erase-buffer) (erase-buffer)
(insert-file-contents-literally (insert-file-contents-literally
(mu4e-message-readable-path msg) nil nil nil t) (mu4e-message-readable-path msg) nil nil nil t)
(setq-local mu4e~view-message msg) (setq-local mu4e--view-message msg)
(mu4e~view-render-buffer msg)) (mu4e--view-render-buffer msg))
(mu4e-loading-mode 0))) (mu4e-loading-mode 0)))
(unless (mu4e--view-detached-p gnus-article-buffer) (unless (mu4e--view-detached-p gnus-article-buffer)
(with-current-buffer mu4e-linked-headers-buffer (with-current-buffer mu4e-linked-headers-buffer
@ -646,7 +646,7 @@ As a side-effect, a message that is being viewed loses its
(with-temp-buffer (with-temp-buffer
(insert-file-contents-literally (insert-file-contents-literally
(mu4e-message-readable-path msg) nil nil nil t) (mu4e-message-readable-path msg) nil nil nil t)
(mu4e~view-render-buffer msg) (mu4e--view-render-buffer msg)
(buffer-substring-no-properties (point-min) (point-max)))) (buffer-substring-no-properties (point-min) (point-max))))
(defun mu4e-action-view-in-browser (msg &optional skip-headers) (defun mu4e-action-view-in-browser (msg &optional skip-headers)
@ -683,7 +683,7 @@ determine which browser function to use."
(xwidget-webkit-browse-url url)))) (xwidget-webkit-browse-url url))))
(mu4e-action-view-in-browser msg))) (mu4e-action-view-in-browser msg)))
(defun mu4e~view-render-buffer (msg) (defun mu4e--view-render-buffer (msg)
"Render current buffer with MSG using Gnus' article mode." "Render current buffer with MSG using Gnus' article mode."
(setq gnus-summary-buffer (get-buffer-create " *appease-gnus*")) (setq gnus-summary-buffer (get-buffer-create " *appease-gnus*"))
(let* ((inhibit-read-only t) (let* ((inhibit-read-only t)
@ -693,7 +693,7 @@ determine which browser function to use."
(ct (and ct (mail-header-parse-content-type ct))) (ct (and ct (mail-header-parse-content-type ct)))
(charset (mail-content-type-get ct 'charset)) (charset (mail-content-type-get ct 'charset))
(charset (and charset (intern charset))) (charset (and charset (intern charset)))
(mu4e~view-rendering t); Needed if e.g. an ics file is buttonized (mu4e--view-rendering t); Needed if e.g. an ics file is buttonized
(gnus-article-emulate-mime t) (gnus-article-emulate-mime t)
(gnus-unbuttonized-mime-types '(".*/.*")) (gnus-unbuttonized-mime-types '(".*/.*"))
(gnus-buttonized-mime-types (gnus-buttonized-mime-types
@ -703,7 +703,7 @@ determine which browser function to use."
(if (and charset (coding-system-p charset)) charset (if (and charset (coding-system-p charset)) charset
(detect-coding-region (point-min) (point-max) t))) (detect-coding-region (point-min) (point-max) t)))
;; Possibly add headers (before "Attachments") ;; Possibly add headers (before "Attachments")
(gnus-display-mime-function (mu4e~view-gnus-display-mime msg)) (gnus-display-mime-function (mu4e--view-gnus-display-mime msg))
(gnus-icalendar-additional-identities (gnus-icalendar-additional-identities
(mu4e-personal-addresses 'no-regexp))) (mu4e-personal-addresses 'no-regexp)))
(condition-case err (condition-case err
@ -711,16 +711,16 @@ determine which browser function to use."
(mm-enable-multibyte) (mm-enable-multibyte)
(run-hooks 'gnus-article-decode-hook) (run-hooks 'gnus-article-decode-hook)
(gnus-article-prepare-display) (gnus-article-prepare-display)
(mu4e~view-activate-urls) (mu4e--view-activate-urls)
(setq mu4e~gnus-article-mime-handles gnus-article-mime-handles (setq mu4e~gnus-article-mime-handles gnus-article-mime-handles
gnus-article-decoded-p gnus-article-decode-hook) gnus-article-decoded-p gnus-article-decode-hook)
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(add-hook 'kill-buffer-hook #'mu4e~view-kill-mime-handles)) (add-hook 'kill-buffer-hook #'mu4e--view-kill-mime-handles))
(epg-error (epg-error
(mu4e-warn "EPG error: %s; fall back to raw view" (mu4e-warn "EPG error: %s; fall back to raw view"
(error-message-string err)))))) (error-message-string err))))))
(defun mu4e~view-kill-mime-handles () (defun mu4e--view-kill-mime-handles ()
"Kill cached MIME-handles, if any." "Kill cached MIME-handles, if any."
(when mu4e~gnus-article-mime-handles (when mu4e~gnus-article-mime-handles
(mm-destroy-parts mu4e~gnus-article-mime-handles) (mm-destroy-parts mu4e~gnus-article-mime-handles)
@ -731,7 +731,7 @@ determine which browser function to use."
(interactive) (interactive)
(when (derived-mode-p 'mu4e-view-mode) (when (derived-mode-p 'mu4e-view-mode)
(kill-buffer) (kill-buffer)
(mu4e-view mu4e~view-message))) (mu4e-view mu4e--view-message)))
(defun mu4e-view-toggle-show-mime-parts() (defun mu4e-view-toggle-show-mime-parts()
"Toggle whether to show all MIME-parts." "Toggle whether to show all MIME-parts."
@ -746,7 +746,7 @@ determine which browser function to use."
(setq mm-fill-flowed (not mm-fill-flowed)) (setq mm-fill-flowed (not mm-fill-flowed))
(mu4e-view-refresh)) (mu4e-view-refresh))
(defun mu4e~view-gnus-display-mime (msg) (defun mu4e--view-gnus-display-mime (msg)
"Like `gnus-display-mime' but include mu4e headers to MSG." "Like `gnus-display-mime' but include mu4e headers to MSG."
(lambda (&optional ihandles) (lambda (&optional ihandles)
(gnus-display-mime ihandles) (gnus-display-mime ihandles)
@ -759,7 +759,7 @@ determine which browser function to use."
(let ((fieldval (mu4e-message-field msg field))) (let ((fieldval (mu4e-message-field msg field)))
(pcase field (pcase field
((or ':path ':maildir :list ':user-agent ':message-id) ((or ':path ':maildir :list ':user-agent ':message-id)
(mu4e~view-gnus-insert-header field fieldval)) (mu4e--view-gnus-insert-header field fieldval))
(':mailing-list (':mailing-list
(let ((list (plist-get msg :list))) (let ((list (plist-get msg :list)))
(if list (mu4e-get-mailing-list-shortname list) ""))) (if list (mu4e-get-mailing-list-shortname list) "")))
@ -768,20 +768,20 @@ determine which browser function to use."
(if (symbolp flag) (if (symbolp flag)
(symbol-name flag) (symbol-name flag)
flag)) fieldval ", "))) flag)) fieldval ", ")))
(mu4e~view-gnus-insert-header field flags))) (mu4e--view-gnus-insert-header field flags)))
(':size (mu4e~view-gnus-insert-header (':size (mu4e--view-gnus-insert-header
field (mu4e-display-size fieldval))) field (mu4e-display-size fieldval)))
((or ':subject ':to ':from ':cc ':bcc ':from-or-to ((or ':subject ':to ':from ':cc ':bcc ':from-or-to
':date :attachments ':signature ':date :attachments ':signature
':decryption)) ; handled by Gnus ':decryption)) ; handled by Gnus
(_ (_
(mu4e~view-gnus-insert-header-custom msg field))))) (mu4e--view-gnus-insert-header-custom msg field)))))
(let ((gnus-treatment-function-alist (let ((gnus-treatment-function-alist
'((gnus-treat-highlight-headers '((gnus-treat-highlight-headers
gnus-article-highlight-headers)))) gnus-article-highlight-headers))))
(gnus-treat-article 'head)))))) (gnus-treat-article 'head))))))
(defun mu4e~view-gnus-insert-header (field val) (defun mu4e--view-gnus-insert-header (field val)
"Insert a header FIELD with value VAL." "Insert a header FIELD with value VAL."
(let* ((info (cdr (assoc field mu4e-header-info))) (let* ((info (cdr (assoc field mu4e-header-info)))
(key (plist-get info :name)) (key (plist-get info :name))
@ -790,7 +790,7 @@ determine which browser function to use."
(insert (propertize (concat key ":") 'help-echo help) (insert (propertize (concat key ":") 'help-echo help)
" " val "\n")))) " " val "\n"))))
(defun mu4e~view-gnus-insert-header-custom (msg field) (defun mu4e--view-gnus-insert-header-custom (msg field)
"Insert MSG's custom FIELD." "Insert MSG's custom FIELD."
(let* ((info (cdr-safe (or (assoc field mu4e-header-info-custom) (let* ((info (cdr-safe (or (assoc field mu4e-header-info-custom)
(mu4e-error "Custom field %S not found" field)))) (mu4e-error "Custom field %S not found" field))))
@ -804,9 +804,9 @@ determine which browser function to use."
(insert (propertize (concat key ":") 'help-echo help) " " val "\n")))) (insert (propertize (concat key ":") 'help-echo help) " " val "\n"))))
(define-advice gnus-icalendar-event-from-handle (define-advice gnus-icalendar-event-from-handle
(:filter-args (handle-attendee) mu4e~view-fix-missing-charset) (:filter-args (handle-attendee) mu4e--view-fix-missing-charset)
"Avoid error when displaying an ical attachment without a charset." "Avoid error when displaying an ical attachment without a charset."
(if (and (boundp 'mu4e~view-rendering) mu4e~view-rendering) (if (and (boundp 'mu4e--view-rendering) mu4e--view-rendering)
(let* ((handle (car handle-attendee)) (let* ((handle (car handle-attendee))
(attendee (cadr handle-attendee)) (attendee (cadr handle-attendee))
(buf (mm-handle-buffer handle)) (buf (mm-handle-buffer handle))
@ -818,26 +818,26 @@ determine which browser function to use."
(list handle attendee)) (list handle attendee))
handle-attendee)) handle-attendee))
(defun mu4e~view-mode-p () (defun mu4e--view-mode-p ()
"Is the buffer in mu4e-view-mode or one of its descendants?" "Is the buffer in mu4e-view-mode or one of its descendants?"
(or (eq major-mode 'mu4e-view-mode) (or (eq major-mode 'mu4e-view-mode)
(derived-mode-p '(mu4e-view-mode)))) (derived-mode-p '(mu4e-view-mode))))
(defun mu4e~view-nop (func &rest args) (defun mu4e--view-nop (func &rest args)
"Do not invoke FUNC with ARGS when in mu4e-view-mode. "Do not invoke FUNC with ARGS when in mu4e-view-mode.
This is useful for advising some Gnus-functionality that does not work in mu4e." This is useful for advising some Gnus-functionality that does not work in mu4e."
(unless (mu4e~view-mode-p) (unless (mu4e--view-mode-p)
(apply func args))) (apply func args)))
(defun mu4e~view-button-reply (func &rest args) (defun mu4e--view-button-reply (func &rest args)
"Advise FUNC with ARGS to make `gnus-button-reply' links work in mu4e." "Advise FUNC with ARGS to make `gnus-button-reply' links work in mu4e."
(if (mu4e~view-mode-p) (if (mu4e--view-mode-p)
(mu4e-compose-reply) (mu4e-compose-reply)
(apply func args))) (apply func args)))
(defun mu4e~view-msg-mail (func &rest args) (defun mu4e--view-msg-mail (func &rest args)
"Advise FUNC with ARGS to make `gnus-msg-mail' links compose with mu4e." "Advise FUNC with ARGS to make `gnus-msg-mail' links compose with mu4e."
(if (mu4e~view-mode-p) (if (mu4e--view-mode-p)
(apply 'mu4e~compose-mail args) (apply 'mu4e~compose-mail args)
(apply func args))) (apply func args)))
@ -1038,15 +1038,15 @@ Based on Gnus' article-mode."
;; Restore C-h b default behavior ;; Restore C-h b default behavior
(define-key mu4e-view-mode-map (kbd "C-h b") 'describe-bindings) (define-key mu4e-view-mode-map (kbd "C-h b") 'describe-bindings)
;; ;; turn off gnus modeline changes and menu items ;; ;; turn off gnus modeline changes and menu items
(advice-add 'gnus-set-mode-line :around #'mu4e~view-nop) (advice-add 'gnus-set-mode-line :around #'mu4e--view-nop)
(advice-add 'gnus-button-reply :around #'mu4e~view-button-reply) (advice-add 'gnus-button-reply :around #'mu4e--view-button-reply)
(advice-add 'gnus-msg-mail :around #'mu4e~view-msg-mail) (advice-add 'gnus-msg-mail :around #'mu4e--view-msg-mail)
;; advice gnus-block-private-groups to always return "." ;; advice gnus-block-private-groups to always return "."
;; so that by default we block images. ;; so that by default we block images.
(advice-add 'gnus-block-private-groups :around (advice-add 'gnus-block-private-groups :around
(lambda(func &rest args) (lambda(func &rest args)
(if (mu4e~view-mode-p) (if (mu4e--view-mode-p)
"." (apply func args)))) "." (apply func args))))
(use-local-map mu4e-view-mode-map) (use-local-map mu4e-view-mode-map)
(mu4e-context-minor-mode) (mu4e-context-minor-mode)
@ -1081,10 +1081,10 @@ Article Treatment' for more options."
(funcall (mu4e-read-option "Massage: " mu4e-view-massage-options))) (funcall (mu4e-read-option "Massage: " mu4e-view-massage-options)))
;;; MIME-parts ;;; MIME-parts
(defvar-local mu4e~view-mime-parts nil (defvar-local mu4e--view-mime-parts nil
"MIME parts for this message.") "MIME parts for this message.")
(defun mu4e~view-gather-mime-parts () (defun mu4e--view-gather-mime-parts ()
"Gather all MIME parts as an alist. "Gather all MIME parts as an alist.
The alist uniquely maps the number to the gnus-part." The alist uniquely maps the number to the gnus-part."
(let ((parts '())) (let ((parts '()))
@ -1116,7 +1116,7 @@ containing commas."
(interactive "P") (interactive "P")
(cl-assert (and (eq major-mode 'mu4e-view-mode) (cl-assert (and (eq major-mode 'mu4e-view-mode)
(derived-mode-p 'gnus-article-mode))) (derived-mode-p 'gnus-article-mode)))
(let* ((parts (mu4e~view-gather-mime-parts)) (let* ((parts (mu4e--view-gather-mime-parts))
(handles '()) (handles '())
(files '()) (files '())
(compfn (if (and (boundp 'helm-mode) helm-mode) (compfn (if (and (boundp 'helm-mode) helm-mode)
@ -1170,9 +1170,9 @@ containing commas."
;; pipe MIME-part to some arbitrary shell command ;; pipe MIME-part to some arbitrary shell command
(:name "|pipe" :handler gnus-article-pipe-part :receives index) (:name "|pipe" :handler gnus-article-pipe-part :receives index)
;; open with the default handler, if any ;; open with the default handler, if any
(:name "open" :handler mu4e~view-open-file :receives temp) (:name "open" :handler mu4e--view-open-file :receives temp)
;; open with some custom file. ;; open with some custom file.
(:name "wopen-with" :handler (lambda (file)(mu4e~view-open-file file t)) (:name "wopen-with" :handler (lambda (file)(mu4e--view-open-file file t))
:receives temp) :receives temp)
;; ;;
@ -1215,7 +1215,7 @@ Each of the actions is a plist with keys
).") ).")
(defun mu4e~view-mime-part-to-temp-file (handle) (defun mu4e--view-mime-part-to-temp-file (handle)
"Write MIME-part HANDLE to a temporary file and return the file name. "Write MIME-part HANDLE to a temporary file and return the file name.
The filename is deduced from the MIME-part's filename, or The filename is deduced from the MIME-part's filename, or
otherwise random; the result is placed in a temporary directory otherwise random; the result is placed in a temporary directory
@ -1236,7 +1236,7 @@ The directory and file are self-destructed."
fname)) fname))
(defun mu4e~view-open-file (file &optional force-ask) (defun mu4e--view-open-file (file &optional force-ask)
"Open FILE with default handler, if any. "Open FILE with default handler, if any.
Otherwise, or if FORCE-ASK is set, ask user for the program to Otherwise, or if FORCE-ASK is set, ask user for the program to
open with." open with."
@ -1254,7 +1254,7 @@ open with."
If N is not specified, ask for it. For instance, '3 A o' opens If N is not specified, ask for it. For instance, '3 A o' opens
the third MIME-part." the third MIME-part."
(interactive "NNumber of MIME-part: ") (interactive "NNumber of MIME-part: ")
(let* ((parts (mu4e~view-gather-mime-parts)) (let* ((parts (mu4e--view-gather-mime-parts))
(options (options
(mapcar (lambda (action) `(,(plist-get action :name) . ,action)) (mapcar (lambda (action) `(,(plist-get action :name) . ,action))
mu4e-view-mime-part-actions)) mu4e-view-mime-part-actions))
@ -1279,7 +1279,7 @@ the third MIME-part."
(mm-insert-part handle) (mm-insert-part handle)
(buffer-string)))) (buffer-string))))
((eq receives 'temp) ((eq receives 'temp)
(funcall handler (mu4e~view-mime-part-to-temp-file handle))) (funcall handler (mu4e--view-mime-part-to-temp-file handle)))
(t (mu4e-error "Invalid :receive for %S" action)))) (t (mu4e-error "Invalid :receive for %S" action))))
((stringp handler) ((stringp handler)
(cond (cond
@ -1290,7 +1290,7 @@ the third MIME-part."
(shell-command (shell-command
(shell-command (concat handler " " (shell-command (concat handler " "
(shell-quote-argument (shell-quote-argument
(mu4e~view-mime-part-to-temp-file handle)))))) (mu4e--view-mime-part-to-temp-file handle))))))
(t (mu4e-error "Invalid action %S" action)))))))) (t (mu4e-error "Invalid action %S" action))))))))
(defun mu4e-view-toggle-html () (defun mu4e-view-toggle-html ()

View File

@ -148,7 +148,7 @@ invoke
(seq-filter (lambda (bm) (seq-filter (lambda (bm)
(and (stringp (plist-get bm :query)) (and (stringp (plist-get bm :query))
(not (or (plist-get bm :hide) (not (or (plist-get bm :hide)
(plist-get bm :hide-unread))))) (plist-get bm :hide-unread)))))
(append (mu4e-bookmarks) (append (mu4e-bookmarks)
(mu4e--maildirs-with-query))))) (mu4e--maildirs-with-query)))))
;; maybe request the list of contacts, automatically refreshed after ;; maybe request the list of contacts, automatically refreshed after
@ -166,7 +166,7 @@ invoke
(mapc (mapc
(lambda (buf) (lambda (buf)
;; When using the Gnus-based viewer, the view buffer has the ;; When using the Gnus-based viewer, the view buffer has the
;; kill-buffer-hook function mu4e~view-kill-buffer-hook-fn which kills the ;; kill-buffer-hook function mu4e--view-kill-buffer-hook-fn which kills the
;; mm-* buffers created by Gnus' article mode. Those have been returned by ;; mm-* buffers created by Gnus' article mode. Those have been returned by
;; `buffer-list' but might already be deleted in case the view buffer has ;; `buffer-list' but might already be deleted in case the view buffer has
;; been killed first. So we need a `buffer-live-p' check here. ;; been killed first. So we need a `buffer-live-p' check here.
@ -193,10 +193,10 @@ invoke
(defun mu4e--update-status (info) (defun mu4e--update-status (info)
"Update the status message with INFO." "Update the status message with INFO."
(setq mu4e-index-update-status (setq mu4e-index-update-status
`(:tstamp ,(current-time) `(:tstamp ,(current-time)
:checked ,(plist-get info :checked) :checked ,(plist-get info :checked)
:updated ,(plist-get info :updated) :updated ,(plist-get info :updated)
:cleaned-up ,(plist-get info :cleaned-up)))) :cleaned-up ,(plist-get info :cleaned-up))))
(defun mu4e--info-handler (info) (defun mu4e--info-handler (info)
"Handler function for (:INFO ...) sexps received from server." "Handler function for (:INFO ...) sexps received from server."
@ -212,16 +212,16 @@ invoke
(mu4e-index-message (mu4e-index-message
"Indexing... checked %d, updated %d" checked updated) "Indexing... checked %d, updated %d" checked updated)
(progn ;; i.e. 'complete (progn ;; i.e. 'complete
(mu4e--update-status info) (mu4e--update-status info)
(mu4e-index-message (mu4e-index-message
"%s completed; checked %d, updated %d, cleaned-up %d" "%s completed; checked %d, updated %d, cleaned-up %d"
(if mu4e-index-lazy-check "Lazy indexing" "Indexing") (if mu4e-index-lazy-check "Lazy indexing" "Indexing")
checked updated cleaned-up) checked updated cleaned-up)
(run-hooks 'mu4e-index-updated-hook) (run-hooks 'mu4e-index-updated-hook)
;; backward compatibility... ;; backward compatibility...
(unless (zerop (+ updated cleaned-up)) (unless (zerop (+ updated cleaned-up))
mu4e-message-changed-hook) mu4e-message-changed-hook)
(unless (and (not (string= mu4e--contacts-tstamp "0")) (unless (and (not (string= mu4e--contacts-tstamp "0"))
(zerop (plist-get info :updated))) (zerop (plist-get info :updated)))
(mu4e--request-contacts-maybe)) (mu4e--request-contacts-maybe))
(when (and (buffer-live-p mainbuf) (get-buffer-window mainbuf)) (when (and (buffer-live-p mainbuf) (get-buffer-window mainbuf))