(notmuch-show-next-open-message))
)))
-(defvar notmuch-search-authors-width 40
+(defvar notmuch-search-authors-width 20
"Number of columns to use to display authors in a notmuch-search buffer.")
(defvar notmuch-search-mode-map
(defvar notmuch-search-query-string)
(defvar notmuch-search-target-thread)
-(defvar notmuch-search-target-position)
+(defvar notmuch-search-target-line)
(defvar notmuch-search-oldest-first t
"Show the oldest mail first in the search-mode")
(make-local-variable 'notmuch-search-query-string)
(make-local-variable 'notmuch-search-oldest-first)
(make-local-variable 'notmuch-search-target-thread)
- (make-local-variable 'notmuch-search-target-position)
+ (make-local-variable 'notmuch-search-target-line)
(set (make-local-variable 'scroll-preserve-screen-position) t)
(add-to-invisibility-spec 'notmuch-search)
(use-local-map notmuch-search-mode-map)
(insert (format " (process returned %d)" exit-status)))
(insert "\n")
(if (and atbob
- notmuch-search-target-thread)
+ (not (string= notmuch-search-target-thread "found")))
(set 'never-found-target-thread t))))))
- (if never-found-target-thread
- (goto-char notmuch-search-target-position)))))))
+ (if (and never-found-target-thread
+ notmuch-search-target-line)
+ (goto-line notmuch-search-target-line)))))))
(defun notmuch-search-process-filter (proc string)
"Process and filter the output of \"notmuch search\""
(authors-length (length authors))
(subject (match-string 5 string))
(tags (match-string 6 string)))
- (if (> authors-length 40)
- (set 'authors (concat (substring authors 0 (- 40 3)) "...")))
+ (if (> authors-length notmuch-search-authors-width)
+ (set 'authors (concat (substring authors 0 (- notmuch-search-authors-width 3)) "...")))
(goto-char (point-max))
- (let ((beg (point-marker)))
- (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
+ (let ((beg (point-marker))
+ (format-string (format "%%s %%-7s %%-%ds %%s (%%s)\n" notmuch-search-authors-width)))
+ (insert (format format-string date count authors subject tags))
(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
(put-text-property beg (point-marker) 'notmuch-search-authors authors)
(put-text-property beg (point-marker) 'notmuch-search-subject subject)
- (if (and notmuch-search-target-thread
- (string= thread-id notmuch-search-target-thread))
+ (if (string= thread-id notmuch-search-target-thread)
(progn
(set 'found-target beg)
- (set 'notmuch-search-target-thread nil))))
+ (set 'notmuch-search-target-thread "found"))))
(set 'line (match-end 0)))
(set 'more nil)))))
(if found-target
(append action-split (list notmuch-search-query-string) nil))))
;;;###autoload
-(defun notmuch-search (query &optional oldest-first target-thread target-position)
+(defun notmuch-search (query &optional oldest-first target-thread target-line)
"Run \"notmuch search\" with the given query string and display results.
The optional parameters are used as follows:
oldest-first: A Boolean controlling the sort order of returned threads
target-thread: A thread ID (with the thread: prefix) that will be made
current if it appears in the search results.
- saved-position: If the search results complete, and the target thread is
- not found in the results, and the point is still at the
- beginning of the buffer, then the point will be moved to
- the saved position.
-"
+ target-line: The line number to move to if the target thread does not
+ appear in the search results."
(interactive "sNotmuch search: ")
(let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))
(switch-to-buffer buffer)
(set 'notmuch-search-query-string query)
(set 'notmuch-search-oldest-first oldest-first)
(set 'notmuch-search-target-thread target-thread)
- (set 'notmuch-search-target-position target-position)
+ (set 'notmuch-search-target-line target-line)
(let ((proc (get-buffer-process (current-buffer)))
(inhibit-read-only t))
(if proc
thread. Otherwise, point will be moved to attempt to be in the
same relative position within the new buffer."
(interactive)
- (let ((here (point))
+ (let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
- (thread (notmuch-search-find-thread-id))
+ (target-thread (notmuch-search-find-thread-id))
(query notmuch-search-query-string))
(kill-this-buffer)
- (notmuch-search query oldest-first thread here)
+ (notmuch-search query oldest-first target-thread target-line)
(goto-char (point-min))
))