X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=contrib%2Fnotmuch-pick%2Fnotmuch-pick.el;h=7f5f729a55aee73f5d352c538c291d405ac2f830;hp=29815083c77c8717f9a8b5f8ebe50c558c7bd114;hb=1fd1e57d936bd39ad0ebd93b0bf62bfedf9f80bc;hpb=8c33fde83e244d0d1fa37666795bb0dc482299cf diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el index 29815083..7f5f729a 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -187,9 +187,6 @@ if the user has loaded a different buffer in that window.") (make-variable-buffer-local 'notmuch-pick-message-buffer) (put 'notmuch-pick-message-buffer 'permanent-local t) -(defvar notmuch-pick-process-state nil - "Parsing state of the search process filter.") - (defvar notmuch-pick-mode-map (let ((map (make-sparse-keymap))) (define-key map [mouse-1] 'notmuch-pick-show-message) @@ -217,6 +214,11 @@ if the user has loaded a different buffer in that window.") (fset 'notmuch-pick-mode-map notmuch-pick-mode-map) (defun notmuch-pick-setup-show-out () + "Set up the keymap for showing a thread + +This uses the value of the defcustom notmuch-pick-show-out to +decide whether to show a message in the message pane or in the +whole window." (let ((map notmuch-pick-mode-map)) (if notmuch-pick-show-out (progn @@ -274,6 +276,11 @@ Some useful entries are: (notmuch-pick-get-prop :match)) (defun notmuch-pick-refresh-result () + "Redisplay the current message line. + +This redisplays the current line based on the messages +properties (as they are now). This is used when tags are +updated." (let ((init-point (point)) (end (line-end-position)) (msg (notmuch-pick-get-message-properties)) @@ -377,6 +384,7 @@ Does NOT change the database." t)) (defun notmuch-pick-message-window-kill-hook () + "Close the message pane when exiting the show buffer." (let ((buffer (current-buffer))) (when (and (window-live-p notmuch-pick-message-window) (eq (window-buffer notmuch-pick-message-window) buffer)) @@ -675,7 +683,10 @@ unchanged ADDRESS if parsing fails." (notmuch-pick-show-message))))) (defun notmuch-pick-insert-tree (tree depth tree-status first last) - "Insert the message tree TREE at depth DEPTH in the current thread." + "Insert the message tree TREE at depth DEPTH in the current thread. + +A message tree is another name for a single sub-thread: i.e., a +message together with all its descendents." (let ((msg (car tree)) (replies (cadr tree))) @@ -706,7 +717,7 @@ unchanged ADDRESS if parsing fails." (notmuch-pick-insert-thread replies (1+ depth) tree-status))) (defun notmuch-pick-insert-thread (thread depth tree-status) - "Insert the thread THREAD at depth DEPTH >= 1 in the current forest." + "Insert the collection of sibling sub-threads THREAD at depth DEPTH in the current forest." (let ((n (length thread))) (loop for tree in thread for count from 1 to n @@ -714,12 +725,17 @@ unchanged ADDRESS if parsing fails." do (notmuch-pick-insert-tree tree depth tree-status (eq count 1) (eq count n))))) (defun notmuch-pick-insert-forest-thread (forest-thread) + "Insert a single complete thread." (let (tree-status) ;; Reset at the start of each main thread. (setq notmuch-pick-previous-subject nil) (notmuch-pick-insert-thread forest-thread 0 tree-status))) (defun notmuch-pick-insert-forest (forest) + "Insert a forest of threads. + +This function inserts a collection of several complete threads as +passed to it by notmuch-pick-process-filter." (mapc 'notmuch-pick-insert-forest-thread forest)) (defun notmuch-pick-mode () @@ -767,15 +783,6 @@ Complete list of currently available key bindings: (insert (format " (process returned %d)" exit-status))) (insert "\n"))))))))) - -(defun notmuch-pick-show-error (string &rest objects) - (save-excursion - (goto-char (point-max)) - (insert "Error: Unexpected output from notmuch search:\n") - (insert (apply #'format string objects)) - (insert "\n"))) - - (defun notmuch-pick-process-filter (proc string) "Process and filter the output of \"notmuch show\" (for pick)" (let ((results-buf (process-buffer proc)) @@ -810,16 +817,15 @@ Complete list of currently available key bindings: (if (equal (car (process-lines notmuch-command "count" search-args)) "0") (setq search-args basic-query)) (if notmuch-pick-asynchronous-parser - (let ((proc (start-process - "notmuch-pick" buffer - notmuch-command "show" "--body=false" "--format=sexp" + (let ((proc (notmuch-start-notmuch + "notmuch-pick" buffer #'notmuch-pick-process-sentinel + "show" "--body=false" "--format=sexp" message-arg search-args)) ;; Use a scratch buffer to accumulate partial output. ;; This buffer will be killed by the sentinel, which ;; should be called no matter how the process dies. (parse-buf (generate-new-buffer " *notmuch pick parse*"))) (process-put proc 'parse-buf parse-buf) - (set-process-sentinel proc 'notmuch-pick-process-sentinel) (set-process-filter proc 'notmuch-pick-process-filter) (set-process-query-on-exit-flag proc nil)) (progn