mu4e-headers: show search props in mode-line

I.e., whether a search is threaded/include-related/full.

There's high bike-shed potential, but let's not do that yet.
This commit is contained in:
Dirk-Jan C. Binnema
2021-02-12 20:39:49 +02:00
parent 2d91a9ab27
commit 895f580b99
2 changed files with 47 additions and 18 deletions

View File

@ -269,6 +269,15 @@ This prefix should have the same length as `mu4e-headers-thread-connection-prefi
(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" . "🎄")
"Non-fancy and fancy labels for threaded search in the mode-line.")
(defvar mu4e-headers-full-label '("F" . "")
"Non-fancy and fancy labels for full search in the mode-line.")
(defvar mu4e-headers-related-label '("R" . "🤝")
"Non-fancy and fancy labels for inclued-related search in the mode-line.")
;;;; Various ;;;; Various
(defvar mu4e-headers-actions (defvar mu4e-headers-actions
@ -1259,6 +1268,41 @@ anything about the query, it just does text replacement."
:type 'function :type 'function
:group 'mu4e) :group 'mu4e)
(defvar mu4e~headers-mode-line-label "")
(defun mu4e~headers-update-mode-line ()
"Update mode-line settings."
(let* ((flagstr
(mapconcat (lambda (flag-cell)
(if (car flag-cell)
(if mu4e-use-fancy-chars
(cddr flag-cell) (cadr flag-cell) )
""))
`((,mu4e-headers-full-search . ,mu4e-headers-full-label)
(,mu4e-headers-include-related . ,mu4e-headers-related-label)
(,mu4e-headers-show-threads . ,mu4e-headers-threaded-label))
""))
(name "mu4e-headers"))
(setq mode-name name)
(setq mu4e~headers-mode-line-label (concat flagstr " " mu4e~headers-last-query))
(make-local-variable 'global-mode-string)
(add-to-list 'global-mode-string
`(:eval
(concat
(propertize
(mu4e~quote-for-modeline ,mu4e~headers-mode-line-label)
'face 'mu4e-modeline-face)
" "
(if (and mu4e-display-update-status-in-modeline
(buffer-live-p mu4e~update-buffer)
(process-live-p (get-buffer-process
mu4e~update-buffer)))
(propertize " (updating)" 'face 'mu4e-modeline-face)
""))))))
(defun mu4e~headers-search-execute (expr ignore-history) (defun mu4e~headers-search-execute (expr ignore-history)
"Search in the mu database for EXPR, and switch to the output "Search in the mu database for EXPR, and switch to the output
buffer for the results. If IGNORE-HISTORY is true, do *not* update buffer for the results. If IGNORE-HISTORY is true, do *not* update
@ -1276,23 +1320,8 @@ the query history stack."
;; save the old present query to the history list ;; save the old present query to the history list
(when mu4e~headers-last-query (when mu4e~headers-last-query
(mu4e~headers-push-query mu4e~headers-last-query 'past))) (mu4e~headers-push-query mu4e~headers-last-query 'past)))
(setq (setq mu4e~headers-last-query rewritten-expr)
mode-name "mu4e-headers" (mu4e~headers-update-mode-line))
mu4e~headers-last-query rewritten-expr)
(make-local-variable 'global-mode-string)
(add-to-list 'global-mode-string
'(:eval
(concat
(propertize
(mu4e~quote-for-modeline mu4e~headers-last-query)
'face 'mu4e-modeline-face)
" "
(if (and mu4e-display-update-status-in-modeline
(buffer-live-p mu4e~update-buffer)
(process-live-p (get-buffer-process
mu4e~update-buffer)))
(propertize " (updating)" 'face 'mu4e-modeline-face)
"")))))
;; when the buffer is already visible, select it; otherwise, ;; when the buffer is already visible, select it; otherwise,
;; switch to it. ;; switch to it.

View File

@ -208,7 +208,7 @@ Follows the format of `format-time-string'."
:type 'string :type 'string
:group 'mu4e) :group 'mu4e)
(defcustom mu4e-modeline-max-width 30 (defcustom mu4e-modeline-max-width 42
"Determines the maximum length of the modeline string. "Determines the maximum length of the modeline string.
If the string exceeds this limit, it will be truncated to fit." If the string exceeds this limit, it will be truncated to fit."
:type 'integer :type 'integer