mu4e-headers: whitespace/newline cleanups

This commit is contained in:
Dirk-Jan C. Binnema 2022-12-11 12:42:48 +02:00
parent 713ae1e98b
commit 6278d1f18a
1 changed files with 126 additions and 100 deletions

View File

@ -32,7 +32,8 @@
(require 'fringe) (require 'fringe)
(require 'hl-line) (require 'hl-line)
(require 'mailcap) (require 'mailcap)
(require 'mule-util) ;; seems _some_ people need this for truncate-string-ellipsis (require 'mule-util) ;; seems _some_ people need this for
;; truncate-string-ellipsis
(require 'mu4e-update) (require 'mu4e-update)
@ -142,7 +143,8 @@ Example that hides all trashed messages:
(member \='trashed (mu4e-message-field msg :flags)))).") (member \='trashed (mu4e-message-field msg :flags)))).")
(defcustom mu4e-headers-visible-flags (defcustom mu4e-headers-visible-flags
'(draft flagged new passed replied trashed attach encrypted signed list personal) '(draft flagged new passed replied trashed attach encrypted signed
list personal)
"An ordered list of flags to show in the headers buffer. "An ordered list of flags to show in the headers buffer.
Each element is a symbol in the list. Each element is a symbol in the list.
@ -159,9 +161,9 @@ mostly covered by `new', and the display gets cluttered otherwise."
(const :tag "Attach" attach) (const :tag "Attach" attach)
(const :tag "Encrypted" encrypted) (const :tag "Encrypted" encrypted)
(const :tag "Signed" signed) (const :tag "Signed" signed)
(const :tag "List" list) (const :tag "List" list)
(const :tag "Personal" personal) (const :tag "Personal" personal)
(const :tag "Calendar" calendar)) (const :tag "Calendar" calendar))
:group 'mu4e-headers) :group 'mu4e-headers)
(defcustom mu4e-headers-found-hook nil (defcustom mu4e-headers-found-hook nil
@ -346,7 +348,7 @@ Optionally, show TEXT."
(with-current-buffer (mu4e-get-headers-buffer) (with-current-buffer (mu4e-get-headers-buffer)
(mu4e--mark-clear) (mu4e--mark-clear)
(erase-buffer) (erase-buffer)
(when text (when text
(goto-char (point-min)) (goto-char (point-min))
(insert (propertize text 'face 'mu4e-system-face 'intangible t))))))) (insert (propertize text 'face 'mu4e-system-face 'intangible t)))))))
@ -359,7 +361,7 @@ into a string."
(mapconcat (mapconcat
(lambda (contact) (lambda (contact)
(let ((name (mu4e-contact-name contact)) (let ((name (mu4e-contact-name contact))
(email (mu4e-contact-email contact))) (email (mu4e-contact-email contact)))
(or name email "?"))) contacts ", ")) (or name email "?"))) contacts ", "))
(defun mu4e~headers-thread-prefix-map (type) (defun mu4e~headers-thread-prefix-map (type)
@ -374,7 +376,8 @@ into a string."
(connection (funcall get-prefix mu4e-headers-thread-connection-prefix)) (connection (funcall get-prefix mu4e-headers-thread-connection-prefix))
(blank (funcall get-prefix mu4e-headers-thread-blank-prefix)) (blank (funcall get-prefix mu4e-headers-thread-blank-prefix))
(orphan (funcall get-prefix mu4e-headers-thread-orphan-prefix)) (orphan (funcall get-prefix mu4e-headers-thread-orphan-prefix))
(single-orphan (funcall get-prefix mu4e-headers-thread-single-orphan-prefix)) (single-orphan (funcall get-prefix
mu4e-headers-thread-single-orphan-prefix))
(duplicate (funcall get-prefix mu4e-headers-thread-duplicate-prefix)) (duplicate (funcall get-prefix mu4e-headers-thread-duplicate-prefix))
(t "?")))) (t "?"))))
@ -481,7 +484,8 @@ with DOCID which must be present in the headers buffer."
(if single-orphan 'single-orphan (if single-orphan 'single-orphan
(if (and orphan (if (and orphan
(or first-child (or first-child
(not (eq mu4e-headers-thread-mark-as-orphan 'first)))) (not (eq mu4e-headers-thread-mark-as-orphan
'first))))
'orphan 'orphan
(if last-child 'last-child (if last-child 'last-child
(if first-child 'first-child (if first-child 'first-child
@ -507,14 +511,14 @@ function is for display. (This difference is significant, since
internally, the Maildir spec determines what the flags look like, internally, the Maildir spec determines what the flags look like,
while our display may be different)." while our display may be different)."
(or (mapconcat (or (mapconcat
(lambda (flag) (lambda (flag)
(when (member flag mu4e-headers-visible-flags) (when (member flag mu4e-headers-visible-flags)
(if-let* ((mark (intern-soft (if-let* ((mark (intern-soft
(format "mu4e-headers-%s-mark" (symbol-name flag)))) (format "mu4e-headers-%s-mark" (symbol-name flag))))
(cell (symbol-value mark))) (cell (symbol-value mark)))
(if mu4e-use-fancy-chars (cdr cell) (car cell)) (if mu4e-use-fancy-chars (cdr cell) (car cell))
""))) "")))
flags "") flags "")
"")) ""))
;;; Special headers ;;; Special headers
@ -526,8 +530,8 @@ addresses, (as per `mu4e-personal-address-p'), show the To
address. Otherwise, show the From address, prefixed with the address. Otherwise, show the From address, prefixed with the
appropriate `mu4e-headers-from-or-to-prefix'." appropriate `mu4e-headers-from-or-to-prefix'."
(let* ((from1 (car-safe (mu4e-message-field msg :from))) (let* ((from1 (car-safe (mu4e-message-field msg :from)))
(from1-addr (and from1 (mu4e-contact-email from1))) (from1-addr (and from1 (mu4e-contact-email from1)))
(is-user (and from1-addr (mu4e-personal-address-p from1-addr)))) (is-user (and from1-addr (mu4e-personal-address-p from1-addr))))
(if is-user (if is-user
(concat (cdr mu4e-headers-from-or-to-prefix) (concat (cdr mu4e-headers-from-or-to-prefix)
(mu4e~headers-contact-str (mu4e-message-field msg :to))) (mu4e~headers-contact-str (mu4e-message-field msg :to)))
@ -591,8 +595,8 @@ found."
(truncate-string-to-width val 600))) (truncate-string-to-width val 600)))
(:thread-subject ;; if not searching threads, fall back to :subject (:thread-subject ;; if not searching threads, fall back to :subject
(if mu4e-search-threads (if mu4e-search-threads
(mu4e~headers-thread-subject msg) (mu4e~headers-thread-subject msg)
(mu4e~headers-field-value msg :subject))) (mu4e~headers-field-value msg :subject)))
((:maildir :path :message-id) val) ((:maildir :path :message-id) val)
((:to :from :cc :bcc) (mu4e~headers-contact-str val)) ((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show ;; if we (ie. `user-mail-address' is the 'From', show
@ -650,23 +654,26 @@ space propertized with a `display' text property which expands to
(let* ((field (car f-w)) (let* ((field (car f-w))
(width (cdr f-w)) (width (cdr f-w))
(val (mu4e~headers-field-value msg field)) (val (mu4e~headers-field-value msg field))
(val (and val (if width (mu4e~headers-truncate-field field val width) val)))) (val (and val
(if width
(mu4e~headers-truncate-field field val width)
val))))
val)) val))
(defsubst mu4e~headers-apply-flags (msg fieldval) (defsubst mu4e~headers-apply-flags (msg fieldval)
"Adjust FIELDVAL's face property based on flags in MSG." "Adjust FIELDVAL's face property based on flags in MSG."
(let* ((flags (plist-get msg :flags)) (let* ((flags (plist-get msg :flags))
(meta (plist-get msg :meta)) (meta (plist-get msg :meta))
(face (cond (face (cond
((memq 'trashed flags) 'mu4e-trashed-face) ((memq 'trashed flags) 'mu4e-trashed-face)
((memq 'draft flags) 'mu4e-draft-face) ((memq 'draft flags) 'mu4e-draft-face)
((or (memq 'unread flags) (memq 'new flags)) ((or (memq 'unread flags) (memq 'new flags))
'mu4e-unread-face) 'mu4e-unread-face)
((memq 'flagged flags) 'mu4e-flagged-face) ((memq 'flagged flags) 'mu4e-flagged-face)
((plist-get meta :related) 'mu4e-related-face) ((plist-get meta :related) 'mu4e-related-face)
((memq 'replied flags) 'mu4e-replied-face) ((memq 'replied flags) 'mu4e-replied-face)
((memq 'passed flags) 'mu4e-forwarded-face) ((memq 'passed flags) 'mu4e-forwarded-face)
(t 'mu4e-header-face)))) (t 'mu4e-header-face))))
(add-face-text-property 0 (length fieldval) face t fieldval) (add-face-text-property 0 (length fieldval) face t fieldval)
fieldval)) fieldval))
@ -684,7 +691,7 @@ displaying in the header view."
(defsubst mu4e~headers-insert-header (msg pos) (defsubst mu4e~headers-insert-header (msg pos)
"Insert a header for MSG at point POS." "Insert a header for MSG at point POS."
(when-let ((line (mu4e~message-header-line msg)) (when-let ((line (mu4e~message-header-line msg))
(docid (plist-get msg :docid))) (docid (plist-get msg :docid)))
(goto-char pos) (goto-char pos)
(insert (insert
(propertize (propertize
@ -716,7 +723,8 @@ 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 (lambda (_) (eq docid (plist-get mu4e~view-message :docid))))) (mu4e-get-view-buffers
(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)
@ -725,11 +733,11 @@ Do this at the end of the headers-buffer."
(when (buffer-live-p (mu4e-get-headers-buffer)) (when (buffer-live-p (mu4e-get-headers-buffer))
(with-current-buffer (mu4e-get-headers-buffer) (with-current-buffer (mu4e-get-headers-buffer)
(save-excursion (save-excursion
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(seq-do (seq-do
(lambda (msg) (lambda (msg)
(mu4e~headers-insert-header msg (point-max))) (mu4e~headers-insert-header msg (point-max)))
msglst)))))) msglst))))))
(defun mu4e~headers-update-handler (msg is-move maybe-view) (defun mu4e~headers-update-handler (msg is-move maybe-view)
@ -741,7 +749,7 @@ headers."
(let* ((docid (mu4e-message-field msg :docid)) (let* ((docid (mu4e-message-field msg :docid))
(initial-message-at-point (mu4e~headers-docid-at-point)) (initial-message-at-point (mu4e~headers-docid-at-point))
(initial-column (current-column)) (initial-column (current-column))
(inhibit-read-only t) (inhibit-read-only t)
(point (mu4e~headers-docid-pos docid)) (point (mu4e~headers-docid-pos docid))
(markinfo (gethash docid mu4e--mark-map))) (markinfo (gethash docid mu4e--mark-map)))
(when point ;; is the message present in this list? (when point ;; is the message present in this list?
@ -772,8 +780,8 @@ headers."
;; longer matches the query, but this seem a good heuristic. if it ;; longer matches the query, but this seem a good heuristic. if it
;; was only a flag-change, show the message with its updated flags. ;; was only a flag-change, show the message with its updated flags.
(unless is-move (unless is-move
(save-excursion (save-excursion
(mu4e~headers-insert-header msg point))) (mu4e~headers-insert-header msg point)))
;; restore the mark, if any. See #2076. ;; restore the mark, if any. See #2076.
(when (and markinfo (mu4e~headers-goto-docid docid)) (when (and markinfo (mu4e~headers-goto-docid docid))
@ -848,16 +856,16 @@ true, do *not* update the query history stack."
(defun mu4e~headers-benchmark-message (count) (defun mu4e~headers-benchmark-message (count)
"Get some report message for messaging search and rendering speed." "Get some report message for messaging search and rendering speed."
(if (and mu4e-headers-report-render-time (if (and mu4e-headers-report-render-time
mu4e~headers-search-start mu4e~headers-search-start
mu4e~headers-render-start mu4e~headers-render-start
(> count 0)) (> count 0))
(let ((render-time-ms (* 1000(- (float-time) mu4e~headers-render-start))) (let ((render-time-ms (* 1000(- (float-time) mu4e~headers-render-start)))
(search-time-ms (* 1000(- (float-time) mu4e~headers-search-start)))) (search-time-ms (* 1000(- (float-time) mu4e~headers-search-start))))
(format (concat (format (concat
"; search: %0.1f ms (%0.2f ms/msg)" "; search: %0.1f ms (%0.2f ms/msg)"
"; render: %0.1f ms (%0.2f ms/msg)") "; render: %0.1f ms (%0.2f ms/msg)")
search-time-ms (/ search-time-ms count) search-time-ms (/ search-time-ms count)
render-time-ms (/ render-time-ms count))) render-time-ms (/ render-time-ms count)))
"")) ""))
(defun mu4e~headers-found-handler (count) (defun mu4e~headers-found-handler (count)
@ -871,7 +879,7 @@ after the end of the search results."
(str (if (zerop count) mu4e~no-matches mu4e~end-of-results)) (str (if (zerop count) mu4e~no-matches mu4e~end-of-results))
(msg (format "Found %d matching message%s%s" (msg (format "Found %d matching message%s%s"
count (if (= 1 count) "" "s") count (if (= 1 count) "" "s")
(mu4e~headers-benchmark-message count)))) (mu4e~headers-benchmark-message count))))
(insert (propertize str 'face 'mu4e-system-face 'intangible t)) (insert (propertize str 'face 'mu4e-system-face 'intangible t))
(unless (zerop count) (unless (zerop count)
@ -882,7 +890,8 @@ after the end of the search results."
(when mu4e--search-msgid-target (when mu4e--search-msgid-target
(if (eq (current-buffer) (window-buffer)) (if (eq (current-buffer) (window-buffer))
(mu4e-headers-goto-message-id mu4e--search-msgid-target) (mu4e-headers-goto-message-id mu4e--search-msgid-target)
(let* ((pos (mu4e-headers-goto-message-id mu4e--search-msgid-target))) (let* ((pos (mu4e-headers-goto-message-id
mu4e--search-msgid-target)))
(when pos (when pos
(set-window-point (get-buffer-window nil t) pos))))) (set-window-point (get-buffer-window nil t) pos)))))
(when (and mu4e--search-view-target (mu4e-message-at-point 'noerror)) (when (and mu4e--search-view-target (mu4e-message-at-point 'noerror))
@ -931,10 +940,10 @@ after the end of the search results."
(define-key map "j" 'mu4e~headers-jump-to-maildir) (define-key map "j" 'mu4e~headers-jump-to-maildir)
(define-key map "O" 'mu4e-headers-change-sorting) (define-key map "O" 'mu4e-headers-change-sorting)
(define-key map "M" 'mu4e-headers-toggle-setting) (define-key map "M" 'mu4e-headers-toggle-setting)
;; these are impossible to remember; use mu4e-headers-toggle-setting ;; these are impossible to remember; use mu4e-headers-toggle-setting
;; instead :) ;; instead :)
(define-key map "P" 'mu4e-headers-toggle-threading) (define-key map "P" 'mu4e-headers-toggle-threading)
(define-key map "Q" 'mu4e-headers-toggle-full-search) (define-key map "Q" 'mu4e-headers-toggle-full-search)
(define-key map "W" 'mu4e-headers-toggle-include-related) (define-key map "W" 'mu4e-headers-toggle-include-related)
@ -947,7 +956,7 @@ after the end of the search results."
(define-key map "t" 'mu4e-headers-mark-subthread) (define-key map "t" 'mu4e-headers-mark-subthread)
(define-key map "T" 'mu4e-headers-mark-thread) (define-key map "T" 'mu4e-headers-mark-thread)
(define-key map "," #'mu4e-sexp-at-point) (define-key map "," #'mu4e-sexp-at-point)
;; navigation between messages ;; navigation between messages
(define-key map "p" 'mu4e-headers-prev) (define-key map "p" 'mu4e-headers-prev)
@ -962,7 +971,8 @@ after the end of the search results."
(define-key map (kbd "C-+") 'mu4e-headers-split-view-grow) (define-key map (kbd "C-+") 'mu4e-headers-split-view-grow)
(define-key map (kbd "C--") 'mu4e-headers-split-view-shrink) (define-key map (kbd "C--") 'mu4e-headers-split-view-shrink)
(define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-grow) (define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-grow)
(define-key map (kbd "<C-kp-subtract>") 'mu4e-headers-split-view-shrink) (define-key map (kbd "<C-kp-subtract>")
'mu4e-headers-split-view-shrink)
;; switching to view mode (if it's visible) ;; switching to view mode (if it's visible)
(define-key map "y" 'mu4e-select-other-view) (define-key map "y" 'mu4e-select-other-view)
@ -986,10 +996,14 @@ after the end of the search results."
(define-key map (kbd "=") 'mu4e-headers-mark-for-untrash) (define-key map (kbd "=") 'mu4e-headers-mark-for-untrash)
(define-key map (kbd "&") 'mu4e-headers-mark-custom) (define-key map (kbd "&") 'mu4e-headers-mark-custom)
(define-key map (kbd "*") 'mu4e-headers-mark-for-something) (define-key map (kbd "*")
(define-key map (kbd "<kp-multiply>") 'mu4e-headers-mark-for-something) 'mu4e-headers-mark-for-something)
(define-key map (kbd "<insertchar>") 'mu4e-headers-mark-for-something) (define-key map (kbd "<kp-multiply>")
(define-key map (kbd "<insert>") 'mu4e-headers-mark-for-something) '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 "#") 'mu4e-mark-resolve-deferred-marks) (define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks)
@ -1104,7 +1118,7 @@ after the end of the search results."
(field (car item)) (width (cdr item)) (field (car item)) (width (cdr item))
(info (cdr (assoc field (info (cdr (assoc field
(append mu4e-header-info mu4e-header-info-custom)))) (append mu4e-header-info mu4e-header-info-custom))))
(sortable (plist-get info :sortable)) (sortable (plist-get info :sortable))
;; if sortable, it is either t (when field is sortable itself) ;; if sortable, it is either t (when field is sortable itself)
;; or a symbol (if another field is used for sorting) ;; or a symbol (if another field is used for sorting)
(this-field (when sortable (if (booleanp sortable) field sortable))) (this-field (when sortable (if (booleanp sortable) field sortable)))
@ -1143,8 +1157,8 @@ after the end of the search results."
some changes, `mu4e-headers-auto-update' is non-nil and there is some changes, `mu4e-headers-auto-update' is non-nil and there is
no user-interaction ongoing." no user-interaction ongoing."
(when (and mu4e-headers-auto-update ;; must be set (when (and mu4e-headers-auto-update ;; must be set
mu4e-index-update-status mu4e-index-update-status
(not (zerop (plist-get mu4e-index-update-status :updated))) (not (zerop (plist-get mu4e-index-update-status :updated)))
;; NOTE: `mu4e-mark-marks-num' can return nil. Is that intended? ;; NOTE: `mu4e-mark-marks-num' can return nil. Is that intended?
(zerop (or (mu4e-mark-marks-num) 0)) ;; non active marks (zerop (or (mu4e-mark-marks-num) 0)) ;; non active marks
(not (active-minibuffer-window))) ;; no user input only (not (active-minibuffer-window))) ;; no user input only
@ -1287,21 +1301,23 @@ message plist, or nil if not found."
(defvar mu4e~headers-mode-line-label "") (defvar mu4e~headers-mode-line-label "")
(defun mu4e~headers-update-mode-line () (defun mu4e~headers-update-mode-line ()
"Update mode-line settings." "Update mode-line settings."
(let* ((flagstr (let* ((flagstr
(mapconcat (mapconcat
(lambda (flag-cell) (lambda (flag-cell)
(if (car flag-cell) (if (car flag-cell)
(if mu4e-use-fancy-chars (if mu4e-use-fancy-chars
(cddr flag-cell) (cadr flag-cell) ) "")) (cddr flag-cell) (cadr flag-cell) ) ""))
`((,mu4e-search-full . ,mu4e-headers-full-label) `((,mu4e-search-full . ,mu4e-headers-full-label)
(,mu4e-headers-include-related . ,mu4e-headers-related-label) (,mu4e-headers-include-related . ,mu4e-headers-related-label)
(,mu4e-search-threads . ,mu4e-headers-threaded-label) (,mu4e-search-threads . ,mu4e-headers-threaded-label)
(,mu4e-headers-skip-duplicates . ,mu4e-headers-skip-duplicates-label)) (,mu4e-headers-skip-duplicates
"")) . ,mu4e-headers-skip-duplicates-label))
(name "mu4e-headers")) ""))
(name "mu4e-headers"))
(setq mode-name name) (setq mode-name name)
(setq mu4e~headers-mode-line-label (concat flagstr " " mu4e--search-last-query)) (setq mu4e~headers-mode-line-label
(concat flagstr " " mu4e--search-last-query))
(make-local-variable 'global-mode-string) (make-local-variable 'global-mode-string)
@ -1405,9 +1421,10 @@ matching messages with that mark."
(if (member field '(:to :from :cc :bcc :reply-to)) (if (member field '(:to :from :cc :bcc :reply-to))
(cl-find-if (lambda (contact) (cl-find-if (lambda (contact)
(let ((name (mu4e-contact-name contact)) (let ((name (mu4e-contact-name contact))
(email (mu4e-contact-email contact))) (email (mu4e-contact-email contact)))
(or (and name (string-match pattern name)) (or (and name (string-match pattern name))
(and email (string-match pattern email))))) value) (and email (string-match pattern email)))))
value)
(string-match pattern (or value "")))))))) (string-match pattern (or value ""))))))))
(defun mu4e-headers-mark-custom () (defun mu4e-headers-mark-custom ()
@ -1501,7 +1518,8 @@ user)."
(or field (or field
(mu4e-read-option "Sortfield: " mu4e~headers-sort-field-choices))) (mu4e-read-option "Sortfield: " mu4e~headers-sort-field-choices)))
;; note: 'sortable' is either a boolean (meaning: if non-nil, this is ;; note: 'sortable' is either a boolean (meaning: if non-nil, this is
;; sortable field), _or_ another field (meaning: sort by this other field). ;; sortable field), _or_ another field (meaning: sort by this other
;; field).
(sortable (plist-get (cdr (assoc field mu4e-header-info)) :sortable)) (sortable (plist-get (cdr (assoc field mu4e-header-info)) :sortable))
;; error check ;; error check
(sortable (sortable
@ -1533,21 +1551,22 @@ When prefix-argument DONT-REFRESH is non-nill, do not refresh the
last search with the new setting." last search with the new setting."
(interactive "P") (interactive "P")
(let* ((toggles '(("fFull-search" . mu4e-search-full) (let* ((toggles '(("fFull-search" . mu4e-search-full)
("rInclude-related" . mu4e-headers-include-related) ("rInclude-related" . mu4e-headers-include-related)
("tShow threads" . mu4e-search-threads) ("tShow threads" . mu4e-search-threads)
("uSkip duplicates" . mu4e-headers-skip-duplicates))) ("uSkip duplicates" . mu4e-headers-skip-duplicates)))
(toggles (seq-map (toggles (seq-map
(lambda (cell) (lambda (cell)
(cons (cons
(concat (car cell) (format" (%s)" (concat (car cell)
(if (symbol-value (cdr cell)) "on" "off"))) (format" (%s)"
(cdr cell))) toggles)) (if (symbol-value (cdr cell)) "on" "off")))
(choice (mu4e-read-option "Toggle setting " toggles))) (cdr cell))) toggles))
(choice (mu4e-read-option "Toggle setting " toggles)))
(when choice (when choice
(set choice (not (symbol-value choice))) (set choice (not (symbol-value choice)))
(mu4e-message "Set `%s' to %s" (symbol-name choice) (symbol-value choice)) (mu4e-message "Set `%s' to %s" (symbol-name choice) (symbol-value choice))
(unless dont-refresh (unless dont-refresh
(mu4e-search-rerun))))) (mu4e-search-rerun)))))
(defun mu4e~headers-toggle (name togglevar dont-refresh) (defun mu4e~headers-toggle (name togglevar dont-refresh)
@ -1595,9 +1614,9 @@ _not_ refresh the last search with the new setting for threading."
(unless (eq major-mode 'mu4e-headers-mode) (unless (eq major-mode 'mu4e-headers-mode)
(mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode))
(let* ((msg (mu4e-message-at-point)) (let* ((msg (mu4e-message-at-point))
(path (mu4e-message-field msg :path)) (path (mu4e-message-field msg :path))
(_exists (or (file-readable-p path) (_exists (or (file-readable-p path)
(mu4e-warn "No message at %s" path))) (mu4e-warn "No message at %s" path)))
(docid (or (mu4e-message-field msg :docid) (docid (or (mu4e-message-field msg :docid)
(mu4e-warn "No message at point"))) (mu4e-warn "No message at point")))
(mark-as-read (mark-as-read
@ -1622,12 +1641,12 @@ return nil."
(condition-case _err (condition-case _err
(prog1 (prog1
(let (line-move-visual) (let (line-move-visual)
(and (line-move arg) 0)) (and (line-move arg) 0))
;; Skip invisible text at BOL possibly hidden by ;; Skip invisible text at BOL possibly hidden by
;; the end of another invisible overlay covering ;; the end of another invisible overlay covering
;; previous EOL. ;; previous EOL.
(move-to-column 2)) (move-to-column 2))
((beginning-of-buffer end-of-buffer) ((beginning-of-buffer end-of-buffer)
1)))) 1))))
(let* ((succeeded (zerop (goto-next-line lines))) (let* ((succeeded (zerop (goto-next-line lines)))
(docid (mu4e~headers-docid-at-point))) (docid (mu4e~headers-docid-at-point)))
@ -1637,7 +1656,8 @@ return nil."
;; update all windows showing the headers buffer ;; update all windows showing the headers buffer
(walk-windows (walk-windows
(lambda (win) (lambda (win)
(when (eq (window-buffer win) (mu4e-get-headers-buffer (buffer-name))) (when (eq (window-buffer win)
(mu4e-get-headers-buffer (buffer-name)))
(set-window-point win (point)))) (set-window-point win (point))))
nil t) nil t)
;; If the assigned (and buffer-local) `mu4e~headers-view-win' ;; If the assigned (and buffer-local) `mu4e~headers-view-win'
@ -1649,8 +1669,8 @@ return nil."
;; attempt to highlight the new line, display the message ;; attempt to highlight the new line, display the message
(mu4e~headers-highlight docid) (mu4e~headers-highlight docid)
(if succeeded (if succeeded
docid docid
nil))))) nil)))))
(defun mu4e-headers-next (&optional n) (defun mu4e-headers-next (&optional n)
"Move point to the next message header. "Move point to the next message header.
@ -1701,7 +1721,8 @@ given, offer to edit the search query before executing it."
(list maildir current-prefix-arg))) (list maildir current-prefix-arg)))
(when maildir (when maildir
(let* ((query (format "maildir:\"%s\"" maildir)) (let* ((query (format "maildir:\"%s\"" maildir))
(query (if edit (mu4e-search-read-query "Refine query: " query) query))) (query (if edit
(mu4e-search-read-query "Refine query: " query) query)))
(mu4e-mark-handle-when-leaving) (mu4e-mark-handle-when-leaving)
(mu4e-search query)))) (mu4e-search query))))
@ -1741,7 +1762,8 @@ pass ACTIONFUNC, which is a function that takes a msg-plist
argument." argument."
(interactive) (interactive)
(let ((msg (mu4e-message-at-point)) (let ((msg (mu4e-message-at-point))
(afunc (or actionfunc (mu4e-read-option "Action: " mu4e-headers-actions)))) (afunc (or actionfunc
(mu4e-read-option "Action: " mu4e-headers-actions))))
(funcall afunc msg))) (funcall afunc msg)))
(defun mu4e-headers-mark-and-next (mark) (defun mu4e-headers-mark-and-next (mark)
@ -1779,14 +1801,18 @@ other windows."
(when mu4e-dim-when-loading (when mu4e-dim-when-loading
(setq mu4e--loading-overlay-bg (setq mu4e--loading-overlay-bg
(let ((overlay (make-overlay (point-min) (point-max)))) (let ((overlay (make-overlay (point-min) (point-max))))
(overlay-put overlay 'face `(:foreground "gray22" :background (overlay-put overlay 'face
,(face-attribute 'default :background))) `(:foreground "gray22" :background
,(face-attribute 'default
:background)))
(overlay-put overlay 'priority 9998) (overlay-put overlay 'priority 9998)
overlay))) overlay)))
(setq mu4e--loading-overlay-text (setq mu4e--loading-overlay-text
(let ((overlay (make-overlay (point-min) (point-min)))) (let ((overlay (make-overlay (point-min) (point-min))))
(overlay-put overlay 'priority 9999) (overlay-put overlay 'priority 9999)
(overlay-put overlay 'before-string (propertize "Loading…\n" 'face 'mu4e-header-title-face)) (overlay-put overlay 'before-string
(propertize "Loading…\n"
'face 'mu4e-header-title-face))
overlay))) overlay)))
(when mu4e--loading-overlay-bg (when mu4e--loading-overlay-bg
(delete-overlay mu4e--loading-overlay-bg)) (delete-overlay mu4e--loading-overlay-bg))