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 'hl-line)
(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)
@ -142,7 +143,8 @@ Example that hides all trashed messages:
(member \='trashed (mu4e-message-field msg :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.
Each element is a symbol in the list.
@ -374,7 +376,8 @@ into a string."
(connection (funcall get-prefix mu4e-headers-thread-connection-prefix))
(blank (funcall get-prefix mu4e-headers-thread-blank-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))
(t "?"))))
@ -481,7 +484,8 @@ with DOCID which must be present in the headers buffer."
(if single-orphan 'single-orphan
(if (and orphan
(or first-child
(not (eq mu4e-headers-thread-mark-as-orphan 'first))))
(not (eq mu4e-headers-thread-mark-as-orphan
'first))))
'orphan
(if last-child 'last-child
(if first-child 'first-child
@ -650,7 +654,10 @@ space propertized with a `display' text property which expands to
(let* ((field (car f-w))
(width (cdr f-w))
(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))
(defsubst mu4e~headers-apply-flags (msg fieldval)
@ -716,7 +723,8 @@ docid is not found."
(defun mu4e~headers-view-this-message-p (docid)
"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
(defun mu4e~headers-append-handler (msglst)
@ -882,7 +890,8 @@ after the end of the search results."
(when mu4e--search-msgid-target
(if (eq (current-buffer) (window-buffer))
(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
(set-window-point (get-buffer-window nil t) pos)))))
(when (and mu4e--search-view-target (mu4e-message-at-point 'noerror))
@ -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-shrink)
(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)
(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-custom)
(define-key map (kbd "*") 'mu4e-headers-mark-for-something)
(define-key map (kbd "<kp-multiply>") '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-headers-mark-for-something)
(define-key map (kbd "<kp-multiply>")
'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)
@ -1296,12 +1310,14 @@ message plist, or nil if not found."
`((,mu4e-search-full . ,mu4e-headers-full-label)
(,mu4e-headers-include-related . ,mu4e-headers-related-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"))
(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)
@ -1407,7 +1423,8 @@ matching messages with that mark."
(let ((name (mu4e-contact-name contact))
(email (mu4e-contact-email contact)))
(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 ""))))))))
(defun mu4e-headers-mark-custom ()
@ -1501,7 +1518,8 @@ user)."
(or field
(mu4e-read-option "Sortfield: " mu4e~headers-sort-field-choices)))
;; 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))
;; error check
(sortable
@ -1539,7 +1557,8 @@ last search with the new setting."
(toggles (seq-map
(lambda (cell)
(cons
(concat (car cell) (format" (%s)"
(concat (car cell)
(format" (%s)"
(if (symbol-value (cdr cell)) "on" "off")))
(cdr cell))) toggles))
(choice (mu4e-read-option "Toggle setting " toggles)))
@ -1637,7 +1656,8 @@ return nil."
;; update all windows showing the headers buffer
(walk-windows
(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))))
nil t)
;; If the assigned (and buffer-local) `mu4e~headers-view-win'
@ -1701,7 +1721,8 @@ given, offer to edit the search query before executing it."
(list maildir current-prefix-arg)))
(when 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-search query))))
@ -1741,7 +1762,8 @@ pass ACTIONFUNC, which is a function that takes a msg-plist
argument."
(interactive)
(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)))
(defun mu4e-headers-mark-and-next (mark)
@ -1779,14 +1801,18 @@ other windows."
(when mu4e-dim-when-loading
(setq mu4e--loading-overlay-bg
(let ((overlay (make-overlay (point-min) (point-max))))
(overlay-put overlay 'face `(:foreground "gray22" :background
,(face-attribute 'default :background)))
(overlay-put overlay 'face
`(:foreground "gray22" :background
,(face-attribute 'default
:background)))
(overlay-put overlay 'priority 9998)
overlay)))
(setq mu4e--loading-overlay-text
(let ((overlay (make-overlay (point-min) (point-min))))
(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)))
(when mu4e--loading-overlay-bg
(delete-overlay mu4e--loading-overlay-bg))