mirror of https://github.com/djcb/mu.git
mu4e: add mu4e-headers-hide-predicate
Add `mu4e-headers-hide-predicate', a function that allows for hiding messages from the display. This can be used e.g. to hide trashed messages.
This commit is contained in:
parent
b5345851ee
commit
49bc9605d8
|
@ -135,6 +135,21 @@ sent messages into message threads."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'mu4e-headers)
|
: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,
|
||||||
|
otherwise don't. function takes one parameter MSG, which is the
|
||||||
|
message plist for the message to be hidden or not.
|
||||||
|
|
||||||
|
Example that hides all 'trashed' messages:
|
||||||
|
(setq mu4e-headers-hide-predicate
|
||||||
|
(lambda (msg)
|
||||||
|
(member 'trashed (mu4e-message-field msg :flags))))
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -311,9 +326,10 @@ headers."
|
||||||
(when (buffer-live-p mu4e~headers-buffer)
|
(when (buffer-live-p mu4e~headers-buffer)
|
||||||
(with-current-buffer mu4e~headers-buffer
|
(with-current-buffer mu4e~headers-buffer
|
||||||
(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))
|
||||||
(point (mu4e~headers-docid-pos docid)))
|
(point (mu4e~headers-docid-pos docid)))
|
||||||
|
|
||||||
(when point ;; is the message present in this list?
|
(when point ;; is the message present in this list?
|
||||||
|
|
||||||
;; if it's marked, unmark it now
|
;; if it's marked, unmark it now
|
||||||
|
@ -337,7 +353,6 @@ headers."
|
||||||
;; (which is useful for viewing the raw message)
|
;; (which is useful for viewing the raw message)
|
||||||
(when (mu4e~headers-view-this-message-p docid)
|
(when (mu4e~headers-view-this-message-p docid)
|
||||||
(mu4e-view msg mu4e~headers-buffer))
|
(mu4e-view msg mu4e~headers-buffer))
|
||||||
|
|
||||||
;; now, if this update was about *moving* a message, we don't show it
|
;; now, if this update was about *moving* a message, we don't show it
|
||||||
;; anymore (of course, we cannot be sure if the message really no
|
;; anymore (of course, we cannot be sure if the message really no
|
||||||
;; longer matches the query, but this seem a good heuristic. if it
|
;; longer matches the query, but this seem a good heuristic. if it
|
||||||
|
@ -351,8 +366,7 @@ headers."
|
||||||
(move-to-column initial-column)
|
(move-to-column initial-column)
|
||||||
(mu4e~headers-highlight initial-message-at-point))
|
(mu4e~headers-highlight initial-message-at-point))
|
||||||
;; attempt to highlight the corresponding line and make it visible
|
;; attempt to highlight the corresponding line and make it visible
|
||||||
(mu4e~headers-highlight docid))
|
(mu4e~headers-highlight docid)))))))
|
||||||
)))))
|
|
||||||
|
|
||||||
(defun mu4e~headers-remove-handler (docid)
|
(defun mu4e~headers-remove-handler (docid)
|
||||||
"Remove handler, will be called when a message with DOCID has
|
"Remove handler, will be called when a message with DOCID has
|
||||||
|
@ -572,12 +586,14 @@ found."
|
||||||
(defun mu4e~headers-header-handler (msg &optional point)
|
(defun mu4e~headers-header-handler (msg &optional point)
|
||||||
"Create a one line description of MSG in this buffer, at POINT,
|
"Create a one line description of MSG in this buffer, at POINT,
|
||||||
if provided, or at the end of the buffer otherwise."
|
if provided, or at the end of the buffer otherwise."
|
||||||
(let ((docid (mu4e-message-field msg :docid))
|
(unless (and mu4e-headers-hide-predicate
|
||||||
(line (mapconcat (lambda (f-w)
|
(funcall mu4e-headers-hide-predicate msg))
|
||||||
(mu4e~headers-field-handler f-w msg))
|
(let ((docid (mu4e-message-field msg :docid))
|
||||||
mu4e-headers-fields " ")))
|
(line (mapconcat (lambda (f-w)
|
||||||
(setq line (mu4e~headers-line-handler msg line))
|
(mu4e~headers-field-handler f-w msg))
|
||||||
(mu4e~headers-add-header line docid point msg)))
|
mu4e-headers-fields " ")))
|
||||||
|
(setq line (mu4e~headers-line-handler msg line))
|
||||||
|
(mu4e~headers-add-header line docid point msg))))
|
||||||
|
|
||||||
(defconst mu4e~no-matches "No matching messages found")
|
(defconst mu4e~no-matches "No matching messages found")
|
||||||
(defconst mu4e~end-of-results "End of search results")
|
(defconst mu4e~end-of-results "End of search results")
|
||||||
|
|
Loading…
Reference in New Issue