aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-06-05 17:13:53 -0400
committerKyle Meyer <kyle@kyleam.com>2021-06-07 00:12:06 -0400
commitb28593830b8f99a24c562a4764e5a0d3bfb25831 (patch)
tree15ea1ad5d599ddb59ca1a2af8ea24f5c8ba39240
parent93000654bf06aac64330c285863d4c3db1b495db (diff)
downloadpiem-b28593830b8f99a24c562a4764e5a0d3bfb25831.tar.gz
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>
-rw-r--r--piem-lei.el25
1 files 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)))