mirror of https://github.com/djcb/mu.git
* mu4e: set sort order by clicking on header tabs
This commit is contained in:
parent
958a84d5e3
commit
1e2ed5715a
|
@ -508,6 +508,17 @@ 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)
|
||||||
|
|
||||||
|
;; borrowed from `tabulated-list'
|
||||||
|
(defvar mu4e~glyphless-char-display
|
||||||
|
(let ((table (make-char-table 'glyphless-char-display nil)))
|
||||||
|
(set-char-table-parent table glyphless-char-display)
|
||||||
|
;; Some text terminals can't display the Unicode arrows; be safe.
|
||||||
|
(aset table 9650 (cons nil "^"))
|
||||||
|
(aset table 9660 (cons nil "v"))
|
||||||
|
table)
|
||||||
|
"The `glyphless-char-display' table in mu4e heders buffers.")
|
||||||
|
|
||||||
|
|
||||||
(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
|
(cons
|
||||||
|
@ -517,12 +528,28 @@ after the end of the search results."
|
||||||
(lambda (item)
|
(lambda (item)
|
||||||
(let* ((field (car item)) (width (cdr item))
|
(let* ((field (car item)) (width (cdr item))
|
||||||
(info (cdr (assoc field mu4e-header-info)))
|
(info (cdr (assoc field mu4e-header-info)))
|
||||||
|
(sortable (plist-get info :sortable))
|
||||||
(help (plist-get info :help))
|
(help (plist-get info :help))
|
||||||
;; triangle to mark the sorted-by column
|
;; triangle to mark the sorted-by column
|
||||||
(triangle
|
(triangle
|
||||||
(when (eq (car item) mu4e-headers-sortfield)
|
(when (and sortable (eq (car item) mu4e-headers-sortfield))
|
||||||
(if mu4e-headers-sort-revert "▼" "▲")))
|
(if mu4e-headers-sort-revert "▼ " "▲ ")))
|
||||||
(name (concat triangle (plist-get info :shortname))))
|
(name (concat triangle (plist-get info :shortname)))
|
||||||
|
(map (make-sparse-keymap)))
|
||||||
|
(when sortable
|
||||||
|
(define-key map [header-line mouse-1]
|
||||||
|
(lambda (&optional e)
|
||||||
|
;; getting the field, inspired by `tabulated-list-col-sort'
|
||||||
|
(interactive "e")
|
||||||
|
(let* ((obj (posn-object (event-start e)))
|
||||||
|
(field
|
||||||
|
(and obj (get-text-property 0 'field (car obj)))))
|
||||||
|
(if (eq field mu4e-headers-sortfield)
|
||||||
|
(setq mu4e-headers-sort-revert (not mu4e-headers-sort-revert))
|
||||||
|
(setq mu4e-headers-sortfield field))
|
||||||
|
;;(message "REFRESH! %S %S" obj field)
|
||||||
|
)
|
||||||
|
(mu4e-headers-rerun-search))))
|
||||||
(concat
|
(concat
|
||||||
(propertize
|
(propertize
|
||||||
(if width
|
(if width
|
||||||
|
@ -530,7 +557,9 @@ after the end of the search results."
|
||||||
name)
|
name)
|
||||||
'face 'mu4e-header-title-face
|
'face 'mu4e-header-title-face
|
||||||
'help-echo help
|
'help-echo help
|
||||||
'mouse-face 'highlight) " ")))
|
'mouse-face (when sortable 'highlight)
|
||||||
|
'keymap (when sortable map)
|
||||||
|
'field field) " ")))
|
||||||
mu4e-headers-fields)))
|
mu4e-headers-fields)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -543,13 +572,14 @@ after the end of the search results."
|
||||||
(make-local-variable 'mu4e~headers-proc)
|
(make-local-variable 'mu4e~headers-proc)
|
||||||
(make-local-variable 'mu4e~highlighted-docid)
|
(make-local-variable 'mu4e~highlighted-docid)
|
||||||
(make-local-variable 'global-mode-string)
|
(make-local-variable 'global-mode-string)
|
||||||
(make-local-variable 'hl-line-face)
|
(set (make-local-variable 'hl-line-face) 'mu4e-header-highlight-face)
|
||||||
|
(set (make-local-variable 'glyphless-char-display)
|
||||||
|
mu4e~glyphless-char-display)
|
||||||
|
|
||||||
(setq
|
(setq
|
||||||
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
|
|
||||||
header-line-format (mu4e~header-line-format))
|
header-line-format (mu4e~header-line-format))
|
||||||
|
|
||||||
(mu4e~mark-initialize) ;; initialize the marking subsystem
|
(mu4e~mark-initialize) ;; initialize the marking subsystem
|
||||||
|
@ -689,24 +719,7 @@ non-nill, don't raise an error when the docid is not found."
|
||||||
(unless ignore-missing
|
(unless ignore-missing
|
||||||
(mu4e-error "Cannot find message with docid %S" docid)))))
|
(mu4e-error "Cannot find message with docid %S" docid)))))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(defun mu4e~headers-update-global-mode-string ()
|
|
||||||
"Determine the mode string for the headers buffers (based on the
|
|
||||||
last query, sorting settings."
|
|
||||||
(let* ((cell (find-if
|
|
||||||
(lambda (cell)
|
|
||||||
(eq (cdr cell) mu4e-headers-sortfield))
|
|
||||||
mu4e~headers-sortfield-choices))
|
|
||||||
(optchar (substring (car cell) 0 1)))
|
|
||||||
(setq global-mode-string
|
|
||||||
(concat
|
|
||||||
(propertize mu4e~headers-last-query 'face 'mu4e-title-face)
|
|
||||||
"("
|
|
||||||
optchar
|
|
||||||
(if mu4e-headers-sort-revert "d" "a")
|
|
||||||
(when mu4e-headers-show-threads "T")
|
|
||||||
(when mu4e-headers-full-search "F")
|
|
||||||
")"))))
|
|
||||||
|
|
||||||
(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
|
||||||
|
@ -725,8 +738,8 @@ the query history stack."
|
||||||
(setq
|
(setq
|
||||||
mu4e~headers-buffer buf
|
mu4e~headers-buffer buf
|
||||||
mode-name "mu4e-headers"
|
mode-name "mu4e-headers"
|
||||||
mu4e~headers-last-query expr)
|
mu4e~headers-last-query expr
|
||||||
(mu4e~headers-update-global-mode-string))
|
global-mode-string (propertize mu4e~headers-last-query 'face 'mu4e-title-face)))
|
||||||
(switch-to-buffer buf)
|
(switch-to-buffer buf)
|
||||||
(mu4e~proc-find
|
(mu4e~proc-find
|
||||||
(replace-regexp-in-string "\"" "\\\\\"" expr) ;; escape "\"
|
(replace-regexp-in-string "\"" "\\\\\"" expr) ;; escape "\"
|
||||||
|
|
|
@ -346,7 +346,8 @@ headers)."
|
||||||
'( (:attachments .
|
'( (:attachments .
|
||||||
( :name "Attachments"
|
( :name "Attachments"
|
||||||
:shortname "Atts"
|
:shortname "Atts"
|
||||||
:help "Message attachments"))
|
:help "Message attachments"
|
||||||
|
:sortable nil))
|
||||||
(:bcc .
|
(:bcc .
|
||||||
( :name "Bcc"
|
( :name "Bcc"
|
||||||
:shortname "Bcc"
|
:shortname "Bcc"
|
||||||
|
@ -366,7 +367,7 @@ headers)."
|
||||||
( :name "Flags"
|
( :name "Flags"
|
||||||
:shortname "Flgs"
|
:shortname "Flgs"
|
||||||
:help "Flags for the message"
|
:help "Flags for the message"
|
||||||
:sortable t))
|
:sortable nil))
|
||||||
(:from .
|
(:from .
|
||||||
( :name "From"
|
( :name "From"
|
||||||
:shortname "From"
|
:shortname "From"
|
||||||
|
@ -377,7 +378,7 @@ headers)."
|
||||||
:shortname "From/To"
|
:shortname "From/To"
|
||||||
:help "Sender of the message if it's not me; otherwise
|
:help "Sender of the message if it's not me; otherwise
|
||||||
the recipient"
|
the recipient"
|
||||||
:sortable t))
|
:sortable nil))
|
||||||
(:maildir .
|
(:maildir .
|
||||||
( :name "Maildir"
|
( :name "Maildir"
|
||||||
:shortname "Maildir"
|
:shortname "Maildir"
|
||||||
|
|
Loading…
Reference in New Issue