contrib: pick: fix refresh result

The function notmuch-pick-refresh-result (used to update tag changes)
was not quite correct: sometimes it got the choice between the subject
and " ..." wrong. This was always true but the new code often calls
this (when opening a message in the message pane to remove the unread
tag) while the async pick process is still running and this caused
mistakes which made the tests fail.

Thus we store the previous subject with the message.
This commit is contained in:
Mark Walters 2013-06-30 09:55:12 +01:00 committed by David Bremner
parent a9dbcbb00c
commit eb26cd1fba

View file

@ -264,8 +264,15 @@ Some useful entries are:
(msg (notmuch-pick-get-message-properties)) (msg (notmuch-pick-get-message-properties))
(inhibit-read-only t)) (inhibit-read-only t))
(beginning-of-line) (beginning-of-line)
(delete-region (point) (1+ (line-end-position))) ;; This is a little tricky: we override
(notmuch-pick-insert-msg msg) ;; notmuch-pick-previous-subject to get the decision between
;; ... and a subject right and it stops notmuch-pick-insert-msg
;; from overwriting the buffer local copy of
;; notmuch-pick-previous-subject if this is called while the
;; buffer is displaying.
(let ((notmuch-pick-previous-subject (notmuch-pick-get-prop :previous-subject)))
(delete-region (point) (1+ (line-end-position)))
(notmuch-pick-insert-msg msg))
(let ((new-end (line-end-position))) (let ((new-end (line-end-position)))
(goto-char (if (= init-point end) (goto-char (if (= init-point end)
new-end new-end
@ -628,10 +635,14 @@ unchanged ADDRESS if parsing fails."
(defun notmuch-pick-insert-msg (msg) (defun notmuch-pick-insert-msg (msg)
"Insert the message MSG according to notmuch-pick-result-format" "Insert the message MSG according to notmuch-pick-result-format"
(dolist (spec notmuch-pick-result-format) ;; We need to save the previous subject as it will get overwritten
(notmuch-pick-insert-field (car spec) (cdr spec) msg)) ;; by the insert-field calls.
(notmuch-pick-set-message-properties msg) (let ((previous-subject notmuch-pick-previous-subject))
(insert "\n")) (dolist (spec notmuch-pick-result-format)
(notmuch-pick-insert-field (car spec) (cdr spec) msg))
(notmuch-pick-set-message-properties msg)
(notmuch-pick-set-prop :previous-subject previous-subject)
(insert "\n")))
(defun notmuch-pick-goto-and-insert-msg (msg) (defun notmuch-pick-goto-and-insert-msg (msg)
"Insert msg at the end of the buffer. Move point to msg if it is the target" "Insert msg at the end of the buffer. Move point to msg if it is the target"