From: Tom Hirschowitz Date: Fri, 6 Jun 2014 12:20:53 +0000 (+0200) Subject: Re: an emacs macro X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7dc33992c4d77cd720e9124ef046bc3e55213278;p=notmuch-archives.git Re: an emacs macro --- diff --git a/0d/c9942a828be3a2f1c21d9c6883248b516dd0e1 b/0d/c9942a828be3a2f1c21d9c6883248b516dd0e1 new file mode 100644 index 000000000..560437919 --- /dev/null +++ b/0d/c9942a828be3a2f1c21d9c6883248b516dd0e1 @@ -0,0 +1,131 @@ +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 5FE5640C425 + for ; Fri, 6 Jun 2014 05:21:04 -0700 (PDT) +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=[RCVD_IN_DNSWL_NONE=-0.0001] 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 ZdQAviQ+Yj0n for ; + Fri, 6 Jun 2014 05:20:57 -0700 (PDT) +Received: from dsi-mta-out.univ-savoie.fr (dsi-mta-out.univ-savoie.fr + [193.48.126.73]) + by olra.theworths.org (Postfix) with ESMTP id C9F2340CAF1 + for ; Fri, 6 Jun 2014 05:20:56 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id 7B26042247 + for ; Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +Received: from dsi-mta-out.univ-savoie.fr ([127.0.0.1]) + by localhost (dsi-mta-out.univ-savoie.fr [127.0.0.1]) (amavisd-new, + port 10026) with ESMTP id HxqaMigslDDh for ; + Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +Received: from dsi-mail-msa1.univ-savoie.fr (dsi-mail-msa1.univ-savoie.fr + [193.48.126.83]) + by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id 68A6E42184 + for ; Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id 663E714096 + for ; Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +X-Virus-Scanned: Debian amavisd-new at dsi-mail-msa1.univ-savoie.fr +Received: from dsi-mail-msa1.univ-savoie.fr ([127.0.0.1]) + by localhost (dsi-mail-msa1.univ-savoie.fr [127.0.0.1]) (amavisd-new, + port 10024) with ESMTP id cHnncTX7AkJZ for ; + Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +Received: from hirscho.lama.univ-savoie.fr (lama-d186.univ-savoie.fr + [193.48.123.186]) + by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id 49FF014093 + for ; Fri, 6 Jun 2014 14:20:53 +0200 (CEST) +From: Tom Hirschowitz +To: notmuch@notmuchmail.org +Cc: +Subject: Re: an emacs macro +In-Reply-To: <8761kefdpq.fsf@qmul.ac.uk> +References: <87bnu7k7j3.fsf@hirscho.lama.univ-savoie.fr> + <8761kefdpq.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Fri, 06 Jun 2014 14:20:53 +0200 +Message-ID: <8738fiut3u.fsf@hirscho.lama.univ-savoie.fr> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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:21:04 -0000 + + +Thanks, you were right, although that's what i had tried. No idea what i +did wrong the first time. + +Here's the code in case anyone is interested (i actually tweaked *-add-tag): + +(defun notmuch-search-move (tag-changes &optional beg end) + "Add the local tag, plus possibly others, given as interactive arguments, +for the current thread or region (defaulting to add)." + (interactive (notmuch-search-interactive-tag-changes "+")) + (notmuch-search-tag (cons "+local" tag-changes) beg end)) + +(defun notmuch-tree-move (tag-changes) + "Add the local tag, plus possibly others, given as interactive arguments, +for the current thread or region (defaulting to add)." + (interactive + (list (notmuch-read-tag-changes (notmuch-tree-get-tags) "Tag message" "+"))) + (notmuch-tree-tag (cons "+local" tag-changes))) + +Cheers, +Tom + +Mark Walters writes: + +> 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