summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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)