X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=ab00454357ef12f26b2f92b9705f30093d753a1f;hp=6c0bc1bcae0ed9e3f423e9ccdb860484b4e18111;hb=fd80a9cac1b773d50acef42522ef767c1a2d44b7;hpb=5e26d14536398210869a920f8e7bb84fd2ace6aa diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 6c0bc1bc..ab004543 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -153,7 +153,7 @@ there will be called at other points of notmuch execution." (defvar notmuch-search-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map notmuch-common-keymap) - (define-key map "x" 'notmuch-kill-this-buffer) + (define-key map "x" 'notmuch-bury-or-kill-this-buffer) (define-key map (kbd "") 'notmuch-search-scroll-down) (define-key map "b" 'notmuch-search-scroll-down) (define-key map " " 'notmuch-search-scroll-up) @@ -428,14 +428,16 @@ matched and unmatched messages in the current thread." "Return the stable query for the current region. If ONLY-MATCHED is non-nil, include only matched messages. If it -is nil, include both matched and unmatched messages." +is nil, include both matched and unmatched messages. If there are +no messages in the region then return nil." (let ((query-list nil) (all (not only-matched))) (dolist (queries (notmuch-search-properties-in-region :query beg end)) (when (first queries) (push (first queries) query-list)) (when (and all (second queries)) (push (second queries) query-list))) - (concat "(" (mapconcat 'identity query-list ") or (") ")"))) + (when query-list + (concat "(" (mapconcat 'identity query-list ") or (") ")")))) (defun notmuch-search-find-authors () "Return the authors for the current thread" @@ -578,7 +580,8 @@ This function advances the next thread when finished." (when notmuch-archive-tags (notmuch-search-tag (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end)) - (notmuch-search-next-thread)) + (when (eq beg end) + (notmuch-search-next-thread))) (defun notmuch-search-update-result (result &optional pos) "Replace the result object of the thread at POS (or point) by @@ -647,12 +650,12 @@ of the result." Here is an example of how to color search results based on tags. (the following text would be placed in your ~/.emacs file): - (setq notmuch-search-line-faces '((\"deleted\" . (:foreground \"red\" - :background \"blue\")) - (\"unread\" . (:foreground \"green\")))) + (setq notmuch-search-line-faces '((\"unread\" . (:foreground \"green\")) + (\"deleted\" . (:foreground \"red\" + :background \"blue\")))) -The attributes defined for matching tags are merged, with later -attributes overriding earlier. A message having both \"deleted\" +The attributes defined for matching tags are merged, with earlier +attributes overriding later. A message having both \"deleted\" and \"unread\" tags with the above settings would have a green foreground and blue background." :type '(alist :key-type (string) :value-type (custom-face-edit)) @@ -855,11 +858,15 @@ PROMPT is the string to prompt with." (lexical-let ((completions (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:" - "subject:" "attachment:") + "subject:" "attachment:" "mimetype:") (mapcar (lambda (tag) (concat "tag:" (notmuch-escape-boolean-term tag))) (process-lines notmuch-command "search" "--output=tags" "*"))))) (let ((keymap (copy-keymap minibuffer-local-map)) + (current-query (case major-mode + (notmuch-search-mode (notmuch-search-get-query)) + (notmuch-show-mode (notmuch-show-get-query)) + (notmuch-tree-mode (notmuch-tree-get-query)))) (minibuffer-completion-table (completion-table-dynamic (lambda (string) @@ -877,7 +884,11 @@ PROMPT is the string to prompt with." (define-key keymap (kbd "TAB") 'minibuffer-complete) (let ((history-delete-duplicates t)) (read-from-minibuffer prompt nil keymap nil - 'notmuch-search-history nil nil))))) + 'notmuch-search-history current-query nil))))) + +(defun notmuch-search-get-query () + "Return the current query in this search buffer" + notmuch-search-query-string) ;;;###autoload (put 'notmuch-search 'notmuch-doc "Search for messages.") @@ -950,7 +961,7 @@ same relative position within the new buffer." (oldest-first notmuch-search-oldest-first) (target-thread (notmuch-search-find-thread-id 'bare)) (query notmuch-search-query-string)) - (notmuch-kill-this-buffer) + (notmuch-bury-or-kill-this-buffer) (notmuch-search query oldest-first target-thread target-line) (goto-char (point-min))))