an emacs macro
[notmuch-archives.git] / 2d / 6128833bc7425b51172de5f8907316258b9bd8
diff --git a/2d/6128833bc7425b51172de5f8907316258b9bd8 b/2d/6128833bc7425b51172de5f8907316258b9bd8
new file mode 100644 (file)
index 0000000..a3c16be
--- /dev/null
@@ -0,0 +1,103 @@
+Return-Path: <tom.hirschowitz@univ-savoie.fr>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7F57E431FBD\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 02:58:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 21LqtV-zjHh2 for <notmuch@notmuchmail.org>;\r
+       Thu,  5 Jun 2014 02:58:52 -0700 (PDT)\r
+X-Greylist: delayed 378 seconds by postgrey-1.32 at olra;\r
+       Thu, 05 Jun 2014 02:58:52 PDT\r
+Received: from dsi-mta-out.univ-savoie.fr (dsi-mta-out.univ-savoie.fr\r
+       [193.48.126.73])\r
+       by olra.theworths.org (Postfix) with ESMTP id 73380431FBC\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 02:58:52 -0700 (PDT)\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id E5AF0422A2\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+Received: from dsi-mta-out.univ-savoie.fr ([127.0.0.1])\r
+       by localhost (dsi-mta-out.univ-savoie.fr [127.0.0.1]) (amavisd-new,\r
+       port 10026) with ESMTP id KnSPTAk0dvdc for <notmuch@notmuchmail.org>;\r
+       Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+Received: from dsi-mail-msa1.univ-savoie.fr (dsi-mail-msa1.univ-savoie.fr\r
+       [193.48.126.83])\r
+       by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id CE9F6422A1\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id CC68E14093\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+X-Virus-Scanned: Debian amavisd-new at dsi-mail-msa1.univ-savoie.fr\r
+Received: from dsi-mail-msa1.univ-savoie.fr ([127.0.0.1])\r
+       by localhost (dsi-mail-msa1.univ-savoie.fr [127.0.0.1]) (amavisd-new,\r
+       port 10024) with ESMTP id JtjGUMP2xbrP for <notmuch@notmuchmail.org>;\r
+       Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+Received: from hirscho.lama.univ-savoie.fr (lama-d186.univ-savoie.fr\r
+       [193.48.123.186])\r
+       by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id B271914080\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jun 2014 11:52:32 +0200 (CEST)\r
+From: Tom Hirschowitz <tom.hirschowitz@univ-savoie.fr>\r
+To: notmuch@notmuchmail.org\r
+Cc: \r
+Subject: an emacs macro\r
+User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Thu, 05 Jun 2014 11:52:32 +0200\r
+Message-ID: <87bnu7k7j3.fsf@hirscho.lama.univ-savoie.fr>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 05 Jun 2014 09:58:58 -0000\r
+\r
+\r
+Hi all, \r
+\r
+I'm trying to define a macro for notmuch/emacs which in show-mode would\r
+\r
+ - prompt the user for tags (possibly starting with "+"),\r
+\r
+ - tag the shown message with these tags plus an additional fixed tag,\r
+   say "+local".\r
+\r
+I know next to nothing about emacs/lisp, so I tried to mimick notmuch*.el.\r
+\r
+Here's my most plausible attempt:\r
+\r
+(defun notmuch-show-move (tag-changes)\r
+  "Add the local tag, plus possibly others, given as interactive arguments."\r
+  (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags)\r
+                                              "Tag message" "+")))\r
+  (let* ((tag-changes-with-local (cons "+local" tag-changes))\r
+        (rien (notmuch-tag (notmuch-show-get-message-id) tag-changes-with-local))\r
+        (current-tags (notmuch-show-get-tags))\r
+        (new-tags (notmuch-update-tags current-tags tag-changes-with-local)))\r
+    (unless (equal current-tags new-tags)\r
+      (notmuch-show-set-tags new-tags))))\r
+\r
+(define-key notmuch-show-mode-map (kbd "M") 'notmuch-show-move)\r
+(define-key notmuch-search-mode-map (kbd "M") 'notmuch-show-move)\r
+\r
+This seems to work in show-mode, but not in search-mode.\r
+I'd be grateful for any hint on doing this in tree- and search-modes\r
+(and possibly explanations on why the current version does not work).\r
+\r
+Thanks,\r
+Tom\r