mu4e: make mu4e~view-message buffer-local

So we don't leak it outside mu4e. `mu4e-message-at-point` should do the
right thing.
This commit is contained in:
djcb 2019-02-25 21:49:41 +02:00
parent 9cf120b012
commit 31f73b32a7
4 changed files with 8 additions and 42 deletions

View File

@ -139,7 +139,6 @@ sent messages into message threads."
:type 'boolean :type 'boolean
:group 'mu4e-headers) :group 'mu4e-headers)
(defvar mu4e-headers-hide-predicate nil (defvar mu4e-headers-hide-predicate nil
"Predicate function applied to headers before they are shown; "Predicate function applied to headers before they are shown;
if function is nil or evaluates to nil, show the header, if function is nil or evaluates to nil, show the header,
@ -153,7 +152,6 @@ Example that hides all 'trashed' messages:
Note that this is merely a display filter.") Note that this is merely a display filter.")
(defcustom mu4e-headers-visible-flags (defcustom mu4e-headers-visible-flags
'(draft flagged new passed replied seen trashed attach encrypted signed unread) '(draft flagged new passed replied seen trashed attach encrypted signed unread)
"An ordered list of flags to show in the headers buffer. Each "An ordered list of flags to show in the headers buffer. Each
@ -295,7 +293,6 @@ If this is nil show results up to `mu4e-search-results-limit')")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; internal variables/constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; internal variables/constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; docid cookies ;; docid cookies
@ -347,7 +344,7 @@ In the format needed for `mu4e-read-option'.")
"Is DOCID currently being viewed?" "Is DOCID currently being viewed?"
(when (buffer-live-p (mu4e-get-view-buffer)) (when (buffer-live-p (mu4e-get-view-buffer))
(with-current-buffer (mu4e-get-view-buffer) (with-current-buffer (mu4e-get-view-buffer)
(eq docid (plist-get mu4e~view-msg :docid))))) (eq docid (plist-get mu4e~view-message :docid)))))
(defun mu4e~headers-update-handler (msg is-move maybe-view) (defun mu4e~headers-update-handler (msg is-move maybe-view)
"Update handler, will be called when a message has been updated "Update handler, will be called when a message has been updated
@ -530,7 +527,6 @@ while our display may be different)."
str)) str))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst mu4e-headers-from-or-to-prefix '("" . "To ") (defconst mu4e-headers-from-or-to-prefix '("" . "To ")
"Prefix for the :from-or-to field. "Prefix for the :from-or-to field.
It's a cons cell with the car element being the From: prefix, the It's a cons cell with the car element being the From: prefix, the
@ -577,7 +573,6 @@ show the subject of a thread only once, similar to e.g. 'mutt'."
(plist-get tinfo :empty-parent)) (plist-get tinfo :empty-parent))
(truncate-string-to-width subj 600) "")))) (truncate-string-to-width subj 600) ""))))
(defsubst mu4e~headers-mailing-list (list) (defsubst mu4e~headers-mailing-list (list)
"Get some identifier for the mailing list." "Get some identifier for the mailing list."
(if list (if list
@ -747,7 +742,6 @@ after the end of the search results."
(mu4e~headers-defun-mark-for unread) (mu4e~headers-defun-mark-for unread)
(mu4e~headers-defun-mark-for action) (mu4e~headers-defun-mark-for action)
;;; headers-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; headers-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-headers-mode-map nil (defvar mu4e-headers-mode-map nil
"Keymap for *mu4e-headers* buffers.") "Keymap for *mu4e-headers* buffers.")
@ -830,7 +824,6 @@ after the end of the search results."
(define-key map (kbd "<insertchar>") 'mu4e-headers-mark-for-something) (define-key map (kbd "<insertchar>") 'mu4e-headers-mark-for-something)
(define-key map (kbd "<insert>") 'mu4e-headers-mark-for-something) (define-key map (kbd "<insert>") 'mu4e-headers-mark-for-something)
(define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks) (define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks)
(define-key map "U" 'mu4e-mark-unmark-all) (define-key map "U" 'mu4e-mark-unmark-all)
@ -899,13 +892,11 @@ after the end of the search results."
'("Mark for move" . mu4e-headers-mark-for-move)) '("Mark for move" . mu4e-headers-mark-for-move))
(define-key menumap [sepa2] '("--")) (define-key menumap [sepa2] '("--"))
(define-key menumap [resend] '("Resend" . mu4e-compose-resend)) (define-key menumap [resend] '("Resend" . mu4e-compose-resend))
(define-key menumap [forward] '("Forward" . mu4e-compose-forward)) (define-key menumap [forward] '("Forward" . mu4e-compose-forward))
(define-key menumap [reply] '("Reply" . mu4e-compose-reply)) (define-key menumap [reply] '("Reply" . mu4e-compose-reply))
(define-key menumap [compose-new] '("Compose new" . mu4e-compose-new)) (define-key menumap [compose-new] '("Compose new" . mu4e-compose-new))
(define-key menumap [sepa3] '("--")) (define-key menumap [sepa3] '("--"))
(define-key menumap [query-next] (define-key menumap [query-next]
@ -921,7 +912,6 @@ after the end of the search results."
(define-key menumap [refresh] '("Refresh" . mu4e-headers-rerun-search)) (define-key menumap [refresh] '("Refresh" . mu4e-headers-rerun-search))
(define-key menumap [search] '("Search" . mu4e-headers-search)) (define-key menumap [search] '("Search" . mu4e-headers-search))
(define-key menumap [sepa4] '("--")) (define-key menumap [sepa4] '("--"))
(define-key menumap [view] '("View" . mu4e-headers-view-message)) (define-key menumap [view] '("View" . mu4e-headers-view-message))
@ -931,7 +921,6 @@ after the end of the search results."
map))) map)))
(fset 'mu4e-headers-mode-map mu4e-headers-mode-map) (fset 'mu4e-headers-mode-map mu4e-headers-mode-map)
(defun mu4e~header-line-format () (defun mu4e~header-line-format ()
"Get the format for the header line." "Get the format for the header line."
(let ((uparrow (if mu4e-use-fancy-chars "" " ^")) (let ((uparrow (if mu4e-use-fancy-chars "" " ^"))
@ -1038,7 +1027,6 @@ Also, unhighlight any previously highlighted headers."
(hl-line-highlight))) (hl-line-highlight)))
(setq mu4e~highlighted-docid docid))) (setq mu4e~highlighted-docid docid)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e~headers-select-window () (defun mu4e~headers-select-window ()
"When there is a visible window for the headers buffer, make sure "When there is a visible window for the headers buffer, make sure
@ -1085,7 +1073,6 @@ of the beginning of the line."
(setq newpoint (point))))) (setq newpoint (point)))))
newpoint)) ;; return the point, or nil if not found newpoint)) ;; return the point, or nil if not found
(defsubst mu4e~headers-docid-pos (docid) (defsubst mu4e~headers-docid-pos (docid)
"Return the pos of the beginning of the line with the header with "Return the pos of the beginning of the line with the header with
docid DOCID, or nil if it cannot be found." docid DOCID, or nil if it cannot be found."
@ -1133,7 +1120,6 @@ message plist, or nil if not found."
'msg msg))) 'msg msg)))
(goto-char oldpoint)))) (goto-char oldpoint))))
(defsubst mu4e~headers-add-header (str docid point &optional msg) (defsubst mu4e~headers-add-header (str docid point &optional msg)
"Add header STR with DOCID to the buffer at POINT if non-nil, or "Add header STR with DOCID to the buffer at POINT if non-nil, or
at (point-max) otherwise. If MSG is not nil, add it as the at (point-max) otherwise. If MSG is not nil, add it as the
@ -1163,9 +1149,6 @@ docid is not found."
(unless ignore-missing (unless ignore-missing
(mu4e-error "Cannot find message with docid %S" docid))))) (mu4e-error "Cannot find message with docid %S" docid)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom mu4e-query-rewrite-function 'identity (defcustom mu4e-query-rewrite-function 'identity
"Function that takes a search expression string, and returns a "Function that takes a search expression string, and returns a
@ -1187,7 +1170,6 @@ anything about the query, it just does text replacement."
:type 'function :type 'function
:group 'mu4e) :group 'mu4e)
(defun mu4e~headers-search-execute (expr ignore-history) (defun mu4e~headers-search-execute (expr ignore-history)
"Search in the mu database for EXPR, and switch to the output "Search in the mu database for EXPR, and switch to the output
buffer for the results. If IGNORE-HISTORY is true, do *not* update buffer for the results. If IGNORE-HISTORY is true, do *not* update
@ -1379,7 +1361,6 @@ matching messages with that mark."
(match-string 1 path)))) (match-string 1 path))))
(otherwise (mu4e-error "Not supported"))))) (otherwise (mu4e-error "Not supported")))))
(defun mu4e-headers-mark-thread-using-markpair (markpair &optional subthread) (defun mu4e-headers-mark-thread-using-markpair (markpair &optional subthread)
"Mark the thread at point using the given markpair. If SUBTHREAD is "Mark the thread at point using the given markpair. If SUBTHREAD is
non-nil, marking is limited to the message at point and its non-nil, marking is limited to the message at point and its
@ -1491,7 +1472,6 @@ or `past'."
"Whether to automatically view (open) the target message (as "Whether to automatically view (open) the target message (as
per `mu4e~headers-msgid-target').") per `mu4e~headers-msgid-target').")
(defun mu4e-headers-search (&optional expr prompt edit (defun mu4e-headers-search (&optional expr prompt edit
ignore-history msgid show) ignore-history msgid show)
"Search in the mu database for EXPR, and switch to the output "Search in the mu database for EXPR, and switch to the output
@ -1538,7 +1518,6 @@ the search."
(interactive) (interactive)
(mu4e-headers-search-bookmark nil t)) (mu4e-headers-search-bookmark nil t))
(defun mu4e-headers-search-narrow (filter ) (defun mu4e-headers-search-narrow (filter )
"Narrow the last search by appending search expression FILTER to "Narrow the last search by appending search expression FILTER to
the last search expression. Note that you can go back to previous the last search expression. Note that you can go back to previous
@ -1553,7 +1532,6 @@ query (effectively, 'widen' it), with `mu4e-headers-query-prev'."
(mu4e-headers-search (mu4e-headers-search
(format "(%s) AND (%s)" mu4e~headers-last-query filter))) (format "(%s) AND (%s)" mu4e~headers-last-query filter)))
(defun mu4e-headers-change-sorting (&optional field dir) (defun mu4e-headers-change-sorting (&optional field dir)
"Change the sorting/threading parameters. "Change the sorting/threading parameters.
FIELD is the field to sort by; DIR is a symbol: either 'ascending, FIELD is the field to sort by; DIR is a symbol: either 'ascending,

View File

@ -30,7 +30,6 @@
(require 'mu4e-utils) (require 'mu4e-utils)
(require 'flow-fill) (require 'flow-fill)
(defcustom mu4e-html2text-command (defcustom mu4e-html2text-command
(if (fboundp 'shr-insert-document) (if (fboundp 'shr-insert-document)
'mu4e-shr2text 'mu4e-shr2text
@ -154,7 +153,7 @@ Thus, function will return nil for empty lists, non-existing body-txt or body-ht
Either the headers buffer or the view buffer, or nil if there is Either the headers buffer or the view buffer, or nil if there is
no such message. If optional NOERROR is non-nil, do not raise an 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."
(let ((msg (or (get-text-property (point) 'msg) mu4e~view-msg))) (let ((msg (or (get-text-property (point) 'msg) mu4e~view-message)))
(if msg (if msg
msg msg
(unless noerror (mu4e-warn "No message at point"))))) (unless noerror (mu4e-warn "No message at point")))))
@ -232,7 +231,6 @@ unless PREFER-HTML is non-nil."
(setq body (funcall func msg body))) (setq body (funcall func msg body)))
body)) body))
(defun mu4e-message-outlook-cleanup (msg body) (defun mu4e-message-outlook-cleanup (msg body)
"Clean-up MSG's BODY. "Clean-up MSG's BODY.
Esp. MS-Outlook-originating message may not advertise the correct Esp. MS-Outlook-originating message may not advertise the correct
@ -250,7 +248,6 @@ replace with."
(t "")))) (t ""))))
(buffer-string))) (buffer-string)))
(defun mu4e-message-contact-field-matches (msg cfield rx) (defun mu4e-message-contact-field-matches (msg cfield rx)
"Does MSG's contact-field CFIELD matche rx? "Does MSG's contact-field CFIELD matche rx?
Check if any of the of the CFIELD in MSG matches RX. I.e. Check if any of the of the CFIELD in MSG matches RX. I.e.

View File

@ -230,7 +230,6 @@ shortcut-key for the query.
An older form of bookmark, a 3-item list with (QUERY DESCRIPTION An older form of bookmark, a 3-item list with (QUERY DESCRIPTION
KEY) is still recognized as well, for backward-compatibility.") KEY) is still recognized as well, for backward-compatibility.")
(defcustom mu4e-split-view 'horizontal (defcustom mu4e-split-view 'horizontal
"How to show messages / headers. "How to show messages / headers.
A symbol which is either: A symbol which is either:
@ -305,7 +304,6 @@ Also see `mu4e-compose-context-policy'."
(const :tag "Don't change the context when none match" nil)) (const :tag "Don't change the context when none match" nil))
:group 'mu4e) :group 'mu4e)
;; crypto ;; crypto
(defgroup mu4e-crypto nil (defgroup mu4e-crypto nil
"Crypto-related settings." "Crypto-related settings."
@ -358,7 +356,6 @@ Set to nil to not have any time-based restriction."
:type 'string :type 'string
:group 'mu4e-compose) :group 'mu4e-compose)
;;; names and mail-addresses can be mapped onto their canonical ;;; names and mail-addresses can be mapped onto their canonical
;;; counterpart. use the customizeable function ;;; counterpart. use the customizeable function
;;; mu4e-canonical-contact-function to do that. below the identity ;;; mu4e-canonical-contact-function to do that. below the identity
@ -389,7 +386,6 @@ are needed for sorting the contacts."
:type 'function :type 'function
:group 'mu4e-compose) :group 'mu4e-compose)
(defcustom mu4e-compose-complete-ignore-address-regexp "no-?reply" (defcustom mu4e-compose-complete-ignore-address-regexp "no-?reply"
"Ignore any e-mail addresses for completion if they match this regexp." "Ignore any e-mail addresses for completion if they match this regexp."
:type 'string :type 'string
@ -490,7 +486,6 @@ nil otherwise."
(function :tag "Function return folder name")) (function :tag "Function return folder name"))
:group 'mu4e-folders) :group 'mu4e-folders)
(defcustom mu4e-maildir-shortcuts nil (defcustom mu4e-maildir-shortcuts nil
"A list of maildir shortcuts. "A list of maildir shortcuts.
This makes it possible to quickly go to a particular This makes it possible to quickly go to a particular
@ -842,7 +837,6 @@ in `mu4e-view-fields.'
Note, `:sortable' is not supported for custom header fields.") Note, `:sortable' is not supported for custom header fields.")
(defvar mu4e-header-info-custom (defvar mu4e-header-info-custom
'( (:recipnum . '( (:recipnum .
( :name "Number of recipients" ( :name "Number of recipients"
@ -860,10 +854,8 @@ should point to a function that takes a message p-list as
argument, and returns a string. See the default value of argument, and returns a string. See the default value of
`mu4e-header-info-custom for an example.") `mu4e-header-info-custom for an example.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; run-time vars used in multiple places ;; run-time vars used in multiple places
@ -878,9 +870,6 @@ argument, and returns a string. See the default value of
(defconst mu4e~view-embedded-buffer-name " *mu4e-embedded-view*" (defconst mu4e~view-embedded-buffer-name " *mu4e-embedded-view*"
"Name for the embedded message view buffer.") "Name for the embedded message view buffer.")
(defvar mu4e~view-msg nil
"The message being viewed in view mode.")
(defvar mu4e~contacts nil (defvar mu4e~contacts nil
"Hash that maps contacts (ie. 'name <e-mail>') to an integer for sorting. "Hash that maps contacts (ie. 'name <e-mail>') to an integer for sorting.
We need to keep this information around to quickly re-sort We need to keep this information around to quickly re-sort
@ -971,7 +960,6 @@ sexp received from the server process.")
"A function called for each (:temp <file> <cookie>) sexp.") "A function called for each (:temp <file> <cookie>) sexp.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'mu4e-vars) (provide 'mu4e-vars)
;;; mu4e-vars.el ends here ;;; mu4e-vars.el ends here

View File

@ -147,6 +147,9 @@ The first letter of NAME is used as a shortcut character."
:group 'mu4e-view :group 'mu4e-view
:type '(alist :key-type string :value-type function)) :type '(alist :key-type string :value-type function))
(defvar-local mu4e~view-message nil
"The message being viewed in view mode.")
(defvar mu4e-view-fill-headers t (defvar mu4e-view-fill-headers t
"If non-nil, automatically fill the headers when viewing them.") "If non-nil, automatically fill the headers when viewing them.")
@ -342,7 +345,7 @@ article-mode."
(mu4e~view-show-images-maybe msg) (mu4e~view-show-images-maybe msg)
(mu4e-view-mode) (mu4e-view-mode)
(when embedded (local-set-key "q" 'kill-buffer-and-window)) (when embedded (local-set-key "q" 'kill-buffer-and-window))
(when (not embedded) (setq mu4e~view-msg msg)))) (when (not embedded) (setq mu4e~view-message msg))))
(switch-to-buffer buf)))) (switch-to-buffer buf))))
(defun mu4e~view-gnus (msg) (defun mu4e~view-gnus (msg)
@ -374,7 +377,7 @@ article-mode."
(run-hooks 'gnus-article-decode-hook) (run-hooks 'gnus-article-decode-hook)
(gnus-article-prepare-display) (gnus-article-prepare-display)
(mu4e-view-mode) (mu4e-view-mode)
(setq mu4e~view-msg msg) (setq mu4e~view-message msg)
(setq gnus-article-decoded-p gnus-article-decode-hook) (setq gnus-article-decoded-p gnus-article-decode-hook)
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(read-only-mode)))) (read-only-mode))))
@ -1075,7 +1078,7 @@ or `html' or nil.")
(defun mu4e-view-refresh () (defun mu4e-view-refresh ()
"Redisplay the current message." "Redisplay the current message."
(interactive) (interactive)
(mu4e-view mu4e~view-msg) (mu4e-view mu4e~view-message)
(setq mu4e~view-cited-hidden nil)) (setq mu4e~view-cited-hidden nil))
(defun mu4e-view-action (&optional msg) (defun mu4e-view-action (&optional msg)