X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=3311fe8b2c9b8b980a93425dacfb8f65a5f9fc90;hp=92a86cf247ceb5ff6f52c928b8a84deca54ee08c;hb=5b0bf70faa57651993b5e80a3a25467c12e5f9cf;hpb=eead2382774f42c3531f7abe6f06cbe88fe4492a diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 92a86cf2..3311fe8b 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -204,7 +204,7 @@ For a mouse binding, return nil." (define-key map "p" 'notmuch-search-previous-thread) (define-key map "n" 'notmuch-search-next-thread) (define-key map "r" 'notmuch-search-reply-to-thread) - (define-key map "m" 'notmuch-mua-mail) + (define-key map "m" 'notmuch-mua-new-mail) (define-key map "s" 'notmuch-search) (define-key map "o" 'notmuch-search-toggle-order) (define-key map "c" 'notmuch-search-stash-map) @@ -218,6 +218,7 @@ For a mouse binding, return nil." (define-key map "-" 'notmuch-search-remove-tag) (define-key map "+" 'notmuch-search-add-tag) (define-key map (kbd "RET") 'notmuch-search-show-thread) + (define-key map (kbd "M-RET") 'notmuch-search-show-thread-crypto-switch) map) "Keymap for \"notmuch search\" buffers.") (fset 'notmuch-search-mode-map notmuch-search-mode-map) @@ -417,7 +418,11 @@ Complete list of currently available key bindings: "Return a list of authors for the current region" (notmuch-search-properties-in-region 'notmuch-search-subject beg end)) -(defun notmuch-search-show-thread () +(defun notmuch-search-show-thread-crypto-switch () + (interactive) + (notmuch-search-show-thread t)) + +(defun notmuch-search-show-thread (&optional crypto-switch) "Display the currently selected thread." (interactive) (let ((thread-id (notmuch-search-find-thread-id)) @@ -433,14 +438,15 @@ Complete list of currently available key bindings: (concat "*" (truncate-string-to-width subject 32 nil nil t) "*") - 32 nil nil t))) + 32 nil nil t)) + crypto-switch) (error "End of search results")))) -(defun notmuch-search-reply-to-thread () +(defun notmuch-search-reply-to-thread (&optional prompt-for-sender) "Begin composing a reply to the entire current thread in a new buffer." - (interactive) + (interactive "P") (let ((message-id (notmuch-search-find-thread-id))) - (notmuch-mua-reply message-id))) + (notmuch-mua-new-reply message-id prompt-for-sender))) (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. @@ -459,6 +465,44 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (error (buffer-substring beg end)) )))))) +(defun notmuch-tag (query &rest tags) + "Add/remove tags in TAGS to messages matching QUERY. + +TAGS should be a list of strings of the form \"+TAG\" or \"-TAG\" and +QUERY should be a string containing the search-query. + +Note: Other code should always use this function alter tags of +messages instead of running (notmuch-call-notmuch-process \"tag\" ..) +directly, so that hooks specified in notmuch-before-tag-hook and +notmuch-after-tag-hook will be run." + (run-hooks 'notmuch-before-tag-hook) + (apply 'notmuch-call-notmuch-process + (append (list "tag") tags (list "--" query))) + (run-hooks 'notmuch-after-tag-hook)) + +(defcustom notmuch-before-tag-hook nil + "Hooks that are run before tags of a message are modified. + +'tags' will contain the tags that are about to be added or removed as +a list of strings of the form \"+TAG\" or \"-TAG\". +'query' will be a string containing the search query that determines +the messages that are about to be tagged" + + :type 'hook + :options '(hl-line-mode) + :group 'notmuch) + +(defcustom notmuch-after-tag-hook nil + "Hooks that are run before tags of a message are modified. + +'tags' will contain the tags that were added or removed as +a list of strings of the form \"+TAG\" or \"-TAG\". +'query' will be a string containing the search query that determines +the messages that were tagged" + :type 'hook + :options '(hl-line-mode) + :group 'notmuch) + (defun notmuch-search-set-tags (tags) (save-excursion (end-of-line) @@ -498,7 +542,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (defun notmuch-search-add-tag-region (tag beg end) (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))) - (notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-string) + (notmuch-tag search-id-string (concat "+" tag)) (save-excursion (let ((last-line (line-number-at-pos end)) (max-line (- (line-number-at-pos (point-max)) 2))) @@ -512,7 +556,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (defun notmuch-search-remove-tag-region (tag beg end) (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))) - (notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-string) + (notmuch-tag search-id-string (concat "-" tag)) (save-excursion (let ((last-line (line-number-at-pos end)) (max-line (- (line-number-at-pos (point-max)) 2))) @@ -612,7 +656,7 @@ The attributes defined for matching tags are merged, with later attributes overriding earlier. A message having both \"delete\" and \"unread\" tags with the above settings would have a green foreground and blue background." - :type '(alist :key-type (string) :value-type (list)) + :type '(alist :key-type (string) :value-type (custom-face-edit)) :group 'notmuch) (defun notmuch-search-color-line (start end line-tag-list) @@ -809,8 +853,7 @@ characters as well as `_.+-'. (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words)) (error "Action must be of the form `+thistag -that_tag'")) (setq words (cdr words)))) - (apply 'notmuch-call-notmuch-process "tag" - (append action-split (list notmuch-search-query-string) nil)))) + (apply 'notmuch-tag notmuch-search-query-string action-split))) (defun notmuch-search-buffer-title (query) "Returns the title for a buffer with notmuch search results."