summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-08-21 02:46:18 +0100
committerjao <jao@gnu.org>2021-08-23 00:53:08 +0100
commit0bc848869b70e504bcdc0f6dacd43bc8dc757608 (patch)
treeed845853de07ffa940be2fad56fd923fa30c0659
parent84347ffcad24b48390c622e5a96c31c97c094daa (diff)
downloadnotmuch-0bc848869b70e504bcdc0f6dacd43bc8dc757608.tar.gz
notmuch-0bc848869b70e504bcdc0f6dacd43bc8dc757608.tar.bz2
emacs: notmuch-tree: customizable strings for drawing trees
New customizable variable, notmuch-tree-thread-symbols, that allows tweaking of how trees in a forest are represented. For instance, one can now choose to use an hyphen rather than a white space as a prefix, or replace the character(s) used to draw arrows.
-rw-r--r--emacs/notmuch-tree.el36
1 files changed, 26 insertions, 10 deletions
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 2f508128..a1dfa7b1 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -74,6 +74,22 @@
notmuch-unthreaded-show-out
notmuch-tree-show-out))
+(defcustom notmuch-tree-thread-symbols '(" " "─" "┬" "│" "├" "╰" "►")
+ "List of strings used to draw trees in notmuch tree results.
+The first element is used at the top of the tree, followed by the
+second if it has no children or the third if it does. The fourth
+is a bar connecting with a response down the list skipping the
+current one, while the fifth marks the current message as a reply
+to the previous. The sixth string is used at the bottom of
+threads. Finally, the last string in the list is used as a
+pointer to every message.
+
+Common customizations include setting the first element of the
+list to \"-\", to see equal-length prefixes, or the last to an
+empty string or to a different kind of arrow point."
+ :type '(list string)
+ :group 'notmuch-tree)
+
(defcustom notmuch-tree-result-format
`(("date" . "%12s ")
("authors" . "%-20s")
@@ -968,20 +984,20 @@ message together with all its descendents."
(replies (cadr tree)))
(cond
((and (< 0 depth) (not last))
- (push "├" tree-status))
+ (push (elt notmuch-tree-thread-symbols 4) tree-status))
((and (< 0 depth) last)
- (push "╰" tree-status))
+ (push (elt notmuch-tree-thread-symbols 5) tree-status))
((and (eq 0 depth) first last)
- ;; Choice between these two variants is a matter of taste.
- ;; (push "─" tree-status))
- (push " " tree-status))
+ (push (elt notmuch-tree-thread-symbols 0) tree-status))
((and (eq 0 depth) first (not last))
- (push "┬" tree-status))
+ (push (elt notmuch-tree-thread-symbols 2) tree-status))
((and (eq 0 depth) (not first) last)
- (push "╰" tree-status))
+ (push (elt notmuch-tree-thread-symbols 5) tree-status))
((and (eq 0 depth) (not first) (not last))
- (push "├" tree-status)))
- (push (concat (if replies "┬" "─") "►") tree-status)
+ (push (elt notmuch-tree-thread-symbols 4) tree-status)))
+ (push (concat (elt notmuch-tree-thread-symbols (if replies 2 1))
+ (elt notmuch-tree-thread-symbols 6))
+ tree-status)
(setq msg (plist-put msg :first (and first (eq 0 depth))))
(setq msg (plist-put msg :tree-status tree-status))
(setq msg (plist-put msg :orig-tags (plist-get msg :tags)))
@@ -990,7 +1006,7 @@ message together with all its descendents."
(pop tree-status)
(if last
(push " " tree-status)
- (push "│" tree-status))
+ (push (elt notmuch-tree-thread-symbols 3) tree-status))
(notmuch-tree-insert-thread replies (1+ depth) tree-status)))
(defun notmuch-tree-insert-thread (thread depth tree-status)