From 3b4488db1e2cbbbcd122edc286fdcd928ff6e168 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 6 Jun 2014 13:02:25 +0100 Subject: [PATCH] Re: an emacs macro --- 20/bdfb3a39ab5b86ed5223f6a7319b47e0e92bc5 | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 20/bdfb3a39ab5b86ed5223f6a7319b47e0e92bc5 diff --git a/20/bdfb3a39ab5b86ed5223f6a7319b47e0e92bc5 b/20/bdfb3a39ab5b86ed5223f6a7319b47e0e92bc5 new file mode 100644 index 000000000..845227dbb --- /dev/null +++ b/20/bdfb3a39ab5b86ed5223f6a7319b47e0e92bc5 @@ -0,0 +1,109 @@ +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 D57C640A95E + for ; Fri, 6 Jun 2014 05:02:36 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.502 +X-Spam-Level: +X-Spam-Status: No, score=0.502 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, 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 dZjfeZmLE4wT for ; + Fri, 6 Jun 2014 05:02:29 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 7708540A93B + for ; Fri, 6 Jun 2014 05:02:29 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Wssqp-0003T4-4A; Fri, 06 Jun 2014 13:02:27 +0100 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Wssqo-0004Wm-RC; Fri, 06 Jun 2014 13:02:27 +0100 +From: Mark Walters +To: Tom Hirschowitz , notmuch@notmuchmail.org +Subject: Re: an emacs macro +In-Reply-To: <87bnu7k7j3.fsf@hirscho.lama.univ-savoie.fr> +References: <87bnu7k7j3.fsf@hirscho.lama.univ-savoie.fr> +User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Fri, 06 Jun 2014 13:02:25 +0100 +Message-ID: <8761kefdpq.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: fcfac721c17d9da0307bedbf002edcb7 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Fri, 06 Jun 2014 12:02:37 -0000 + + +On Thu, 05 Jun 2014, Tom Hirschowitz wrote: +> Hi all, +> +> I'm trying to define a macro for notmuch/emacs which in show-mode would +> +> - prompt the user for tags (possibly starting with "+"), +> +> - tag the shown message with these tags plus an additional fixed tag, +> say "+local". +> +> I know next to nothing about emacs/lisp, so I tried to mimick notmuch*.el. +> +> Here's my most plausible attempt: +> +> (defun notmuch-show-move (tag-changes) +> "Add the local tag, plus possibly others, given as interactive arguments." +> (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags) +> "Tag message" "+"))) +> (let* ((tag-changes-with-local (cons "+local" tag-changes)) +> (rien (notmuch-tag (notmuch-show-get-message-id) tag-changes-with-local)) +> (current-tags (notmuch-show-get-tags)) +> (new-tags (notmuch-update-tags current-tags tag-changes-with-local))) +> (unless (equal current-tags new-tags) +> (notmuch-show-set-tags new-tags)))) + +Yes this looks fine for notmuch-show. It won't work for search mode as +notmuch-show- commands basically only work in notmuch-show. I would +suggest copying notmuch-search-tag and tweaking it to use +tag-changes-with-local (as you have done for the show version +above). Something similar should work for tree-mode (ie copy +notmuch-tree-tag) + +I think you will need separate functions for the three modes. + +Best wishes + +Mark -- 2.26.2