From b28593830b8f99a24c562a4764e5a0d3bfb25831 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 5 Jun 2021 17:13:53 -0400 Subject: piem-lei-query-thread: Drop repeated subjects public-inbox's web interface suppresses a message's subject when it matches the previous lines [*]. Teach piem-lei-query-thread to do the same to make it easier to spot subject shifts and identify subthreads. [*] notmuch-tree-mode does similar, displaying "..." instead. Message-Id: <20210605211402.20304-10-kyle@kyleam.com> --- piem-lei.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/piem-lei.el b/piem-lei.el index 74bf357..43ab01e 100644 --- a/piem-lei.el +++ b/piem-lei.el @@ -370,7 +370,7 @@ Return a list with a `piem-lei-msg' object for each root." (let* ((records (piem-lei-query--slurp (list "--threads" (concat "m:" mid)))) (msgs (piem-lei-query--thread records)) - depths pt-final) + depths pt-final subject-prev) (with-current-buffer (get-buffer-create "*lei-thread*") (let ((inhibit-read-only t)) (erase-buffer) @@ -384,25 +384,34 @@ Return a list with a `piem-lei-msg' object for each root." (setq msgs (append children msgs))) (push (cons msg depth) depths) (if (not (piem-lei-msg-ghost msg)) - (let ((data (cdr (assoc mid-msg records)))) + (let* ((data (cdr (assoc mid-msg records))) + (subject (let ((case-fold-search t)) + (replace-regexp-in-string + (rx string-start "re:" (one-or-more space)) + "" + (string-trim (cdr (assq 's data))))))) (insert (piem-lei-query--format-date data) " " (piem-lei-query--format-thread-marker depth) (let ((from (car (cdr (assq 'f data))))) (propertize (or (car from) (cadr from)) 'font-lock-face 'piem-lei-query-from)) - (concat " " - (propertize (cdr (assq 's data)) - 'font-lock-face - 'piem-lei-query-subject))) + (if (equal subject subject-prev) + "" + (concat " " + (propertize subject + 'font-lock-face + 'piem-lei-query-subject)))) (add-text-properties (line-beginning-position) (line-end-position) - (list 'piem-lei-query-result data))) + (list 'piem-lei-query-result data)) + (setq subject-prev subject)) (insert (make-string 17 ?\s) ; Date alignment. (piem-lei-query--format-thread-marker depth) (propertize (concat " <" mid-msg ">") 'font-lock-face - 'piem-lei-query-thread-ghost))) + 'piem-lei-query-thread-ghost)) + (setq subject-prev nil)) (when (equal mid-msg mid) (setq pt-final (line-beginning-position))) (insert ?\n))) -- cgit v1.2.3