[PATCH v2 0/7] emacs: JSON-based search cleanups

Austin Clements amdragon at MIT.EDU
Fri Jul 13 20:43:19 PDT 2012


This version updates the docstrings for notmuch-search-update-result
and notmuch-search-show-result and fixes the scrolling artifact in
notmuch-search-update-result.  I also updated the commit message of
patch 7 to mention that it changes the behavior of
notmuch-search-previous-thread.

The diff against v1 is below.

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2ece97d..7302fa7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -583,10 +583,12 @@ This function advances the next thread when finished."
   (notmuch-search-next-thread))
 
 (defun notmuch-search-update-result (result &optional pos)
-  "Update the result object of the current thread and redraw it."
+  "Replace the result object of the thread at POS (or point) by
+RESULT and redraw it."
   (let ((start (notmuch-search-result-beginning pos))
 	(end (notmuch-search-result-end pos))
 	(init-point (point))
+	(init-start (window-start))
 	(inhibit-read-only t))
     ;; Delete the current thread
     (delete-region start end)
@@ -603,7 +605,9 @@ This function advances the next thread when finished."
 	     (new-point (if (= init-point end)
 			    new-end
 			  (min init-point (- new-end 1)))))
-	(insert-before-markers (delete-and-extract-region start new-point))))))
+	(insert-before-markers (delete-and-extract-region start new-point))))
+    ;; We also may have shifted the window scroll.  Fix it.
+    (set-window-start (selected-window) init-start)))
 
 (defun notmuch-search-process-sentinel (proc msg)
   "Add a message to let user know when \"notmuch search\" exits"
@@ -766,6 +770,7 @@ non-authors is found, assume that all of the authors match."
 			  'face 'notmuch-tag-face))))))
 
 (defun notmuch-search-show-result (result &optional pos)
+  "Insert RESULT at POS or the end of the buffer if POS is null."
   ;; Ignore excluded matches
   (unless (= (plist-get result :matched) 0)
     (let ((beg (or pos (point-max))))



More information about the notmuch mailing list