From 362bca493ad4e368358aab62921fd7cc8f035fa8 Mon Sep 17 00:00:00 2001 From: Tom Hirschowitz Date: Thu, 5 Jun 2014 11:52:32 +0200 Subject: [PATCH] an emacs macro --- 2d/6128833bc7425b51172de5f8907316258b9bd8 | 103 ++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 2d/6128833bc7425b51172de5f8907316258b9bd8 diff --git a/2d/6128833bc7425b51172de5f8907316258b9bd8 b/2d/6128833bc7425b51172de5f8907316258b9bd8 new file mode 100644 index 000000000..a3c16be21 --- /dev/null +++ b/2d/6128833bc7425b51172de5f8907316258b9bd8 @@ -0,0 +1,103 @@ +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 7F57E431FBD + for ; Thu, 5 Jun 2014 02:58:58 -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 21LqtV-zjHh2 for ; + Thu, 5 Jun 2014 02:58:52 -0700 (PDT) +X-Greylist: delayed 378 seconds by postgrey-1.32 at olra; + Thu, 05 Jun 2014 02:58:52 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 73380431FBC + for ; Thu, 5 Jun 2014 02:58:52 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id E5AF0422A2 + for ; Thu, 5 Jun 2014 11:52:32 +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 KnSPTAk0dvdc for ; + Thu, 5 Jun 2014 11:52:32 +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 CE9F6422A1 + for ; Thu, 5 Jun 2014 11:52:32 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id CC68E14093 + for ; Thu, 5 Jun 2014 11:52:32 +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 JtjGUMP2xbrP for ; + Thu, 5 Jun 2014 11:52:32 +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 B271914080 + for ; Thu, 5 Jun 2014 11:52:32 +0200 (CEST) +From: Tom Hirschowitz +To: notmuch@notmuchmail.org +Cc: +Subject: an emacs macro +User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Thu, 05 Jun 2014 11:52:32 +0200 +Message-ID: <87bnu7k7j3.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: Thu, 05 Jun 2014 09:58:58 -0000 + + +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)))) + +(define-key notmuch-show-mode-map (kbd "M") 'notmuch-show-move) +(define-key notmuch-search-mode-map (kbd "M") 'notmuch-show-move) + +This seems to work in show-mode, but not in search-mode. +I'd be grateful for any hint on doing this in tree- and search-modes +(and possibly explanations on why the current version does not work). + +Thanks, +Tom -- 2.26.2