mu4e-headers: implement mu4e-headers-toggle-setting

Make it easier to toggle various header-view settings and display them in the mode-line.
This commit is contained in:
Dirk-Jan C. Binnema 2022-06-11 12:07:50 +03:00
parent 5a3306ddfc
commit 1a84a57e05
2 changed files with 62 additions and 28 deletions

View File

@ -91,9 +91,6 @@
*** mu4e *** mu4e
- the old mu4e-view is *gone*; only the gnus-based one remains. This allowed
for removing quite a bit of old code.
- the mu4e headers rendering is much faster (a factor of 3+), which makes - the mu4e headers rendering is much faster (a factor of 3+), which makes
displaying big results snappier. This required some updates in the headers displaying big results snappier. This required some updates in the headers
handling and in the server protocol. Separate from that, the cached handling and in the server protocol. Separate from that, the cached
@ -103,6 +100,27 @@
- "related" messages are now recognizable as such in the headers-view, with - "related" messages are now recognizable as such in the headers-view, with
their own face, ~mu4e-related-face~; by default with an italic slant. their own face, ~mu4e-related-face~; by default with an italic slant.
- For performance testing, you can set the variable
~mu4e-headers-report-render-time~ to ~t~ and ~mu4e~ will report the
search/rendering speed of each query operation.
- Removed header-fields ~:attachments~, ~:signature~, ~:encryption~ and
~:user-agent~. They're obsolete with the Gnus-based message viewer.
- The various "toggles" for the headers-view (full-search, include-related,
skip-duplicates, threading) were a bit hard to find and with non-obvious
key-bindings. For that, there is now ~mu4e-headers-toggle-setting~ (bound to
~M~) to handle all of that. The toggles are also reflected in the mode-line;
so e.g. 'RTU' means we're including [R]elated messages, and show [T]hreads,
skip duplicates ([U]nique).
- the old mu4e-view is *gone*; only the gnus-based one remains. This allowed
for removing quite a bit of old code.
- A new ~defcustom~, ~mu4e-view-open-program~ for starting the appropriate
program for a give file (e.g., ~xdg-open~). There are some reasonable
defaults for various systems. This can also be set to a function.
- indexing happens in the background now and mu4e can interact with the - indexing happens in the background now and mu4e can interact with the
server while it is ongoing; this allows for using mu4e during lengthy server while it is ongoing; this allows for using mu4e during lengthy
indexing operations. indexing operations.
@ -122,14 +140,6 @@
automatically change the ~Organization:~ header, and attempts to update the automatically change the ~Organization:~ header, and attempts to update the
message signature. Also, there's a key-binding now: ~C-c ;~ message signature. Also, there's a key-binding now: ~C-c ;~
- A new ~defcustom~, ~mu4e-view-open-program~ for starting the appropriate
program for a give file (e.g., ~xdg-open~). There are some reasonable
defaults for various systems. This can also be set to a function.
- For performance testing, you can set the variable
~mu4e-headers-report-render-time~ to ~t~ and ~mu4e~ will report the
search/rendering speed of each query operation.
- Changed the default for ~mu4e-compose-complete-only-after~ to 2018-01-01, to - Changed the default for ~mu4e-compose-complete-only-after~ to 2018-01-01, to
filter out contacts not seen after that date. filter out contacts not seen after that date.
@ -143,9 +153,6 @@
- Removed ~make-mu4e-bookmark~ which was obsoleted in version 1.3.9. - Removed ~make-mu4e-bookmark~ which was obsoleted in version 1.3.9.
- Removed header-fields ~:attachments~, ~:signature~, ~:encryption~ and
~:user-agent~. They're obsolete with the Gnus-based message viewer.
- Add command ~mu4e-sexp-at-point~ for showing/hiding the s-expression for the - Add command ~mu4e-sexp-at-point~ for showing/hiding the s-expression for the
message-at-point. Useful for development / debugging. Bound to ~,~ in headers message-at-point. Useful for development / debugging. Bound to ~,~ in headers
and view mode. and view mode.

View File

@ -272,13 +272,13 @@ Must have the same length as `mu4e-headers-thread-connection-prefix'.")
(defvar mu4e-headers-thread-duplicate-prefix '("=" . "") (defvar mu4e-headers-thread-duplicate-prefix '("=" . "")
"Prefix for duplicate messages.") "Prefix for duplicate messages.")
(defvar mu4e-headers-threaded-label '("T" . "") (defvar mu4e-headers-threaded-label '("T" . "")
"Non-fancy and fancy labels for threaded search in the mode-line.") "Non-fancy and fancy labels to indicate threaded search in the mode-line.")
(defvar mu4e-headers-full-label '("F" . "") (defvar mu4e-headers-full-label '("F" . "")
"Non-fancy and fancy labels for full search in the mode-line.") "Non-fancy and fancy labels to indicate full search in the mode-line.")
(defvar mu4e-headers-related-label '("R" . "") (defvar mu4e-headers-related-label '("R" . "")
"Non-fancy and fancy labels to indicate related search in the mode-line.")
(defvar mu4e-headers-skip-duplicates-label '("U" . "") ;; 'U' for 'unique'
"Non-fancy and fancy labels for include-related search in the mode-line.") "Non-fancy and fancy labels for include-related search in the mode-line.")
;;;; Various ;;;; Various
@ -942,8 +942,11 @@ after the end of the search results."
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(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)
;; these are impossible to remember; use mu4e-headers-toggle-setting
;; 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)
@ -1296,15 +1299,16 @@ message plist, or nil if not found."
(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 (lambda (flag-cell) (mapconcat
(if (car flag-cell) (lambda (flag-cell)
(if mu4e-use-fancy-chars (if (car flag-cell)
(cddr flag-cell) (cadr flag-cell) ) (if mu4e-use-fancy-chars
"")) (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))
""))
(name "mu4e-headers")) (name "mu4e-headers"))
(setq mode-name name) (setq mode-name name)
@ -1561,6 +1565,29 @@ user)."
(symbol-name mu4e-headers-sort-direction)) (symbol-name mu4e-headers-sort-direction))
(mu4e-search-rerun))) (mu4e-search-rerun)))
(defun mu4e-headers-toggle-setting (&optional dont-refresh)
"Toggle some aspect of headers display.
When prefix-argument DONT-REFRESH is non-nill, do not refresh the
last search with the new setting."
(interactive "P")
(let* ((toggles '(("fFull-search" . mu4e-search-full)
("rInclude-related" . mu4e-headers-include-related)
("tShow threads" . mu4e-search-threads)
("uSkip duplicates" . mu4e-headers-skip-duplicates)))
(toggles (seq-map
(lambda (cell)
(cons
(concat (car cell) (format" (%s)" (if (cdr cell) "on" "off")))
(cdr cell))) toggles))
(choice (mu4e-read-option "Toggle setting " toggles)))
(when choice
(set choice (not (symbol-value choice)))
(mu4e-message "Set `%s' to %s" (symbol-name choice) (symbol-value choice))
(unless dont-refresh
(mu4e-search-rerun)))))
(defun mu4e~headers-toggle (name togglevar dont-refresh) (defun mu4e~headers-toggle (name togglevar dont-refresh)
"Toggle variable TOGGLEVAR for feature NAME. Unless DONT-REFRESH is non-nil, "Toggle variable TOGGLEVAR for feature NAME. Unless DONT-REFRESH is non-nil,
re-run the last search." re-run the last search."