summaryrefslogtreecommitdiffhomepage
path: root/lib/net
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-08-18 22:17:34 +0100
committerjao <jao@gnu.org>2021-08-18 22:17:34 +0100
commitbfa005de36f4f80f34d622276676a629ca7918f9 (patch)
treef9a6df657924ad34ce27aaddc9c29a3972d705ff /lib/net
parent06bffb1158259f53a99962254e597671a9ec5886 (diff)
downloadelibs-bfa005de36f4f80f34d622276676a629ca7918f9.tar.gz
elibs-bfa005de36f4f80f34d622276676a629ca7918f9.tar.bz2
notmuch: tree folding improvements
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/jao-notmuch.el62
1 files changed, 48 insertions, 14 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index 1bcdaef..ad5657f 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -282,6 +282,13 @@
(defun jao-notmuch--tree-top () (notmuch-tree-get-prop :first))
+(defun jao-notmuch--tree-bottom ()
+ (let ((line-move-ignore-invisible t))
+ (save-excursion
+ (when (zerop (forward-line 1))
+ (or (not (notmuch-tree-get-message-properties))
+ (jao-notmuch--tree-top))))))
+
(defun jao-notmuch-tree-hide-thread ()
(interactive)
(notmuch-tree-thread-top)
@@ -313,15 +320,12 @@
(defun jao-notmuch-tree-hide-all ()
(interactive)
- (goto-char (point-min))
(let ((inhibit-read-only t)
(line-move-ignore-invisible nil))
- (while (not (eobp))
- (forward-line)
- (unless (jao-notmuch--tree-top)
- (put-text-property (point)
- (min (1+ (line-end-position)) (point-max))
- 'invisible t))))
+ (goto-char (point-min))
+ (jao-notmuch-tree-hide-thread)
+ (while (notmuch-tree-next-thread-in-tree)
+ (jao-notmuch-tree-hide-thread)))
(goto-char (point-min)))
(defun jao-notmuch-tree-toggle-thread ()
@@ -345,13 +349,30 @@
m))
(defun jao-notmuch--tree-next (prev thread no-exit)
- (save-excursion (jao-notmuch-tree-hide-thread))
- (let ((line-move-ignore-invisible nil))
- (when thread (notmuch-tree-next-thread prev))
- (unless (jao-notmuch--looking-at-new-p)
- (notmuch-tree-matching-message prev (not no-exit))))
- (save-excursion (jao-notmuch-tree-show-thread))
- (notmuch-tree-show-message nil)
+ (let ((line-move-ignore-invisible t))
+ (cond ((looking-at-p "^End of search results")
+ (unless no-exit
+ (notmuch-tree-close-message-window)
+ (notmuch-tree-quit)))
+ ((jao-notmuch--looking-at-new-p)
+ (save-excursion (jao-notmuch-tree-show-thread))
+ (notmuch-tree-show-message nil))
+ (thread
+ (save-excursion (jao-notmuch-tree-hide-thread))
+ (when (notmuch-tree-next-thread prev)
+ (save-excursion (jao-notmuch-tree-show-thread)))
+ (unless (jao-notmuch--looking-at-new-p)
+ (notmuch-tree-matching-message prev (not no-exit))))
+ ((or (and (not prev) (jao-notmuch--tree-bottom))
+ (and prev (jao-notmuch--tree-top)))
+ (save-excursion (jao-notmuch-tree-hide-thread))
+ (forward-line (if prev -1 1))
+ (jao-notmuch--tree-next prev nil no-exit))
+ ((notmuch-tree-get-message-id)
+ (save-excursion (jao-notmuch-tree-show-thread))
+ (notmuch-tree-matching-message prev (not no-exit)))))
+ (when (notmuch-tree-get-message-id)
+ (notmuch-tree-show-message nil))
(jao-notmuch--tree-update-buffer-name))
(defun jao-notmuch-tree-next (thread &optional no-exit)
@@ -364,6 +385,19 @@
(interactive "P")
(jao-notmuch--tree-next t thread t))
+
+;; Updating the tree window after insertion
+
+(defun jao-notmuch--tree-sentinel (proc &rest _)
+ (when (eq (process-status proc) 'exit)
+ (jao-notmuch--tree-update-buffer-name)
+ (jao-notmuch-tree-hide-all)))
+
+(defun jao-notmuch-tree-setup ()
+ "Activate final display of trees adjustments."
+ (advice-add 'notmuch-tree-process-sentinel :after #'jao-notmuch--tree-sentinel))
+
+
;; Tagging
(defun jao-notmuch-tag-jump-and-next (reverse)