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 B2AB7431FAF for ; Wed, 18 Jan 2012 06:45:13 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 NCBO77X7Kw74 for ; Wed, 18 Jan 2012 06:45:13 -0800 (PST) Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 2FBCF431FAE for ; Wed, 18 Jan 2012 06:45:13 -0800 (PST) Received: from [131.202.13.154] (helo=convex-new.cs.unb.ca) by tesseract.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1RnWlD-000807-NS; Wed, 18 Jan 2012 10:45:11 -0400 Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72) (envelope-from ) id 1RnWl8-0003en-AU; Wed, 18 Jan 2012 10:45:06 -0400 From: David Bremner To: "Notmuch Mail" Subject: RFC: tag macros User-Agent: Notmuch/0.10.2+114~g80ee511 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 18 Jan 2012 10:45:06 -0400 Message-ID: <874nvtvzm5.fsf@convex-new.cs.unb.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam_bar: - 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: Wed, 18 Jan 2012 14:45:13 -0000 Hi All; Here is a very early stage proposal to provide tagging macros for notmuch show mode. The idea is that user defines a mapping from single key to a sequence of tagging operations. It might be nice if there as some kind of pop-up menu, or at least a prompt, but I didn't do that so far. The advantage of this rather than just writing lots of little lambdas is that it combines adding and deleting, and it could be done via customize. As provided, the code should just paste into .emacs, and with a little editing into notmuch-show.el. % ---- cut here ---- (eval-after-load 'notmuch-show '(define-key notmuch-show-mode-map "t" 'notmuch-show-apply-tag-macro)) (setq notmuch-show-tag-macro-alist (list '("p" "+notmuch::patch" "+notmuch::needs-review") '("r" "+notmuch::review") '("o" "+notmuch::patch" "+notmuch::obsolete" "-notmuch::needs-review") '("m" "+notmuch::patch" "+notmuch::moreinfo" "-notmuch::needs-review"))) (defun notmuch-show-apply-tag-macro (key) (interactive "k") (let ((macro (assoc key notmuch-show-tag-macro-alist))) (apply 'notmuch-show-add-or-del-tags (cdr macro)))) (defun notmuch-show-add-or-del-tags (&rest add-or-dels) "Add or delete tags to/from the current message." (let* ((current-tags (notmuch-show-get-tags)) (new-tags (notmuch-show-add-or-del-tags-worker current-tags add-or-dels))) (unless (equal current-tags new-tags) (apply 'notmuch-tag (notmuch-show-get-message-id) add-or-dels) (notmuch-show-set-tags new-tags)))) (defun notmuch-show-add-or-del-tags-worker (current-tags add-or-dels) "Remove any tags in `add-or-del' prefixed with `-' from `current-tags', add any prefixed with `+' and return the result." (let (adds deletes) (mapc (lambda (tag-str) (if (string-match "^\\([+\-]\\)\\(.*\\)" tag-str) (let ((op (match-string 1 tag-str)) (tag (match-string 2 tag-str))) (if (equal op "+") (setq adds (cons tag adds)) (setq deletes (cons tag deletes)))) (error "%s: does not start with + or -" tag-str))) add-or-dels) (notmuch-show-del-tags-worker (notmuch-show-add-tags-worker current-tags adds) deletes)))