From: jao <jao@gnu.org>
To: notmuch@notmuchmail.org
Cc: jao <jao@gnu.org>
Subject: [PATCH v2] emacs: notmuch-tree: customizable strings for drawing trees
Date: Sat, 21 Aug 2021 03:20:16 +0100 [thread overview]
Message-ID: <20210821022016.524637-2-jao@gnu.org> (raw)
In-Reply-To: <20210821022016.524637-1-jao@gnu.org>
New customizable variable, notmuch-tree-thread-symbols, that allows
tweaking 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
remove pointy arrows.
---
emacs/notmuch-tree.el | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 01a77b71..045b8845 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -74,6 +74,21 @@
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 the bottom of the
+thread. Finally, the last one is 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 +983,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 +1005,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)
--
2.33.0\r
prev parent reply other threads:[~2021-08-21 2:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-21 2:20 emacs: notmuch-tree: customizable strings for drawing (fixes) jao
2021-08-21 2:20 ` jao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210821022016.524637-2-jao@gnu.org \
--to=jao@gnu.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).