mirror of
https://github.com/djcb/mu.git
synced 2024-06-26 07:29:17 +02:00
* mu4e: indicate sort field in headers line
This commit is contained in:
parent
c0ed7e4b83
commit
65d1e4ce07
|
@ -108,7 +108,7 @@ match.
|
||||||
* PARAM-FUNC is function that is evaluated once, and its value is then passed to
|
* PARAM-FUNC is function that is evaluated once, and its value is then passed to
|
||||||
PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
|
PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
|
||||||
|
|
||||||
(defvar mu4e-headers-sortfield 'date
|
(defvar mu4e-headers-sortfield :date
|
||||||
"Field to sort the headers by. Field must be a symbol, one of:
|
"Field to sort the headers by. Field must be a symbol, one of:
|
||||||
date, subject, size, prio, from, to.")
|
date, subject, size, prio, from, to.")
|
||||||
|
|
||||||
|
@ -140,12 +140,12 @@ PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
|
||||||
"The view window connected to this headers view.")
|
"The view window connected to this headers view.")
|
||||||
|
|
||||||
(defvar mu4e~headers-sortfield-choices
|
(defvar mu4e~headers-sortfield-choices
|
||||||
'( ("date" . date)
|
'( ("date" . :date)
|
||||||
("from" . from)
|
("from" . :from)
|
||||||
("prio" . prio)
|
("prio" . :prio)
|
||||||
("zsize" . size)
|
("zsize" . :size)
|
||||||
("subject" . subject)
|
("subject" . :subject)
|
||||||
("to" . to))
|
("to" . :to))
|
||||||
"List of cells describing the various sort-options (in the format
|
"List of cells describing the various sort-options (in the format
|
||||||
needed for `mu4e-read-option'.")
|
needed for `mu4e-read-option'.")
|
||||||
|
|
||||||
|
@ -508,6 +508,31 @@ after the end of the search results."
|
||||||
|
|
||||||
(fset 'mu4e-headers-mode-map mu4e-headers-mode-map)
|
(fset 'mu4e-headers-mode-map mu4e-headers-mode-map)
|
||||||
|
|
||||||
|
(defun mu4e~header-line-format ()
|
||||||
|
"Get the format for the header line."
|
||||||
|
(cons
|
||||||
|
(make-string
|
||||||
|
(+ mu4e~mark-fringe-len (floor (fringe-columns 'left t))) ?\s)
|
||||||
|
(mapcar
|
||||||
|
(lambda (item)
|
||||||
|
(let* ((field (car item)) (width (cdr item))
|
||||||
|
(info (cdr (assoc field mu4e-header-info)))
|
||||||
|
(help (plist-get info :help))
|
||||||
|
;; triangle to mark the sorted-by column
|
||||||
|
(triangle
|
||||||
|
(when (eq (car item) mu4e-headers-sortfield)
|
||||||
|
(if mu4e-headers-sort-revert "▼" "▲")))
|
||||||
|
(name (concat triangle (plist-get info :shortname))))
|
||||||
|
(concat
|
||||||
|
(propertize
|
||||||
|
(if width
|
||||||
|
(truncate-string-to-width name width 0 ?\s t)
|
||||||
|
name)
|
||||||
|
'face 'mu4e-header-title-face
|
||||||
|
'help-echo help
|
||||||
|
'mouse-face 'highlight) " ")))
|
||||||
|
mu4e-headers-fields)))
|
||||||
|
|
||||||
|
|
||||||
(define-derived-mode mu4e-headers-mode special-mode
|
(define-derived-mode mu4e-headers-mode special-mode
|
||||||
"mu4e:headers"
|
"mu4e:headers"
|
||||||
|
@ -524,33 +549,16 @@ after the end of the search results."
|
||||||
truncate-lines t
|
truncate-lines t
|
||||||
buffer-undo-list t ;; don't record undo information
|
buffer-undo-list t ;; don't record undo information
|
||||||
overwrite-mode 'overwrite-mode-binary
|
overwrite-mode 'overwrite-mode-binary
|
||||||
hl-line-face 'mu4e-header-highlight-face)
|
hl-line-face 'mu4e-header-highlight-face
|
||||||
(mu4e~mark-initialize) ;; initialize the marking subsystem
|
header-line-format (mu4e~header-line-format))
|
||||||
(hl-line-mode 1)
|
|
||||||
|
|
||||||
(setq header-line-format
|
(mu4e~mark-initialize) ;; initialize the marking subsystem
|
||||||
(cons
|
(hl-line-mode 1))
|
||||||
(make-string
|
|
||||||
(+ mu4e~mark-fringe-len (floor (fringe-columns 'left t))) ?\s)
|
|
||||||
(mapcar
|
|
||||||
(lambda (item)
|
|
||||||
(let* ((info (cdr (assoc (car item) mu4e-header-info)))
|
|
||||||
(name (plist-get info :shortname))
|
|
||||||
(help (plist-get info :help))
|
|
||||||
(width (cdr item)))
|
|
||||||
(concat
|
|
||||||
(propertize
|
|
||||||
(if width
|
|
||||||
(truncate-string-to-width name width 0 ?\s t)
|
|
||||||
name)
|
|
||||||
'face 'mu4e-header-title-face
|
|
||||||
'help-echo help) " ")))
|
|
||||||
mu4e-headers-fields))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; higlighting
|
;;; higlighting
|
||||||
(defvar mu4e~highlighted-docid nil
|
(defvar mu4e~highlighted-docid nil
|
||||||
"*internal* The highlighted docid")
|
"The highlighted docid")
|
||||||
|
|
||||||
(defun mu4e~headers-highlight (docid)
|
(defun mu4e~headers-highlight (docid)
|
||||||
"Highlight the header with DOCID, or do nothing if it's not
|
"Highlight the header with DOCID, or do nothing if it's not
|
||||||
|
|
|
@ -313,7 +313,7 @@ sexp, which are handled my `mu4e-error-func', respectively."
|
||||||
|
|
||||||
(defun mu4e~proc-find (query threads sortfield revert maxnum)
|
(defun mu4e~proc-find (query threads sortfield revert maxnum)
|
||||||
"Start a database query for QUERY. If THREADS is non-nil, show
|
"Start a database query for QUERY. If THREADS is non-nil, show
|
||||||
results in threaded fasion, SORTFIELD is a symmbol describing the
|
results in threaded fasion, SORTFIELD is a symbol describing the
|
||||||
field to sort by (or nil); see `mu4e~headers-sortfield-choices'. If
|
field to sort by (or nil); see `mu4e~headers-sortfield-choices'. If
|
||||||
REVERT is non-nil, sort Z->A instead of A->Z. MAXNUM determines the
|
REVERT is non-nil, sort Z->A instead of A->Z. MAXNUM determines the
|
||||||
maximum number of results to return, or nil for 'unlimited'. For
|
maximum number of results to return, or nil for 'unlimited'. For
|
||||||
|
@ -324,7 +324,8 @@ will be called for, resp., a message (header row) or an error."
|
||||||
"find query:\"%s\" threads:%s sortfield:%s reverse:%s maxnum:%d"
|
"find query:\"%s\" threads:%s sortfield:%s reverse:%s maxnum:%d"
|
||||||
query
|
query
|
||||||
(if threads "true" "false")
|
(if threads "true" "false")
|
||||||
(format "%S" sortfield)
|
;; sortfield is e.g. ':subject'; this removes the ':'
|
||||||
|
(if (null sortfield) "nil" (substring (symbol-name sortfield) 1))
|
||||||
(if revert "true" "false")
|
(if revert "true" "false")
|
||||||
(if maxnum maxnum -1)))
|
(if maxnum maxnum -1)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user