From: Mark Walters Date: Sun, 12 Feb 2012 10:36:04 +0000 (+0000) Subject: [RFC PATCH 2/3] emacs: changes to other files to support notmuch-pick X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a57951a4ca0efa0558c6165254cd4e896a7d7cc9;p=notmuch-archives.git [RFC PATCH 2/3] emacs: changes to other files to support notmuch-pick --- diff --git a/d5/e16f01145eb61115ea5b5f02597318a58e8309 b/d5/e16f01145eb61115ea5b5f02597318a58e8309 new file mode 100644 index 000000000..fe407dab1 --- /dev/null +++ b/d5/e16f01145eb61115ea5b5f02597318a58e8309 @@ -0,0 +1,247 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id D060D42116C + for ; Sun, 12 Feb 2012 02:35:12 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id kgX1aT4OPvJs for ; + Sun, 12 Feb 2012 02:35:10 -0800 (PST) +Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com + [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 51313421169 for ; Sun, 12 Feb 2012 02:35:07 -0800 + (PST) +Received: by wgbdt11 with SMTP id dt11so1612923wgb.2 + for ; Sun, 12 Feb 2012 02:35:06 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=inBFoIN+YD3t3yAPlqbFNynCCbHazzvDwB5QcTZkDvI=; + b=eOKJXiuCBM7lRYK9xI2hP2CtW/N7KZaFA6+CxAH3NvxdVF+AYWHB+UpIgwu2CKqrly + mCFjqu6thEufJNTmFZcftkq1x44VTuyYKJrIablSN6USWZSPGAL47z0zswLOstT1Syka + OC01Z8hElGXBDC7Du1nxQZ1F6d2LpxwmBJlxc= +Received: by 10.180.86.105 with SMTP id o9mr18628016wiz.4.1329042906040; + Sun, 12 Feb 2012 02:35:06 -0800 (PST) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + dr5sm35849431wib.0.2012.02.12.02.35.04 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 12 Feb 2012 02:35:05 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [RFC PATCH 2/3] emacs: changes to other files to support notmuch-pick +Date: Sun, 12 Feb 2012 10:36:04 +0000 +Message-Id: <1329042965-3871-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <87d39k1gvi.fsf@qmul.ac.uk> +References: <87d39k1gvi.fsf@qmul.ac.uk> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 12 Feb 2012 10:35:13 -0000 + +--- + emacs/Makefile.local | 3 ++- + emacs/notmuch-hello.el | 10 ++++++++++ + emacs/notmuch-query.el | 4 +++- + emacs/notmuch-show.el | 19 +++++++++++++++---- + emacs/notmuch.el | 8 ++++++++ + 5 files changed, 38 insertions(+), 6 deletions(-) + +diff --git a/emacs/Makefile.local b/emacs/Makefile.local +index 4fee0e8..2922d9e 100644 +--- a/emacs/Makefile.local ++++ b/emacs/Makefile.local +@@ -14,7 +14,8 @@ emacs_sources := \ + $(dir)/notmuch-message.el \ + $(dir)/notmuch-crypto.el \ + $(dir)/coolj.el \ +- $(dir)/notmuch-print.el ++ $(dir)/notmuch-print.el \ ++ $(dir)/notmuch-pick.el + + emacs_images := \ + $(srcdir)/$(dir)/notmuch-logo.png +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index d17a30f..6d28a7e 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -27,6 +27,7 @@ + (require 'notmuch-mua) + + (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation)) ++(declare-function notmuch-pick "notmuch-pick" (query &optional query-context buffer-name)) + (declare-function notmuch-poll "notmuch" ()) + + (defcustom notmuch-hello-recent-searches-max 10 +@@ -181,6 +182,14 @@ International Bureau of Weights and Measures." + (notmuch-search search notmuch-search-oldest-first nil nil + #'notmuch-hello-search-continuation)) + ++(defun notmuch-hello-pick (&optional search) ++ (interactive) ++ (unless (null search) ++ (setq search (notmuch-hello-trim search)) ++ (let ((history-delete-duplicates t)) ++ (add-to-history 'notmuch-search-history search))) ++ (notmuch-pick search)) ++ + (defun notmuch-hello-add-saved-search (widget) + (interactive) + (let ((search (widget-value +@@ -345,6 +354,7 @@ should be. Returns a cons cell `(tags-per-line width)'." + (define-key map (kbd "") 'widget-backward) + (define-key map "m" 'notmuch-mua-new-mail) + (define-key map "s" 'notmuch-hello-search) ++ (define-key map "z" 'notmuch-hello-pick) + map) + "Keymap for \"notmuch hello\" buffers.") + (fset 'notmuch-hello-mode-map notmuch-hello-mode-map) +diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el +index d66baea..b3c91a3 100644 +--- a/emacs/notmuch-query.el ++++ b/emacs/notmuch-query.el +@@ -22,7 +22,7 @@ + (require 'notmuch-lib) + (require 'json) + +-(defun notmuch-query-get-threads (search-terms) ++(defun notmuch-query-get-threads (search-terms &rest extra-format) + "Return a list of threads of messages matching SEARCH-TERMS. + + A thread is a forest or list of trees. A tree is a two element +@@ -33,6 +33,8 @@ is a possibly empty forest of replies. + (json-object-type 'plist) + (json-array-type 'list) + (json-false 'nil)) ++ (if extra-format ++ (setq args (append args extra-format))) + (if notmuch-show-process-crypto + (setq args (append args '("--decrypt")))) + (setq args (append args search-terms)) +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 24fde05..825f7fe 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -42,6 +42,7 @@ + (declare-function notmuch-search-next-thread "notmuch" nil) + (declare-function notmuch-search-show-thread "notmuch" nil) + (declare-function notmuch-update-tags "notmuch" (current-tags tag-changes)) ++(declare-function notmuch-pick "notmuch-pick" (query &optional query-context buffer-name)) + + (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") + "Headers that should be shown in a message, in this order. +@@ -962,7 +963,7 @@ a corresponding notmuch search." + 'face goto-address-mail-face)))) + + ;;;###autoload +-(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch) ++(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch just-matches) + "Run \"notmuch show\" with the given thread ID and display results. + + The optional PARENT-BUFFER is the notmuch-search buffer from +@@ -986,9 +987,9 @@ buffer." + (let* ((process-crypto (if crypto-switch + (not notmuch-crypto-process-mime) + notmuch-crypto-process-mime))) +- (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto))) ++ (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto just-matches))) + +-(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto) ++(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name process-crypto &optional just-matches) + (let* ((buffer-name (generate-new-buffer-name + (or buffer-name + (concat "*notmuch-" thread-id "*")))) +@@ -1012,6 +1013,8 @@ buffer." + (args (if query-context + (append (list "\'") basic-args (list "and (" query-context ")\'")) + (append (list "\'") basic-args (list "\'"))))) ++ (if just-matches ++ (setq args (append (list "--thread=none") args))) + (notmuch-show-insert-forest (notmuch-query-get-threads args)) + ;; If the query context reduced the results to nothing, run + ;; the basic query. +@@ -1031,7 +1034,8 @@ buffer." + ;; Set the header line to the subject of the first open message. + (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject))) + +- (notmuch-show-mark-read))) ++ (notmuch-show-mark-read) ++ buffer)) + + (defun notmuch-show-refresh-view (&optional crypto-switch) + "Refresh the current view (with crypto switch if prefix given). +@@ -1073,6 +1077,8 @@ thread id. If a prefix is given, crypto processing is toggled." + (define-key map (kbd "") 'notmuch-show-previous-button) + (define-key map (kbd "TAB") 'notmuch-show-next-button) + (define-key map "s" 'notmuch-search) ++ (define-key map "z" 'notmuch-pick) ++ (define-key map "Z" 'notmuch-show-pick-current-query) + (define-key map "m" 'notmuch-mua-new-mail) + (define-key map "f" 'notmuch-show-forward-message) + (define-key map "r" 'notmuch-show-reply-sender) +@@ -1476,6 +1482,11 @@ to show, nil otherwise." + (notmuch-show-mark-read) + (notmuch-show-message-adjust)) + ++(defun notmuch-show-pick-current-query () ++ "Call notmuch pick with the current query" ++ (interactive) ++ (notmuch-pick notmuch-show-thread-id notmuch-show-query-context)) ++ + (defun notmuch-show-view-raw-message () + "View the file holding the current message." + (interactive) +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 8250961..e95842e 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -54,6 +54,7 @@ + + (require 'notmuch-lib) + (require 'notmuch-show) ++(require 'notmuch-pick) + (require 'notmuch-mua) + (require 'notmuch-hello) + (require 'notmuch-maildir-fcc) +@@ -272,6 +273,8 @@ For a mouse binding, return nil." + (define-key map "R" 'notmuch-search-reply-to-thread) + (define-key map "m" 'notmuch-mua-new-mail) + (define-key map "s" 'notmuch-search) ++ (define-key map "z" 'notmuch-pick) ++ (define-key map "Z" 'notmuch-search-pick-current-query) + (define-key map "o" 'notmuch-search-toggle-order) + (define-key map "c" 'notmuch-search-stash-map) + (define-key map "=" 'notmuch-search-refresh-view) +@@ -1021,6 +1024,11 @@ same relative position within the new buffer." + (notmuch-search query oldest-first target-thread target-line continuation) + (goto-char (point-min)))) + ++(defun notmuch-search-pick-current-query () ++ "Call notmuch pick with the current query" ++ (interactive) ++ (notmuch-pick notmuch-search-query-string)) ++ + (defcustom notmuch-poll-script nil + "An external script to incorporate new mail into the notmuch database. + +-- +1.7.2.3 +