mirror of https://github.com/djcb/mu.git
mu4e: show sort arrows for fields / derived fields
We weren't showing the sort-arrows in all cases; we need to get calculate the current sortfield, compare that to the current sortfield.
This commit is contained in:
parent
d6ca171e9c
commit
90293f6d98
|
@ -735,46 +735,49 @@ after the end of the search results."
|
||||||
|
|
||||||
(defun mu4e~header-line-format ()
|
(defun mu4e~header-line-format ()
|
||||||
"Get the format for the header line."
|
"Get the format for the header line."
|
||||||
(cons
|
(let ((uparrow (if mu4e-use-fancy-chars " ▲" " ^"))
|
||||||
(make-string
|
(downarrow (if mu4e-use-fancy-chars " ▼" " V")))
|
||||||
(+ mu4e~mark-fringe-len (floor (fringe-columns 'left t))) ?\s)
|
(cons
|
||||||
(mapcar
|
(make-string
|
||||||
(lambda (item)
|
(+ mu4e~mark-fringe-len (floor (fringe-columns 'left t))) ?\s)
|
||||||
(let* ((field (car item)) (width (cdr item))
|
(mapcar
|
||||||
(info (cdr (assoc field
|
(lambda (item)
|
||||||
(append mu4e-header-info mu4e-header-info-custom))))
|
(let* ((field (car item)) (width (cdr item))
|
||||||
(sortable (plist-get info :sortable))
|
(info (cdr (assoc field
|
||||||
(help (plist-get info :help))
|
(append mu4e-header-info mu4e-header-info-custom))))
|
||||||
(uparrow (if mu4e-use-fancy-chars " ▲" " ^"))
|
(sortable (plist-get info :sortable))
|
||||||
(downarrow (if mu4e-use-fancy-chars " ▼" " V"))
|
;; if sortable, it is either t (when field is sortable itself) or a symbol (if
|
||||||
;; triangle to mark the sorted-by column
|
;; another field is used for sorting)
|
||||||
(arrow
|
(sortfield (when sortable (if (booleanp sortable) field sortable)))
|
||||||
(when (and sortable (eq (car item) mu4e-headers-sort-field))
|
(help (plist-get info :help))
|
||||||
(if (eq mu4e-headers-sort-direction 'descending) downarrow uparrow)))
|
;; triangle to mark the sorted-by column
|
||||||
(name (concat (plist-get info :shortname) arrow))
|
(arrow
|
||||||
(map (make-sparse-keymap)))
|
(when (and sortable (eq sortfield mu4e-headers-sort-field))
|
||||||
(when sortable
|
(if (eq mu4e-headers-sort-direction 'descending) downarrow uparrow)))
|
||||||
(define-key map [header-line mouse-1]
|
(name (concat (plist-get info :shortname) arrow))
|
||||||
(lambda (&optional e)
|
(map (make-sparse-keymap)))
|
||||||
;; getting the field, inspired by `tabulated-list-col-sort'
|
(when sortable
|
||||||
(interactive "e")
|
(define-key map [header-line mouse-1]
|
||||||
(let* ((obj (posn-object (event-start e)))
|
(lambda (&optional e)
|
||||||
(field
|
;; getting the field, inspired by `tabulated-list-col-sort'
|
||||||
(and obj (get-text-property 0 'field (car obj)))))
|
(interactive "e")
|
||||||
;; "t": if we're already sorted by field, the sort-order is
|
(let* ((obj (posn-object (event-start e)))
|
||||||
;; changed
|
(field
|
||||||
(mu4e-headers-change-sorting field t)))))
|
(and obj (get-text-property 0 'field (car obj)))))
|
||||||
(concat
|
;; "t": if we're already sorted by field, the sort-order is
|
||||||
(propertize
|
;; changed
|
||||||
(if width
|
(mu4e-headers-change-sorting field t)))))
|
||||||
(truncate-string-to-width name width 0 ?\s t)
|
(concat
|
||||||
name)
|
(propertize
|
||||||
'face (when arrow 'bold)
|
(if width
|
||||||
'help-echo help
|
(truncate-string-to-width name width 0 ?\s t)
|
||||||
'mouse-face (when sortable 'highlight)
|
name)
|
||||||
'keymap (when sortable map)
|
'face (when arrow 'bold)
|
||||||
'field field) " ")))
|
'help-echo help
|
||||||
mu4e-headers-fields)))
|
'mouse-face (when sortable 'highlight)
|
||||||
|
'keymap (when sortable map)
|
||||||
|
'field field) " ")))
|
||||||
|
mu4e-headers-fields))))
|
||||||
|
|
||||||
(defvar mu4e-headers-mode-abbrev-table nil)
|
(defvar mu4e-headers-mode-abbrev-table nil)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue