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 F3A3C431FBC for ; Thu, 19 Nov 2009 06:18:26 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 IPStITc4mskd for ; Thu, 19 Nov 2009 06:18:26 -0800 (PST) Received: from mail-fx0-f217.google.com (mail-fx0-f217.google.com [209.85.220.217]) by olra.theworths.org (Postfix) with ESMTP id 1B326431FAE for ; Thu, 19 Nov 2009 06:18:25 -0800 (PST) Received: by fxm9 with SMTP id 9so2462065fxm.30 for ; Thu, 19 Nov 2009 06:18:21 -0800 (PST) Received: by 10.204.36.206 with SMTP id u14mr4153887bkd.199.1258640301348; Thu, 19 Nov 2009 06:18:21 -0800 (PST) Received: from x61s.janakj (nat.sip-server.net [213.192.30.130]) by mx.google.com with ESMTPS id f31sm734135fkf.42.2009.11.19.06.18.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Nov 2009 06:18:20 -0800 (PST) Received: by x61s.janakj (Postfix, from userid 1000) id 9B2C8440651; Thu, 19 Nov 2009 15:18:19 +0100 (CET) From: Jan Janak To: notmuch@notmuchmail.org Date: Thu, 19 Nov 2009 15:18:19 +0100 Message-Id: <1258640299-6012-1-git-send-email-jan@ryngle.com> X-Mailer: git-send-email 1.6.3.3 Subject: [notmuch] [PATCH] notmuch.el: Completion for tag names. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Thu, 19 Nov 2009 14:18:27 -0000 Add support for completion of tag names. Several commands ask the user for a tag name. With this feature the user can just press tab and emacs automatically retrieves the list of all existing tags from notmuch database with 'notmuch list tags' and presents a completion buffer to the user. Signed-off-by: Jan Janak --- notmuch.el | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/notmuch.el b/notmuch.el index 706e9f3..587e093 100644 --- a/notmuch.el +++ b/notmuch.el @@ -165,7 +165,8 @@ Unlike builtin `next-line' this version accepts no arguments." (defun notmuch-show-add-tag (&rest toadd) "Add a tag to the current message." - (interactive "sTag to add: ") + (interactive + (list (notmuch-tag-with-completion "Tag to add: "))) (apply 'notmuch-call-notmuch-process (append (cons "tag" (mapcar (lambda (s) (concat "+" s)) toadd)) @@ -174,7 +175,8 @@ Unlike builtin `next-line' this version accepts no arguments." (defun notmuch-show-remove-tag (&rest toremove) "Remove a tag from the current message." - (interactive "sTag to remove: ") + (interactive + (list (notmuch-tag-with-completion "Tag to remove: "))) (let ((tags (notmuch-show-get-tags))) (if (intersection tags toremove :test 'string=) (progn @@ -873,13 +875,22 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (let ((end (- (point) 1))) (split-string (buffer-substring beg end)))))) +(defun notmuch-tag-with-completion (prompt) + (let ((tag-list + (with-output-to-string + (with-current-buffer standard-output + (call-process "notmuch" nil t nil "list" "tags"))))) + (completing-read prompt (split-string tag-list "\n+" t) nil nil nil))) + (defun notmuch-search-add-tag (tag) - (interactive "sTag to add: ") + (interactive + (list (notmuch-tag-with-completion "Tag to add: "))) (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id)) (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<)))) (defun notmuch-search-remove-tag (tag) - (interactive "sTag to remove: ") + (interactive + (list (notmuch-tag-with-completion "Tag to remove: "))) (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id)) (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))) @@ -964,7 +975,8 @@ current search results AND the additional query string provided." Runs a new search matching only messages that match both the current search results AND that are tagged with the given tag." - (interactive "sFilter by tag: ") + (interactive + (list (notmuch-tag-with-completion "Filter by tag: "))) (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first)) (defun notmuch () -- 1.6.3.3