* [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees
@ 2021-08-31 1:21 jao
2021-08-31 14:17 ` David Bremner
0 siblings, 1 reply; 4+ messages in thread
From: jao @ 2021-08-31 1:21 UTC (permalink / raw)
To: notmuch; +Cc: jao
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.
---
emacs/notmuch-tree.el | 44 +++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b48a132d..485e89a8 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -74,6 +74,30 @@
notmuch-unthreaded-show-out
notmuch-tree-show-out))
+(defcustom notmuch-tree-thread-symbols
+ '((prefix . " ")
+ (top . "─")
+ (top-tee . "┬")
+ (vertical . "│")
+ (vertical-tee . "├")
+ (bottom . "╰")
+ (arrow . "►"))
+ "Strings used to draw trees in notmuch tree results.
+Symbol keys denote where the corresponding string value is used:
+`prefix' is used at the top of the tree, followed by `top' if it
+has no children or `top-tee' if it does; `vertical' is a bar
+connecting with a response down the list skipping the current
+one, while `vertical-tee' marks the current message as a reply to
+the previous one; `bottom' is used at the bottom of threads.
+Finally, the `arrrow' string in the list is used as a pointer to
+every message.
+
+Common customizations include setting `prefix' to \"-\", to see
+equal-length prefixes, and `arrow' to an empty string or to a
+different kind of arrow point."
+ :type '(alist :key-type symbol :value-type string)
+ :group 'notmuch-tree)
+
(defcustom notmuch-tree-result-format
`(("date" . "%12s ")
("authors" . "%-20s")
@@ -980,20 +1004,20 @@ message together with all its descendents."
(replies (cadr tree)))
(cond
((and (< 0 depth) (not last))
- (push "├" tree-status))
+ (push (alist-get 'vertical-tee notmuch-tree-thread-symbols) tree-status))
((and (< 0 depth) last)
- (push "╰" tree-status))
+ (push (alist-get 'bottom notmuch-tree-thread-symbols) 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 (alist-get 'prefix notmuch-tree-thread-symbols) tree-status))
((and (eq 0 depth) first (not last))
- (push "┬" tree-status))
+ (push (alist-get 'top-tee notmuch-tree-thread-symbols) tree-status))
((and (eq 0 depth) (not first) last)
- (push "╰" tree-status))
+ (push (alist-get 'bottom notmuch-tree-thread-symbols) tree-status))
((and (eq 0 depth) (not first) (not last))
- (push "├" tree-status)))
- (push (concat (if replies "┬" "─") "►") tree-status)
+ (push (alist-get 'vertical-tee notmuch-tree-thread-symbols) tree-status)))
+ (push (concat (alist-get (if replies 'top-tee 'top) notmuch-tree-thread-symbols)
+ (alist-get 'arrow notmuch-tree-thread-symbols))
+ 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)))
@@ -1002,7 +1026,7 @@ message together with all its descendents."
(pop tree-status)
(if last
(push " " tree-status)
- (push "│" tree-status))
+ (push (alist-get 'vertical 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees
2021-08-31 1:21 [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees jao
@ 2021-08-31 14:17 ` David Bremner
2021-08-31 18:28 ` Jose Antonio Ortega Ruiz
0 siblings, 1 reply; 4+ messages in thread
From: David Bremner @ 2021-08-31 14:17 UTC (permalink / raw)
To: jao, notmuch; +Cc: jao
jao <jao@gnu.org> writes:
> - (push "│" tree-status))
> + (push (alist-get 'vertical notmuch-tree-thread-symbols 3) tree-status))
That 3 looks like a typo. If nothing else turns up, I can just delete
it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees
2021-08-31 14:17 ` David Bremner
@ 2021-08-31 18:28 ` Jose Antonio Ortega Ruiz
2021-09-20 23:44 ` David Bremner
0 siblings, 1 reply; 4+ messages in thread
From: Jose Antonio Ortega Ruiz @ 2021-08-31 18:28 UTC (permalink / raw)
To: David Bremner, notmuch
On Tue, Aug 31 2021, David Bremner wrote:
> jao <jao@gnu.org> writes:
>
>> - (push "│" tree-status))
>> + (push (alist-get 'vertical notmuch-tree-thread-symbols 3) tree-status))
>
> That 3 looks like a typo. If nothing else turns up, I can just delete
> it.
indeed. it's a leftover of my previous implementation. please go
ahead. thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees
2021-08-31 18:28 ` Jose Antonio Ortega Ruiz
@ 2021-09-20 23:44 ` David Bremner
0 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2021-09-20 23:44 UTC (permalink / raw)
To: Jose Antonio Ortega Ruiz, notmuch
Jose Antonio Ortega Ruiz <jao@gnu.org> writes:
> On Tue, Aug 31 2021, David Bremner wrote:
>
>> jao <jao@gnu.org> writes:
>>
>>> - (push "│" tree-status))
>>> + (push (alist-get 'vertical notmuch-tree-thread-symbols 3) tree-status))
>>
>> That 3 looks like a typo. If nothing else turns up, I can just delete
>> it.
>
> indeed. it's a leftover of my previous implementation. please go
> ahead. thanks!
Done, and applied to master.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-20 23:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 1:21 [PATCH v4] emacs: notmuch-tree: customizable strings for drawing trees jao
2021-08-31 14:17 ` David Bremner
2021-08-31 18:28 ` Jose Antonio Ortega Ruiz
2021-09-20 23:44 ` David Bremner
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).