aboutsummaryrefslogtreecommitdiffstats
path: root/_spacemacs.d/local/mu4e/mu4e-headers.el
diff options
context:
space:
mode:
Diffstat (limited to '_spacemacs.d/local/mu4e/mu4e-headers.el')
-rw-r--r--_spacemacs.d/local/mu4e/mu4e-headers.el111
1 files changed, 67 insertions, 44 deletions
diff --git a/_spacemacs.d/local/mu4e/mu4e-headers.el b/_spacemacs.d/local/mu4e/mu4e-headers.el
index f45d7b4..e137c02 100644
--- a/_spacemacs.d/local/mu4e/mu4e-headers.el
+++ b/_spacemacs.d/local/mu4e/mu4e-headers.el
@@ -135,6 +135,21 @@ 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,
+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
'(draft flagged new passed replied seen trashed attach encrypted signed unread)
"An ordered list of flags to show in the headers buffer. Each
@@ -215,7 +230,7 @@ Field must be a symbol, one of: :date, :subject, :size, :prio,
(defvar mu4e-headers-default-prefix '("|" . "│ ") "Default.")
(defvar mu4e-headers-actions
- '( ("capture message" . mu4e-action-capture-message)
+ '( ("capture message" . mu4e-action-capture-message)
("show this thread" . mu4e-action-show-thread))
"List of actions to perform on messages in the headers list.
The actions are of the form (NAME SHORTCUT FUNC) where:
@@ -311,22 +326,23 @@ headers."
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
(let* ((docid (mu4e-message-field msg :docid))
- (initial-message-at-point (mu4e~headers-docid-at-point))
- (initial-column (current-column))
- (point (mu4e~headers-docid-pos docid)))
+ (initial-message-at-point (mu4e~headers-docid-at-point))
+ (initial-column (current-column))
+ (point (mu4e~headers-docid-pos docid)))
+
(when point ;; is the message present in this list?
;; if it's marked, unmark it now
(when (mu4e-mark-docid-marked-p docid)
(mu4e-mark-set 'unmark))
- ;; re-use the thread info from the old one; this is needed because
- ;; *update* messages don't have thread info by themselves (unlike
- ;; search results)
+ ;; re-use the thread info from the old one; this is needed because
+ ;; *update* messages don't have thread info by themselves (unlike
+ ;; search results)
;; since we still have the search results, re-use
- ;; those
- (plist-put msg :thread
- (mu4e~headers-field-for-docid docid :thread))
+ ;; those
+ (plist-put msg :thread
+ (mu4e~headers-field-for-docid docid :thread))
;; first, remove the old one (otherwise, we'd have two headers with
;; the same docid...
@@ -337,11 +353,10 @@ headers."
;; (which is useful for viewing the raw message)
(when (mu4e~headers-view-this-message-p docid)
(mu4e-view msg mu4e~headers-buffer))
-
;; 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
- ;; longer matches the query, but this seem a good heuristic.
- ;; if it was only a flag-change, show the message with its updated flags.
+ ;; longer matches the query, but this seem a good heuristic. if it
+ ;; was only a flag-change, show the message with its updated flags.
(unless is-move
(mu4e~headers-header-handler msg point))
@@ -351,8 +366,7 @@ headers."
(move-to-column initial-column)
(mu4e~headers-highlight initial-message-at-point))
;; attempt to highlight the corresponding line and make it visible
- (mu4e~headers-highlight docid))
- )))))
+ (mu4e~headers-highlight docid)))))))
(defun mu4e~headers-remove-handler (docid)
"Remove handler, will be called when a message with DOCID has
@@ -382,7 +396,7 @@ into a string."
(let ((name (car ct)) (email (cdr ct)))
(or name email "?"))) contacts ", "))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defsubst mu4e~headers-thread-prefix (thread)
"Calculate the thread prefix based on thread info THREAD."
(when thread
@@ -430,7 +444,7 @@ while our display may be different)."
('signed (funcall get-prefix mu4e-headers-signed-mark))
('unread (funcall get-prefix mu4e-headers-unread-mark)))))))
str))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst mu4e-headers-from-or-to-prefix '("" . "To ")
@@ -493,7 +507,8 @@ found."
(let* ((item (or (assoc field mu4e-header-info-custom)
(mu4e-error "field %S not found" field)))
(func (or (plist-get (cdr-safe item) :function)
- (mu4e-error "no :function defined for field %S %S" field (cdr item)))))
+ (mu4e-error "no :function defined for field %S %S"
+ field (cdr item)))))
(funcall func msg)))
(defun mu4e~headers-field-apply-basic-properties (msg field val width)
@@ -571,12 +586,14 @@ found."
(defun mu4e~headers-header-handler (msg &optional point)
"Create a one line description of MSG in this buffer, at POINT,
if provided, or at the end of the buffer otherwise."
- (let ((docid (mu4e-message-field msg :docid))
- (line (mapconcat (lambda (f-w)
- (mu4e~headers-field-handler f-w msg))
- mu4e-headers-fields " ")))
- (setq line (mu4e~headers-line-handler msg line))
- (mu4e~headers-add-header line docid point msg)))
+ (unless (and mu4e-headers-hide-predicate
+ (funcall mu4e-headers-hide-predicate msg))
+ (let ((docid (mu4e-message-field msg :docid))
+ (line (mapconcat (lambda (f-w)
+ (mu4e~headers-field-handler f-w 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~end-of-results "End of search results")
@@ -598,14 +615,15 @@ after the end of the search results."
(goto-char (point-min))
(when mu4e~headers-msgid-target
(mu4e-headers-goto-message-id mu4e~headers-msgid-target))
- (when mu4e~headers-view-target
- (mu4e-headers-view-message)) ;; view the message at point
+ (when (and mu4e~headers-view-target (mu4e-message-at-point 'noerror))
+ ;; view the message at point when there is one.
+ (mu4e-headers-view-message))
(setq mu4e~headers-view-target nil
mu4e~headers-msgid-target nil))
(when (mu4e~headers-docid-at-point)
(mu4e~headers-highlight (mu4e~headers-docid-at-point)))
;; run-hooks
- (run-hooks 'mu4e-headers-found-hook)))
+ (run-hooks 'mu4e-headers-found-hook)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -679,7 +697,7 @@ after the end of the search results."
(define-key map (kbd "[") 'mu4e-headers-prev-unread)
(define-key map (kbd "]") 'mu4e-headers-next-unread)
-
+
;; change the number of headers
(define-key map (kbd "C-+") 'mu4e-headers-split-view-grow)
(define-key map (kbd "C--") 'mu4e-headers-split-view-shrink)
@@ -687,7 +705,7 @@ after the end of the search results."
(define-key map (kbd "<C-kp-subtract>") 'mu4e-headers-split-view-shrink)
(define-key map ";" 'mu4e-context-switch)
-
+
;; switching to view mode (if it's visible)
(define-key map "y" 'mu4e-select-other-view)
@@ -748,20 +766,24 @@ after the end of the search results."
(define-key menumap [sepa0] '("--"))
(define-key menumap [toggle-include-related]
- '(menu-item "Toggle related messages" mu4e-headers-toggle-include-related
- :button (:toggle . (and (boundp 'mu4e-headers-include-related)
- mu4e-headers-include-related))))
+ '(menu-item "Toggle related messages"
+ mu4e-headers-toggle-include-related
+ :button (:toggle .
+ (and (boundp 'mu4e-headers-include-related)
+ mu4e-headers-include-related))))
(define-key menumap [toggle-threading]
'(menu-item "Toggle threading" mu4e-headers-toggle-threading
- :button (:toggle . (and (boundp 'mu4e-headers-show-threads)
- mu4e-headers-show-threads))))
+ :button (:toggle .
+ (and (boundp 'mu4e-headers-show-threads)
+ mu4e-headers-show-threads))))
(define-key menumap [sepa1] '("--"))
(define-key menumap [execute-marks] '("Execute marks"
. mu4e-mark-execute-all))
(define-key menumap [unmark-all] '("Unmark all" . mu4e-mark-unmark-all))
- (define-key menumap [unmark] '("Unmark" . mu4e-headers-mark-for-unmark))
+ (define-key menumap [unmark]
+ '("Unmark" . mu4e-headers-mark-for-unmark))
(define-key menumap [mark-pattern] '("Mark pattern" .
mu4e-headers-mark-pattern))
@@ -783,11 +805,12 @@ after the end of the search results."
(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] '("Next query" . mu4e-headers-query-next))
+ (define-key menumap [query-next]
+ '("Next query" . mu4e-headers-query-next))
(define-key menumap [query-prev] '("Previous query" .
mu4e-headers-query-prev))
(define-key menumap [narrow-search] '("Narrow search" .
@@ -979,7 +1002,7 @@ message plist, or nil if not found."
(let ((this-msgid (mu4e-message-field msg :message-id)))
(when (and this-msgid (string= msgid this-msgid))
msg)))))
-
+
;;;; markers mark headers for
(defun mu4e~headers-mark (docid mark)
"(Visually) mark the header for DOCID with character MARK."
@@ -1062,7 +1085,7 @@ the query history stack."
'face 'mu4e-modeline-face)
" "
(mu4e-context-label)))))
-
+
(switch-to-buffer buf)
(run-hook-with-args 'mu4e-headers-search-hook expr)
(mu4e~proc-find
@@ -1229,7 +1252,7 @@ descendants."
(last-marked-point))
(mu4e-headers-for-each
(lambda (mymsg)
- (let ((my-thread-id (mu4e~headers-get-thread-info mymsg 'thread-id)))
+ (let ((my-thread-id (mu4e~headers-get-thread-info mymsg 'thread-id)))
(if subthread
;; subthread matching; mymsg's thread path should have path as its
;; prefix
@@ -1375,8 +1398,8 @@ the last search expression. Note that you can go back to previous
query (effectively, 'widen' it), with `mu4e-headers-query-prev'."
(interactive
(let ((filter
- (read-string (mu4e-format "Narrow down to: ")
- nil 'mu4e~headers-search-hist nil t)))
+ (read-string (mu4e-format "Narrow down to: ")
+ nil 'mu4e~headers-search-hist nil t)))
(list filter)))
(unless mu4e~headers-last-query
(mu4e-warn "There's nothing to filter"))
@@ -1586,7 +1609,7 @@ untrashed). If BACKWARDS is non-`nil', move backwards."
(interactive)
(or (mu4e-headers-find-if-next
(lambda (msg)
- (let ((flags (mu4e-message-field msg :flags)))
+ (let ((flags (mu4e-message-field msg :flags)))
(and (member 'unread flags) (not (member 'trashed flags)))))
backwards)
(mu4e-message (format "No %s unread message found"