- (let ((buffer (process-buffer proc))
- (found-target nil))
- (if (buffer-live-p buffer)
- (with-current-buffer buffer
- (save-excursion
- (let ((line 0)
- (more t)
- (inhibit-read-only t)
- (string (concat notmuch-search-process-filter-data string)))
- (setq notmuch-search-process-filter-data nil)
- (while more
- (while (and (< line (length string)) (= (elt string line) ?\n))
- (setq line (1+ line)))
- (if (string-match "^\\(thread:[0-9A-Fa-f]*\\) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" string line)
- (let* ((thread-id (match-string 1 string))
- (date (match-string 2 string))
- (count (match-string 3 string))
- (authors (match-string 4 string))
- (subject (match-string 5 string))
- (tags (match-string 6 string))
- (tag-list (if tags (save-match-data (split-string tags)))))
- (goto-char (point-max))
- (if (/= (match-beginning 1) line)
- (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n")))
- (let ((beg (point)))
- (notmuch-search-show-result date count authors
- (notmuch-prettify-subject subject) tags)
- (notmuch-search-color-line beg (point) tag-list)
- (put-text-property beg (point) 'notmuch-search-thread-id thread-id)
- (put-text-property beg (point) 'notmuch-search-authors authors)
- (put-text-property beg (point) 'notmuch-search-subject subject)
- (when (string= thread-id notmuch-search-target-thread)
- (set 'found-target beg)
- (set 'notmuch-search-target-thread "found")))
- (set 'line (match-end 0)))
- (set 'more nil)
- (while (and (< line (length string)) (= (elt string line) ?\n))
- (setq line (1+ line)))
- (if (< line (length string))
- (setq notmuch-search-process-filter-data (substring string line)))
- ))))
- (if found-target
- (goto-char found-target)))
- (delete-process proc))))
-
-(defun notmuch-search-operate-all (&rest actions)
- "Add/remove tags from all matching messages.
-
-This command adds or removes tags from all messages matching the
-current search terms. When called interactively, this command
-will prompt for tags to be added or removed. Tags prefixed with
-'+' will be added and tags prefixed with '-' will be removed.
-
-Each character of the tag name may consist of alphanumeric
-characters as well as `_.+-'.
-"
- (interactive (notmuch-select-tags-with-completion
- "Operations (+add -drop): notmuch tag "
- '("+" "-")))
- ;; Perform some validation
- (when (null actions) (error "No operations given"))
- (mapc (lambda (action)
- (unless (string-match-p "^[-+][-+_.[:word:]]+$" action)
- (error "Action must be of the form `+this_tag' or `-that_tag'")))
- actions)
- (apply 'notmuch-tag notmuch-search-query-string actions))
+ (let ((results-buf (process-buffer proc))
+ (parse-buf (process-get proc 'parse-buf))
+ (inhibit-read-only t)
+ done)
+ (when (buffer-live-p results-buf)
+ (with-current-buffer parse-buf
+ ;; Insert new data
+ (save-excursion
+ (goto-char (point-max))
+ (insert string))
+ (notmuch-sexp-parse-partial-list 'notmuch-search-show-result
+ results-buf)))))
+
+(defun notmuch-search-tag-all (&optional tag-changes)
+ "Add/remove tags from all messages in current search buffer.
+
+See `notmuch-tag' for information on the format of TAG-CHANGES."
+ (interactive)
+ (apply 'notmuch-tag notmuch-search-query-string tag-changes))