mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
contrib: pick: allow recursive message field formats
Previously, the message format was fixed: each part had to be a certain width and either left or right justified. This allows the user to specify that two parts can be variable width but that combined they should be some fixed width. We do this by allowing the user to set as a "field" a list of the normal result-format form which is formatted and then itself inserted according to the format string specified. This means all existing formats work but allows more general things too. This will be used in the next patch to allow the user to specify where the tree box graphics are drawn but allow, e.g., the total width of the tree box graphics and subject to be specified.
This commit is contained in:
parent
6c8116c05b
commit
6ae591911c
1 changed files with 12 additions and 2 deletions
|
@ -675,6 +675,10 @@ unchanged ADDRESS if parsing fails."
|
||||||
(match (plist-get msg :match))
|
(match (plist-get msg :match))
|
||||||
formatted-field)
|
formatted-field)
|
||||||
(cond
|
(cond
|
||||||
|
((listp field)
|
||||||
|
(setq formatted-field
|
||||||
|
(format format-string (notmuch-pick-format-field-list field msg))))
|
||||||
|
|
||||||
((string-equal field "date")
|
((string-equal field "date")
|
||||||
(let ((face (if match
|
(let ((face (if match
|
||||||
'notmuch-pick-match-date-face
|
'notmuch-pick-match-date-face
|
||||||
|
@ -722,13 +726,19 @@ unchanged ADDRESS if parsing fails."
|
||||||
'face face)))))
|
'face face)))))
|
||||||
formatted-field))
|
formatted-field))
|
||||||
|
|
||||||
|
(defun notmuch-pick-format-field-list (field-list msg)
|
||||||
|
"Format fields of MSG according to FIELD-LIST and return string"
|
||||||
|
(let (result-string)
|
||||||
|
(dolist (spec field-list result-string)
|
||||||
|
(let ((field-string (notmuch-pick-format-field (car spec) (cdr spec) msg)))
|
||||||
|
(setq result-string (concat result-string field-string))))))
|
||||||
|
|
||||||
(defun notmuch-pick-insert-msg (msg)
|
(defun notmuch-pick-insert-msg (msg)
|
||||||
"Insert the message MSG according to notmuch-pick-result-format"
|
"Insert the message MSG according to notmuch-pick-result-format"
|
||||||
;; We need to save the previous subject as it will get overwritten
|
;; We need to save the previous subject as it will get overwritten
|
||||||
;; by the insert-field calls.
|
;; by the insert-field calls.
|
||||||
(let ((previous-subject notmuch-pick-previous-subject))
|
(let ((previous-subject notmuch-pick-previous-subject))
|
||||||
(dolist (spec notmuch-pick-result-format)
|
(insert (notmuch-pick-format-field-list notmuch-pick-result-format msg))
|
||||||
(insert (notmuch-pick-format-field (car spec) (cdr spec) msg)))
|
|
||||||
(notmuch-pick-set-message-properties msg)
|
(notmuch-pick-set-message-properties msg)
|
||||||
(notmuch-pick-set-prop :previous-subject previous-subject)
|
(notmuch-pick-set-prop :previous-subject previous-subject)
|
||||||
(insert "\n")))
|
(insert "\n")))
|
||||||
|
|
Loading…
Reference in a new issue