X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=contrib%2Fnotmuch-pick%2Fnotmuch-pick.el;h=d75a66aeb9fd8da748e91ffccea261db982464e6;hb=a1ddf62f6a54e1e82410445346ec9ba15db1b692;hp=1a553d41314d23a26e2fbb6d1e60beb271b354e5;hpb=480f44fbe47a068626dbb7c7d9e9b1fb72a5da0f;p=obsolete%2Fnotmuch-old diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el index 1a553d41..d75a66ae 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -157,6 +157,10 @@ (make-variable-buffer-local 'notmuch-pick-query-context) (defvar notmuch-pick-buffer-name nil) (make-variable-buffer-local 'notmuch-pick-buffer-name) +;; This variable is the window used for the message pane. It is set +;; in both the parent pick buffer and the child show buffer. It is +;; used to try and close the message pane when quitting pick or the +;; child show buffer. (defvar notmuch-pick-message-window nil) (make-variable-buffer-local 'notmuch-pick-message-window) (put 'notmuch-pick-message-window 'permanent-local t) @@ -175,8 +179,8 @@ (define-key map "?" 'notmuch-help) (define-key map "a" 'notmuch-pick-archive-message-then-next) (define-key map "=" 'notmuch-pick-refresh-view) - (define-key map "s" 'notmuch-search) - (define-key map "z" 'notmuch-pick) + (define-key map "s" 'notmuch-pick-to-search) + (define-key map "z" 'notmuch-pick-to-pick) (define-key map "m" 'notmuch-pick-new-mail) (define-key map "f" 'notmuch-pick-forward-message) (define-key map "r" 'notmuch-pick-reply-sender) @@ -289,6 +293,25 @@ Does NOT change the database." (interactive) (notmuch-pick-tag "-")) +;; The next two functions close the message window before searching or +;; picking but they do so after the user has entered the query (in +;; case the user was basing the query on something in the message +;; window). + +(defun notmuch-pick-to-search () + "Run \"notmuch search\" with the given `query' and display results." + (interactive) + (let ((query (notmuch-read-query "Notmuch search: "))) + (notmuch-pick-close-message-window) + (notmuch-search query))) + +(defun notmuch-pick-to-pick () + "Run a query and display results in experimental notmuch-pick mode" + (interactive) + (let ((query (notmuch-read-query "Notmuch pick: "))) + (notmuch-pick-close-message-window) + (notmuch-pick query))) + ;; This function should be in notmuch-hello.el but we are trying to ;; minimise impact on the rest of the codebase. (defun notmuch-pick-from-hello (&optional search) @@ -324,6 +347,16 @@ Does NOT change the database." (notmuch-prettify-subject (notmuch-search-find-subject))) (notmuch-pick-show-match-message-with-wait)) +(defun notmuch-pick-message-window-kill-hook () + (let ((buffer (current-buffer))) + (when (and (window-live-p notmuch-pick-message-window) + (eq (window-buffer notmuch-pick-message-window) buffer)) + ;; We do not want an error if this is the sole window in the + ;; frame and I do not know how to test for that in emacs pre + ;; 24. Hence we just ignore-errors. + (ignore-errors + (delete-window notmuch-pick-message-window))))) + (defun notmuch-pick-show-message () "Show the current message (in split-pane)." (interactive) @@ -341,6 +374,11 @@ Does NOT change the database." (let ((notmuch-show-indent-messages-width 0)) (setq current-prefix-arg '(4)) (setq buffer (notmuch-show id nil nil nil)))) + ;; We need the `let' as notmuch-pick-message-window is buffer local. + (let ((window notmuch-pick-message-window)) + (with-current-buffer buffer + (setq notmuch-pick-message-window window) + (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook))) (notmuch-pick-tag-update-display (list "-unread")) (setq notmuch-pick-message-buffer buffer))))