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 B91B4431FBC for ; Sun, 22 Nov 2009 16:11:22 -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 THXY0LGEWw7E for ; Sun, 22 Nov 2009 16:11:22 -0800 (PST) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by olra.theworths.org (Postfix) with ESMTP id 139AF431FAE for ; Sun, 22 Nov 2009 16:11:21 -0800 (PST) Received: by fg-out-1718.google.com with SMTP id 19so1921773fgg.2 for ; Sun, 22 Nov 2009 16:11:21 -0800 (PST) Received: by 10.102.165.24 with SMTP id n24mr1914615mue.47.1258935081132; Sun, 22 Nov 2009 16:11:21 -0800 (PST) Received: from x61s.janakj (r2c34.net.upc.cz [62.245.66.34]) by mx.google.com with ESMTPS id u9sm14200792muf.7.2009.11.22.16.11.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 22 Nov 2009 16:11:20 -0800 (PST) Received: by x61s.janakj (Postfix, from userid 1000) id 13DBB440374; Mon, 23 Nov 2009 01:10:57 +0100 (CET) From: Jan Janak To: notmuch@notmuchmail.org Date: Mon, 23 Nov 2009 01:10:56 +0100 Message-Id: <1258935056-9746-3-git-send-email-jan@ryngle.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1258935056-9746-2-git-send-email-jan@ryngle.com> References: <1258935056-9746-1-git-send-email-jan@ryngle.com> <1258935056-9746-2-git-send-email-jan@ryngle.com> Subject: [notmuch] [PATCH 3/3] notmuch.el: Select tag names with completion. 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: Mon, 23 Nov 2009 00:11:22 -0000 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 search-tags' and presents a completion buffer to the user. This feature is very useful for users who have a large number of tags because it saves typing and minimizes the risk of typos. Signed-off-by: Jan Janak --- notmuch.el | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/notmuch.el b/notmuch.el index 5927737..b6be395 100644 --- a/notmuch.el +++ b/notmuch.el @@ -139,6 +139,13 @@ within the current window." (or (memq prop buffer-invisibility-spec) (assq prop buffer-invisibility-spec))))) +(defun notmuch-select-tag-with-completion (prompt) + (let ((tag-list + (with-output-to-string + (with-current-buffer standard-output + (call-process notmuch-command nil t nil "search-tags"))))) + (completing-read prompt (split-string tag-list "\n+" t) nil nil nil))) + (defun notmuch-show-next-line () "Like builtin `next-line' but ensuring we end on a visible character. @@ -202,7 +209,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-select-tag-with-completion "Tag to add: "))) (apply 'notmuch-call-notmuch-process (append (cons "tag" (mapcar (lambda (s) (concat "+" s)) toadd)) @@ -211,7 +219,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-select-tag-with-completion "Tag to remove: "))) (let ((tags (notmuch-show-get-tags))) (if (intersection tags toremove :test 'string=) (progn @@ -970,12 +979,14 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (split-string (buffer-substring beg end)))))) (defun notmuch-search-add-tag (tag) - (interactive "sTag to add: ") + (interactive + (list (notmuch-select-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-select-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)))) @@ -1061,7 +1072,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-select-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