Re: [notmuch] [PATCH] Support for deletion (patch included)
authorracin <racin@free.fr>
Sat, 27 Feb 2010 10:34:27 +0000 (11:34 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:18 +0000 (09:36 -0800)
4f/d4a854892db47429958250822a20b8598caa3e [new file with mode: 0644]

diff --git a/4f/d4a854892db47429958250822a20b8598caa3e b/4f/d4a854892db47429958250822a20b8598caa3e
new file mode 100644 (file)
index 0000000..7fc338a
--- /dev/null
@@ -0,0 +1,288 @@
+Return-Path: <racin@free.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 C8925431FBD\r
+       for <notmuch@notmuchmail.org>; Sat, 27 Feb 2010 02:34:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.691\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.691 tagged_above=-999 required=5 tests=[AWL=0.908,\r
+       BAYES_00=-2.599] autolearn=unavailable\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 mPnM5VeXFQt1 for <notmuch@notmuchmail.org>;\r
+       Sat, 27 Feb 2010 02:34:43 -0800 (PST)\r
+Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5])\r
+       by olra.theworths.org (Postfix) with ESMTP id 12C76431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 27 Feb 2010 02:34:41 -0800 (PST)\r
+Received: from smtp5-g21.free.fr (localhost [127.0.0.1])\r
+       by smtp5-g21.free.fr (Postfix) with ESMTP id 4614DD4812B;\r
+       Sat, 27 Feb 2010 11:34:29 +0100 (CET)\r
+Received: from zimbra1-e1.priv.proxad.net (zimbra1-e1.priv.proxad.net\r
+       [172.20.243.151])\r
+       by smtp5-g21.free.fr (Postfix) with ESMTP id 4376FD480C8;\r
+       Sat, 27 Feb 2010 11:34:27 +0100 (CET)\r
+Date: Sat, 27 Feb 2010 11:34:27 +0100 (CET)\r
+From: racin@free.fr\r
+To: Carl Worth <cworth@cworth.org>\r
+Message-ID:\r
+ <1673492941.5760781267266866949.JavaMail.root@zimbra1-e1.priv.proxad.net>\r
+In-Reply-To:\r
+ <1427711643.5760731267266834921.JavaMail.root@zimbra1-e1.priv.proxad.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; \r
+       boundary="----=_Part_211406_2111002656.1267266866945"\r
+X-Originating-IP: [82.239.207.166]\r
+X-Mailer: Zimbra 5.0 (ZimbraWebClient - FF3.0\r
+       (Linux)/5.0.15_GA_2815.UBUNTU8_64)\r
+X-Authenticated-User: racin@free.fr\r
+Cc: notmuch@notmuchmail.org\r
+Subject: Re: [notmuch] [PATCH] Support for deletion (patch included)\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: Sat, 27 Feb 2010 10:34:45 -0000\r
+\r
+------=_Part_211406_2111002656.1267266866945\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Here they are; as I don't know how to include them in the body, I put the p=\r
+atches as attachments. I hope this=20\r
+will be convienient enough for you.\r
+\r
+\r
+Matthieu\r
+\r
+----- racin@free.fr a =C3=A9crit :\r
+\r
+> Carl: The patch in the mail has problems; apparently I have to\r
+> manually add scissorlines to the mail for it\r
+> to be processed by git-am. I thought this was automatically added. (I\r
+> hate the git UI -- nothing is consistent,\r
+> concepts have different names, the definition of scissor lines is as\r
+> precise as "A line that mainly consists of scissors (either ">8" or\r
+> "8<") and perforation (dash "-") --, but I guess we can get used to it\r
+> after a while...)\r
+>=20\r
+> I'll send you a proper patch as soon as I can. Meanwhile, I'm sure you\r
+> have comments on this updated patch!\r
+>=20\r
+> Matthieu\r
+>\r
+------=_Part_211406_2111002656.1267266866945\r
+Content-Type: text/x-diff;\r
+       name=0002-Add-support-for-deletion-in-the-emacs-interface.patch\r
+Content-Transfer-Encoding: 7bit\r
+Content-Disposition: attachment;\r
+       filename=0002-Add-support-for-deletion-in-the-emacs-interface.patch\r
+\r
+>From 0073152e3fa7dd11d88de28e87eec7762cdbbbeb Mon Sep 17 00:00:00 2001\r
+From: Matthieu Lemerre <racin@free.fr>\r
+Date: Thu, 25 Feb 2010 00:25:51 +0100\r
+Subject: [PATCH 2/2] Add support for deletion in the emacs interface\r
+\r
+Add "d" keybinding in notmuch-show and notmuch-summary to delete the current\r
+thread. Adds "D" keybinding to delete the current message in notmuch-show.\r
+Adds a "deleted" folder. Omit deleted items from searchs if no prefix arg.\r
+Adds history management to make searching deleted items more convenient.\r
+\r
+---\r
+ notmuch.el |   56 +++++++++++++++++++++++++++++++++++++++++++++++++-------\r
+ 1 files changed, 49 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 5d7342a..0285573 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -92,6 +92,8 @@\r
+     (define-key map "x" 'notmuch-show-archive-thread-then-exit)\r
+     (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)\r
+     (define-key map "a" 'notmuch-show-archive-thread)\r
++    (define-key map "d" 'notmuch-show-delete-thread)\r
++    (define-key map "D" 'notmuch-show-delete-message)\r
+     (define-key map "p" 'notmuch-show-previous-message)\r
+     (define-key map "N" 'notmuch-show-mark-read-then-next-open-message)\r
+     (define-key map "n" 'notmuch-show-next-message)\r
+@@ -380,6 +382,23 @@ buffer."\r
+   (notmuch-show-archive-thread)\r
+   (kill-this-buffer))\r
\r
++(defun notmuch-show-delete-message ()\r
++  "Delete current message (sets its deleted tag)."\r
++  (interactive)\r
++  (notmuch-show-add-tag "deleted"))\r
++\r
++(defun notmuch-show-delete-thread()\r
++  "Delete each message in thread."\r
++  (interactive)\r
++  (notmuch-show-forall-in-thread\r
++   (notmuch-show-delete-message)))\r
++\r
++(defun notmuch-show-delete-thread-and-exit()\r
++  "Delete each message in thread, then exit back to search results."\r
++  (interactive)\r
++  (notmuch-show-delete-thread)\r
++  (kill-this-buffer))\r
++\r
+ (defun notmuch-show-mark-read-then-archive-then-exit ()\r
+   "Remove unread tags from thread, then archive and exit to search results."\r
+   (interactive)\r
+@@ -1227,6 +1246,7 @@ matching this search term are shown if non-nil. "\r
+     (define-key map [mouse-1] 'notmuch-search-show-thread)\r
+     (define-key map "*" 'notmuch-search-operate-all)\r
+     (define-key map "a" 'notmuch-search-archive-thread)\r
++    (define-key map "d" 'notmuch-search-delete-thread)\r
+     (define-key map "-" 'notmuch-search-remove-tag)\r
+     (define-key map "+" 'notmuch-search-add-tag)\r
+     (define-key map (kbd "RET") 'notmuch-search-show-thread)\r
+@@ -1235,6 +1255,7 @@ matching this search term are shown if non-nil. "\r
+ (fset 'notmuch-search-mode-map notmuch-search-mode-map)\r
\r
+ (defvar notmuch-search-query-string)\r
++(defvar notmuch-search-history nil)\r
+ (defvar notmuch-search-oldest-first t\r
+   "Show the oldest mail first in the search-mode")\r
\r
+@@ -1446,6 +1467,13 @@ This function advances the next thread when finished."\r
+   (notmuch-search-remove-tag "inbox")\r
+   (forward-line))\r
\r
++(defun notmuch-search-delete-thread ()\r
++  "Mark the currently selected thread as deleted (set its \"deleted\" tag).\r
++This function advances the next thread when finished."\r
++  (interactive)\r
++  (notmuch-search-add-tag "deleted")\r
++  (forward-line))\r
++\r
+ (defun notmuch-search-process-sentinel (proc msg)\r
+   "Add a message to let user know when \"notmuch search\" exits"\r
+   (let ((buffer (process-buffer proc))\r
+@@ -1520,10 +1548,22 @@ characters as well as `_.+-'.\r
+          (append action-split (list notmuch-search-query-string) nil))))\r
\r
+ ;;;###autoload\r
+-(defun notmuch-search (query &optional oldest-first)\r
+-  "Run \"notmuch search\" with the given query string and display results."\r
+-  (interactive "sNotmuch search: ")\r
+-  (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))\r
++(defun notmuch-search (query &optional oldest-first include-deleted)\r
++  "Run \"notmuch search\" with the given query string and display results.\r
++\r
++With prefix argument, include deleted items.\r
++"\r
++  (interactive (let* ((prefix current-prefix-arg)\r
++                    (query (if prefix\r
++                               (read-string "Notmuch search (including deleted): "\r
++                                            notmuch-search-query-string\r
++                                            'notmuch-search-history)\r
++                             (read-string "Notmuch search: " nil\r
++                                          'notmuch-search-history))))\r
++               (list query nil prefix)))\r
++  (let ((real-query (if include-deleted query \r
++                    (concat "not tag:deleted and (" query ")")))\r
++      (buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))\r
+     (switch-to-buffer buffer)\r
+     (notmuch-search-mode)\r
+     (set 'notmuch-search-query-string query)\r
+@@ -1539,7 +1579,7 @@ characters as well as `_.+-'.\r
+       (let ((proc (start-process-shell-command\r
+                    "notmuch-search" buffer notmuch-command "search"\r
+                    (if oldest-first "--sort=oldest-first" "--sort=newest-first")\r
+-                   (shell-quote-argument query))))\r
++                   (shell-quote-argument real-query))))\r
+         (set-process-sentinel proc 'notmuch-search-process-sentinel)\r
+         (set-process-filter proc 'notmuch-search-process-filter))))\r
+     (run-hooks 'notmuch-search-hook)))\r
+@@ -1587,7 +1627,7 @@ search."\r
\r
+ Runs a new search matching only messages that match both the\r
+ current search results AND the additional query string provided."\r
+-  (interactive "sFilter search: ")\r
++  (interactive "sFilter search:")\r
+   (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query) (concat "( " query " )") query)))\r
+     (notmuch-search (concat notmuch-search-query-string " and " grouped-query) notmuch-search-oldest-first)))\r
\r
+@@ -1630,7 +1670,9 @@ current search results AND that are tagged with the given tag."\r
\r
+ (fset 'notmuch-folder-mode-map notmuch-folder-mode-map)\r
\r
+-(defcustom notmuch-folders (quote (("inbox" . "tag:inbox") ("unread" . "tag:unread")))\r
++(defcustom notmuch-folders (quote (("inbox" . "tag:inbox") \r
++                                 ("unread" . "tag:unread")\r
++                                 ("deleted" . "tag:deleted")))\r
+   "List of searches for the notmuch folder view"\r
+   :type '(alist :key-type (string) :value-type (string))\r
+   :group 'notmuch)\r
+-- \r
+1.6.5\r
+\r
+\r
+------=_Part_211406_2111002656.1267266866945\r
+Content-Type: text/x-diff;\r
+       name=0001-Add-and-use-notmuch-show-forall-in-thread-macro.patch\r
+Content-Transfer-Encoding: 7bit\r
+Content-Disposition: attachment;\r
+       filename=0001-Add-and-use-notmuch-show-forall-in-thread-macro.patch\r
+\r
+>From bdee9558d93bffb97c80632f522288e059deb7c2 Mon Sep 17 00:00:00 2001\r
+From: Matthieu Lemerre <racin@free.fr>\r
+Date: Thu, 25 Feb 2010 00:24:24 +0100\r
+Subject: [PATCH 1/2] Add and use notmuch-show-forall-in-thread macro\r
+\r
+This macro allows to apply a message-related command to every message\r
+in a thread.\r
+\r
+---\r
+ notmuch.el |   17 +++++++++++------\r
+ 1 files changed, 11 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 6482170..5d7342a 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -321,17 +321,22 @@ pseudoheader summary"\r
+                        (cons (notmuch-show-get-message-id) nil)))\r
+         (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))\r
\r
+-(defun notmuch-show-archive-thread-maybe-mark-read (markread)\r
+-  (save-excursion\r
++(defmacro notmuch-show-forall-in-thread (&rest body)\r
++  "Executes BODY with point in all messages of the current thread."\r
++  `(save-excursion\r
+     (goto-char (point-min))\r
+     (while (not (eobp))\r
+-      (if markread\r
+-        (notmuch-show-remove-tag "unread" "inbox")\r
+-      (notmuch-show-remove-tag "inbox"))\r
++      ,@body\r
+       (if (not (eobp))\r
+         (forward-char))\r
+       (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))\r
+-        (goto-char (point-max)))))\r
++        (goto-char (point-max))))))\r
++\r
++(defun notmuch-show-archive-thread-maybe-mark-read (markread)\r
++  (notmuch-show-forall-in-thread\r
++      (if markread\r
++        (notmuch-show-remove-tag "unread" "inbox")\r
++      (notmuch-show-remove-tag "inbox")))\r
+   (let ((parent-buffer notmuch-show-parent-buffer))\r
+     (kill-this-buffer)\r
+     (if parent-buffer\r
+-- \r
+1.6.5\r
+\r
+\r
+------=_Part_211406_2111002656.1267266866945--\r