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 A08FD429E25 for ; Mon, 6 Jun 2011 09:32:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 fee5pmtjET5S for ; Mon, 6 Jun 2011 09:32:59 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9CC00431FB6 for ; Mon, 6 Jun 2011 09:32:58 -0700 (PDT) Received: by fxm8 with SMTP id 8so2839243fxm.26 for ; Mon, 06 Jun 2011 09:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=nVrSXgo1Tmn4P0/mKDVZ/NHt448FeuaKVwyl3X/dEAE=; b=ASMtjna5lHCfijPqdX4d+i2MkZCxv3Nd3TSX+PO2XNLvhzzLZ3DOnzXWdmXdnLix9o 9RKLplWcyfiNX/nBjxYE53evjsU8Y6sggMtJtjQkud70d0Y0VxWIY6DLLMfRVtXdXRUn 5OrJX03p908V656JUzJV/SCW4pLam+kFgc63g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=LRpgwoUp0d53JJncNSNvUBfXY+rPDSWr+4+ezKv08hg3XA2h/eoCZIBBtKw/z8YTNS Vj0QTQwto0hvXSqBDmPpEizLZFsbFfYafwFCkojbNnDj3zimOfZ10nomNX7po8P+/MG9 UGRkPpl0EpkQCIt4SuyoIxDvSrTtIG6rzLSfc= Received: by 10.223.25.201 with SMTP id a9mr1376430fac.141.1307377977094; Mon, 06 Jun 2011 09:32:57 -0700 (PDT) Received: from localhost (dslb-088-068-007-168.pools.arcor-ip.net [88.68.7.168]) by mx.google.com with ESMTPS id 11sm1441026fax.36.2011.06.06.09.32.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Jun 2011 09:32:55 -0700 (PDT) From: Daniel Schoepe To: Austin Clements Subject: Re: [PATCH] emacs: Tab completion for notmuch-search and notmuch-search-filter In-Reply-To: <87hb85jjgx.fsf@gilead.invalid> References: <1307189970-728-1-git-send-email-daniel.schoepe@googlemail.com> <87mxhxjrry.fsf@gilead.invalid> <20110604215523.GF29861@mit.edu> <87hb85jjgx.fsf@gilead.invalid> User-Agent: Notmuch/0.5-225-ga896936 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Mon, 06 Jun 2011 18:32:41 +0200 Message-ID: <87lixevs2e.fsf@gilead.invalid> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: notmuch@notmuchmail.org 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: Mon, 06 Jun 2011 16:32:59 -0000 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= I accidentally left a, now unnecessary, defvar in the patch from one of the previous attempts, here is the updated version (thanks Austin for noticing). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-emacs-Tab-completion-for-notmuch-search-and-notmuch-.patch Content-Transfer-Encoding: quoted-printable From=20f3bc7376edc66e947d8fdf5931a9aa697b9be5cf Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Sat, 4 Jun 2011 14:17:44 +0200 Subject: [PATCH] emacs: Tab completion for notmuch-search and notmuch-search-filter This patch adds completion with in the minibuffer for notmuch-search and notmuch-search-filter. =2D-- emacs/notmuch.el | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 3311fe8..7ffbc3a 100644 =2D-- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -882,6 +882,35 @@ characters as well as `_.+-'. (concat "*notmuch-search-" query "*")) ))) =20 +(defun notmuch-read-query (prompt) + "Read a notmuch-query from the minibuffer with completion. + +PROMPT is the string to prompt with." + (lexical-let + ((completions=20 + (append (list "folder:" "thread:" "id:" "date:" "from:" "to:" + "subject:" "attachment:") + (mapcar (lambda (tag) + (concat "tag:" tag)) + (process-lines "notmuch" "search-tags"))))) + (let ((keymap (copy-keymap minibuffer-local-map)) + (minibuffer-completion-table + (completion-table-dynamic + (lambda (string) + ;; generate a list of possible completions for the current input + (cond + ;; this ugly regexp is used to get the last word of the input + ;; possibly preceded by a '(' + ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string) + (mapcar (lambda (compl) + (concat (match-string-no-properties 1 string) compl)) + (all-completions (match-string-no-properties 2 string) + completions))) + (t (list string))))))) + ;; this was simpler than convincing completing-read to accept spaces: + (define-key keymap (kbd "") 'minibuffer-complete) + (read-from-minibuffer prompt nil keymap nil minibuffer-history nil n= il)))) + ;;;###autoload (defun notmuch-search (query &optional oldest-first target-thread target-l= ine continuation) "Run \"notmuch search\" with the given query string and display results. @@ -893,7 +922,7 @@ The optional parameters are used as follows: current if it appears in the search results. target-line: The line number to move to if the target thread does not appear in the search results." =2D (interactive "sNotmuch search: ") + (interactive (list (notmuch-read-query "Notmuch search: "))) (let ((buffer (get-buffer-create (notmuch-search-buffer-title query)))) (switch-to-buffer buffer) (notmuch-search-mode) @@ -991,7 +1020,7 @@ search." =20 Runs a new search matching only messages that match both the current search results AND the additional query string provided." =2D (interactive "sFilter search: ") + (interactive (list (notmuch-read-query "Filter search: "))) (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-rege= xp query) (concat "( " query " )") query))) =2D-=20 1.7.5.3 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJN7QEpAAoJEIaTAtce+Z+JkAIP/ilrKOti8iwVo/u1A0CtX2R+ cVF4NAGzsWoK0KsYTNFPV3dtssmJXemMPPtBbXI+W+Q6axPUXsSbV1XY/f/3yRlw sS0hUmqGbmUZiBKzVaNJ/bH2nDZkBbEqsUMTaMfKYr7UbnnPYXCS82FFr2zDRlBQ bOBokkBMvmaIKLDXJuuRbtkZc3/5M61nWKqO7SBVySjgkflDIgItiLbNdimu7M47 Fj/N7yyDww+YcQVynqj0EiOVZRzJ4g4o5BGhx8fcpNk6MUH/IeokwP2pp1/NhMWB iWi1qj3c/V0d4XEibMXyAc+8mpVaB+izWopRIx5+KdRAp/CJR+qvSgWBwJEtvbeY RvBFh0+GF3skontDhuiHnu3IX1625QRHPxrvm+wZaOWC8p5vdPOtGO7hvWTvVKYQ ykmljx/JrBoWUBG/rN21BGq1f739dMsuLJ2MLw0w8ZFU0OXQr9AhQnb+8RSpNIJE brCM+cpvpVzwpvhmI0T5/VeqORSuunO11pvj3543xuLU36sfI5atxR1pz7cZBE2x qoHzmq2kI+HMMfNb2bM5m0VQslcGURrO3ZIDWORSzjhChiw1EhC5vyL8YRtVDRxQ /ED/NSaXu3O507owBh4uFIdq4CbNhkCxIdtFC+hjQGu53HObSyx5N0rn9FikHILG tM+b8pzAaAH/s3kWxM3i =JRlC -----END PGP SIGNATURE----- --==-=-=--