From 31f73b32a7263dcd5605aa1600d89e09b562975b Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 25 Feb 2019 21:49:41 +0200 Subject: [PATCH] mu4e: make mu4e~view-message buffer-local So we don't leak it outside mu4e. `mu4e-message-at-point` should do the right thing. --- mu4e/mu4e-headers.el | 24 +----------------------- mu4e/mu4e-message.el | 5 +---- mu4e/mu4e-vars.el | 12 ------------ mu4e/mu4e-view.el | 9 ++++++--- 4 files changed, 8 insertions(+), 42 deletions(-) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index a2a0f366..0bf627fa 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -139,7 +139,6 @@ sent messages into message threads." :type 'boolean :group 'mu4e-headers) - (defvar mu4e-headers-hide-predicate nil "Predicate function applied to headers before they are shown; 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.") - (defcustom mu4e-headers-visible-flags '(draft flagged new passed replied seen trashed attach encrypted signed unread) "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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; docid cookies @@ -347,7 +344,7 @@ In the format needed for `mu4e-read-option'.") "Is DOCID currently being viewed?" (when (buffer-live-p (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) "Update handler, will be called when a message has been updated @@ -530,7 +527,6 @@ while our display may be different)." str)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (defconst mu4e-headers-from-or-to-prefix '("" . "To ") "Prefix for the :from-or-to field. 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)) (truncate-string-to-width subj 600) "")))) - (defsubst mu4e~headers-mailing-list (list) "Get some identifier for the mailing 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 action) - ;;; headers-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar mu4e-headers-mode-map nil "Keymap for *mu4e-headers* buffers.") @@ -830,7 +824,6 @@ after the end of the search results." (define-key map (kbd "") 'mu4e-headers-mark-for-something) (define-key map (kbd "") 'mu4e-headers-mark-for-something) - (define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks) (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)) (define-key menumap [sepa2] '("--")) - (define-key menumap [resend] '("Resend" . mu4e-compose-resend)) (define-key menumap [forward] '("Forward" . mu4e-compose-forward)) (define-key menumap [reply] '("Reply" . mu4e-compose-reply)) (define-key menumap [compose-new] '("Compose new" . mu4e-compose-new)) - (define-key menumap [sepa3] '("--")) (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 [search] '("Search" . mu4e-headers-search)) - (define-key menumap [sepa4] '("--")) (define-key menumap [view] '("View" . mu4e-headers-view-message)) @@ -931,7 +921,6 @@ after the end of the search results." map))) (fset 'mu4e-headers-mode-map mu4e-headers-mode-map) - (defun mu4e~header-line-format () "Get the format for the header line." (let ((uparrow (if mu4e-use-fancy-chars " ▲" " ^")) @@ -1038,7 +1027,6 @@ Also, unhighlight any previously highlighted headers." (hl-line-highlight))) (setq mu4e~highlighted-docid docid))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun mu4e~headers-select-window () "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))))) newpoint)) ;; return the point, or nil if not found - (defsubst mu4e~headers-docid-pos (docid) "Return the pos of the beginning of the line with the header with docid DOCID, or nil if it cannot be found." @@ -1133,7 +1120,6 @@ message plist, or nil if not found." 'msg msg))) (goto-char oldpoint)))) - (defsubst mu4e~headers-add-header (str docid point &optional msg) "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 @@ -1163,9 +1149,6 @@ docid is not found." (unless ignore-missing (mu4e-error "Cannot find message with docid %S" docid))))) - - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defcustom mu4e-query-rewrite-function 'identity "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 :group 'mu4e) - (defun mu4e~headers-search-execute (expr ignore-history) "Search in the mu database for EXPR, and switch to the output 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)))) (otherwise (mu4e-error "Not supported"))))) - (defun mu4e-headers-mark-thread-using-markpair (markpair &optional subthread) "Mark the thread at point using the given markpair. If SUBTHREAD is 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 per `mu4e~headers-msgid-target').") - (defun mu4e-headers-search (&optional expr prompt edit ignore-history msgid show) "Search in the mu database for EXPR, and switch to the output @@ -1538,7 +1518,6 @@ the search." (interactive) (mu4e-headers-search-bookmark nil t)) - (defun mu4e-headers-search-narrow (filter ) "Narrow the last search by appending search expression FILTER to 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 (format "(%s) AND (%s)" mu4e~headers-last-query filter))) - (defun mu4e-headers-change-sorting (&optional field dir) "Change the sorting/threading parameters. FIELD is the field to sort by; DIR is a symbol: either 'ascending, diff --git a/mu4e/mu4e-message.el b/mu4e/mu4e-message.el index 8cf06a78..e2421fb4 100644 --- a/mu4e/mu4e-message.el +++ b/mu4e/mu4e-message.el @@ -30,7 +30,6 @@ (require 'mu4e-utils) (require 'flow-fill) - (defcustom mu4e-html2text-command (if (fboundp 'shr-insert-document) '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 no such message. If optional NOERROR is non-nil, do not raise an 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 msg (unless noerror (mu4e-warn "No message at point"))))) @@ -232,7 +231,6 @@ unless PREFER-HTML is non-nil." (setq body (funcall func msg body))) body)) - (defun mu4e-message-outlook-cleanup (msg body) "Clean-up MSG's BODY. Esp. MS-Outlook-originating message may not advertise the correct @@ -250,7 +248,6 @@ replace with." (t "")))) (buffer-string))) - (defun mu4e-message-contact-field-matches (msg cfield rx) "Does MSG's contact-field CFIELD matche rx? Check if any of the of the CFIELD in MSG matches RX. I.e. diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 1b033a21..c0886632 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -230,7 +230,6 @@ shortcut-key for the query. An older form of bookmark, a 3-item list with (QUERY DESCRIPTION KEY) is still recognized as well, for backward-compatibility.") - (defcustom mu4e-split-view 'horizontal "How to show messages / headers. 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)) :group 'mu4e) - ;; crypto (defgroup mu4e-crypto nil "Crypto-related settings." @@ -358,7 +356,6 @@ Set to nil to not have any time-based restriction." :type 'string :group 'mu4e-compose) - ;;; names and mail-addresses can be mapped onto their canonical ;;; counterpart. use the customizeable function ;;; mu4e-canonical-contact-function to do that. below the identity @@ -389,7 +386,6 @@ are needed for sorting the contacts." :type 'function :group 'mu4e-compose) - (defcustom mu4e-compose-complete-ignore-address-regexp "no-?reply" "Ignore any e-mail addresses for completion if they match this regexp." :type 'string @@ -490,7 +486,6 @@ nil otherwise." (function :tag "Function return folder name")) :group 'mu4e-folders) - (defcustom mu4e-maildir-shortcuts nil "A list of maildir shortcuts. 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.") - (defvar mu4e-header-info-custom '( (:recipnum . ( :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 `mu4e-header-info-custom for an example.") - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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*" "Name for the embedded message view buffer.") -(defvar mu4e~view-msg nil - "The message being viewed in view mode.") - (defvar mu4e~contacts nil "Hash that maps contacts (ie. 'name ') to an integer for sorting. 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 ) sexp.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (provide 'mu4e-vars) ;;; mu4e-vars.el ends here diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 5375545c..4e8378d7 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -147,6 +147,9 @@ The first letter of NAME is used as a shortcut character." :group 'mu4e-view :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 "If non-nil, automatically fill the headers when viewing them.") @@ -342,7 +345,7 @@ article-mode." (mu4e~view-show-images-maybe msg) (mu4e-view-mode) (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)))) (defun mu4e~view-gnus (msg) @@ -374,7 +377,7 @@ article-mode." (run-hooks 'gnus-article-decode-hook) (gnus-article-prepare-display) (mu4e-view-mode) - (setq mu4e~view-msg msg) + (setq mu4e~view-message msg) (setq gnus-article-decoded-p gnus-article-decode-hook) (set-buffer-modified-p nil) (read-only-mode)))) @@ -1075,7 +1078,7 @@ or `html' or nil.") (defun mu4e-view-refresh () "Redisplay the current message." (interactive) - (mu4e-view mu4e~view-msg) + (mu4e-view mu4e~view-message) (setq mu4e~view-cited-hidden nil)) (defun mu4e-view-action (&optional msg)