unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/6] emacs: customization for tag changes on archive
@ 2012-09-02 19:57 Jani Nikula
  2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:57 UTC (permalink / raw)
  To: notmuch

Hi all, Michal Nazarewicz added customization for tag changes on marking
messages as read (commit 1f30f7d2). This series does the same for
archiving, with some cleanups and minor refactoring. As the tag changes
may now be more complicated than simple "-inbox" or "-unread", add
support for "unarchiving" and "unreading" as well.

After this, all the tags recognized and treated special by the emacs
interface can be customized.

An interesting by-product is that you can filter your mail into multiple
different inboxes, each with their own inbox tag, and (after you setup
`notmuch-archive-tags') you can read and archive each inbox separately
with built-in archiving functions.

BR,
Jani.


Jani Nikula (6):
  emacs: add helper for tag change list manipulation
  emacs: fix notmuch-message-replied-tags defcustom type
  emacs: use new tag change helper to mark messages as replied
  emacs: add support for custom tag changes on message/thread archive
  emacs: add support for reversing notmuch-search-archive-thread tag
    changes
  emacs: add support for reversing notmuch-show-mark-read tag changes

 emacs/notmuch-lib.el     |   14 ++++++++++++
 emacs/notmuch-message.el |   26 ++++++++++------------
 emacs/notmuch-show.el    |   54 +++++++++++++++++++++++++++++++---------------
 emacs/notmuch-tag.el     |   17 +++++++++++++++
 emacs/notmuch.el         |   16 ++++++++++----
 5 files changed, 91 insertions(+), 36 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/6] emacs: add helper for tag change list manipulation
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-03 11:33   ` Michal Nazarewicz
  2012-09-02 19:58 ` [PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type Jani Nikula
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

Add a helper to create (and optionally reverse) a list of tag changes.
---
 emacs/notmuch-tag.el |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 0c0fc87..c1aeb99 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run."
   ;; in all cases we return tag-changes as a list
   tag-changes)
 
+(defun notmuch-tag-change-list (tags &optional reverse)
+  "Convert TAGS into a list of tag changes.
+
+Add a \"+\" prefix to any tag in TAGS list that doesn't already
+begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
+\"+\" prefixes with \"-\" and vice versa in the result."
+  (mapcar (lambda (str)
+	    (let ((s (if (not (string-match "^[+-]" str))
+			 (concat "+" str)
+		       str)))
+	      (if reverse
+		  (concat (if (= (string-to-char s) ?-) "+" "-")
+			  (substring s 1))
+		s)))
+	  tags))
+
+
 ;;
 
 (provide 'notmuch-tag)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
  2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-02 19:58 ` [PATCH 3/6] emacs: use new tag change helper to mark messages as replied Jani Nikula
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

---
 emacs/notmuch-message.el |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index d3738bf..3798046 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -31,7 +31,7 @@ if it is prefaced with a \"-\", removed.
 For example, if you wanted to add a \"replied\" tag and remove
 the \"inbox\" and \"todo\", you would set
     (\"replied\" \"-inbox\" \"-todo\"\)"
-  :type 'list
+  :type '(repeat string)
   :group 'notmuch-send)
 
 (defun notmuch-message-mark-replied ()
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/6] emacs: use new tag change helper to mark messages as replied
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
  2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
  2012-09-02 19:58 ` [PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-02 19:58 ` [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive Jani Nikula
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

Clarify documentation while at it.
---
 emacs/notmuch-message.el |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index 3798046..4dc4883 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -23,14 +23,16 @@
 (require 'notmuch-tag)
 (require 'notmuch-mua)
 
-(defcustom notmuch-message-replied-tags '("replied")
-  "Tags to be automatically added to or removed from a message when it is replied to.
-Any tag in the list will be added to a replied message or,
-if it is prefaced with a \"-\", removed.
+(defcustom notmuch-message-replied-tags '("+replied")
+  "List of tag changes to apply to a message when it has been replied to.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message being replied to.
 
 For example, if you wanted to add a \"replied\" tag and remove
-the \"inbox\" and \"todo\", you would set
-    (\"replied\" \"-inbox\" \"-todo\"\)"
+the \"inbox\" and \"todo\" tags, you would set:
+    (\"+replied\" \"-inbox\" \"-todo\"\)"
   :type '(repeat string)
   :group 'notmuch-send)
 
@@ -38,14 +40,8 @@ the \"inbox\" and \"todo\", you would set
   ;; get the in-reply-to header and parse it for the message id.
   (let ((rep (mail-header-parse-addresses (message-field-value "In-Reply-To"))))
     (when (and notmuch-message-replied-tags rep)
-      ;; add a "+" to any tag that is doesn't already begin with a "+"
-      ;; or "-"
-      (let ((tags (mapcar (lambda (str)
-			    (if (not (string-match "^[+-]" str))
-				(concat "+" str)
-			      str))
-			  notmuch-message-replied-tags)))
-	(funcall 'notmuch-tag (notmuch-id-to-query (car (car rep))) tags)))))
+      (funcall 'notmuch-tag (notmuch-id-to-query (car (car rep)))
+	       (notmuch-tag-change-list notmuch-message-replied-tags)))))
 
 (add-hook 'message-send-hook 'notmuch-message-mark-replied)
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
                   ` (2 preceding siblings ...)
  2012-09-02 19:58 ` [PATCH 3/6] emacs: use new tag change helper to mark messages as replied Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-03 11:39   ` Michal Nazarewicz
  2012-09-02 19:58 ` [PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes Jani Nikula
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

Add support for customization of the tag changes that are applied when
a message or a thread is archived. Instead of hard-coded removal of
the "inbox" tag, the user can now specify a list of tag changes to
perform.
---
 emacs/notmuch-lib.el  |   14 ++++++++++++++
 emacs/notmuch-show.el |   29 +++++++++++++++++------------
 emacs/notmuch.el      |   12 ++++++++++--
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 900235b..20d990d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -82,6 +82,20 @@
   :type '(alist :key-type string :value-type string)
   :group 'notmuch-hello)
 
+(defcustom notmuch-archive-tags '("-inbox")
+  "List of tag changes to apply to a message or a thread when it is archived.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message or thread being archived.
+
+For example, if you wanted to remove an \"inbox\" tag and add an
+\"archived\" tag, you would set:
+    (\"-inbox\" \"+archived\")"
+  :type '(repeat string)
+  :group 'notmuch-search
+  :group 'notmuch-show)
+
 (defvar notmuch-folders nil
   "Deprecated name for what is now known as `notmuch-saved-searches'.")
 
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ce5ea6f..e701aec 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1748,18 +1748,20 @@ argument, hide all of the messages."
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.
 
-Archive each message currently shown by removing the \"inbox\"
-tag from each.  If a prefix argument is given, the messages will
-be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed).
+Archive each message currently shown by applying the tag changes
+in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
+default). If a prefix argument is given, the messages will be
+\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
+will be reversed.
 
 Note: This command is safe from any race condition of new messages
 being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive "P")
-  (let ((op (if unarchive "+" "-")))
-    (notmuch-show-tag-all (concat op "inbox"))))
+  (when notmuch-archive-tags
+    (notmuch-show-tag-all
+     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
 
 (defun notmuch-show-archive-thread-then-next ()
   "Archive all messages in the current buffer, then show next thread from search."
@@ -1774,14 +1776,17 @@ buffer."
   (notmuch-show-next-thread))
 
 (defun notmuch-show-archive-message (&optional unarchive)
-  "Archive the current message (remove \"inbox\" tag).
+  "Archive the current message.
 
-If a prefix argument is given, the message will be
-\"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed)."
+Archive the current message by applying the tag changes in
+`notmuch-archive-tags' to it (remove the \"inbox\" tag by
+default). If a prefix argument is given, the message will be
+\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
+will be reversed."
   (interactive "P")
-  (let ((op (if unarchive "+" "-")))
-    (notmuch-show-tag-message (concat op "inbox"))))
+  (when notmuch-archive-tags
+    (apply 'notmuch-show-tag-message
+	   (notmuch-tag-change-list notmuch-archive-tags unarchive))))
 
 (defun notmuch-show-archive-message-then-next-or-exit ()
   "Archive the current message, then show the next open message in the current thread.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1c43d3e..64caa3e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
   (notmuch-search-tag "-"))
 
 (defun notmuch-search-archive-thread ()
-  "Archive the currently selected thread (remove its \"inbox\" tag).
+  "Archive the currently selected thread.
+
+Archive each message in the currently selected thread by applying
+the tag changes in `notmuch-archive-tags' to each (remove the
+\"inbox\" tag by default). If a prefix argument is given, the
+messages will be \"unarchived\" (i.e. the tag changes in
+`notmuch-archive-tags' will be reversed).
 
 This function advances the next thread when finished."
   (interactive)
-  (notmuch-search-tag '("-inbox"))
+  (when notmuch-archive-tags
+    (notmuch-search-tag
+     (notmuch-tag-change-list notmuch-archive-tags)))
   (notmuch-search-next-thread))
 
 (defun notmuch-search-update-result (result &optional pos)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
                   ` (3 preceding siblings ...)
  2012-09-02 19:58 ` [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-02 19:58 ` [PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read " Jani Nikula
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

Since archiving a thread can now be a user customized set of tag
changes, make reversing this easier. Allow a prefix argument to
notmuch-search-archive-thread to reverse the archiving, similar to the
unarchiving in notmuch-show-archive-message.
---
 emacs/notmuch.el |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 64caa3e..a8a85ce 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -593,7 +593,7 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
   (interactive)
   (notmuch-search-tag "-"))
 
-(defun notmuch-search-archive-thread ()
+(defun notmuch-search-archive-thread (&optional unarchive)
   "Archive the currently selected thread.
 
 Archive each message in the currently selected thread by applying
@@ -603,10 +603,10 @@ messages will be \"unarchived\" (i.e. the tag changes in
 `notmuch-archive-tags' will be reversed).
 
 This function advances the next thread when finished."
-  (interactive)
+  (interactive "P")
   (when notmuch-archive-tags
     (notmuch-search-tag
-     (notmuch-tag-change-list notmuch-archive-tags)))
+     (notmuch-tag-change-list notmuch-archive-tags unarchive)))
   (notmuch-search-next-thread))
 
 (defun notmuch-search-update-result (result &optional pos)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read tag changes
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
                   ` (4 preceding siblings ...)
  2012-09-02 19:58 ` [PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes Jani Nikula
@ 2012-09-02 19:58 ` Jani Nikula
  2012-09-03 11:41 ` [PATCH 0/6] emacs: customization for tag changes on archive Michal Nazarewicz
  2012-09-04  7:02 ` Mark Walters
  7 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-02 19:58 UTC (permalink / raw)
  To: notmuch

Since marking a message as read can now be a user customized set of
tag changes, make reversing this easier. Allow a prefix argument to
notmuch-show-mark-read to reverse the marking as read, similar to the
unarchiving in notmuch-show-archive-message.

While at it, update the relevant documentation to match that of other
automatic tagging (i.e. archive and reply).
---
 emacs/notmuch-show.el |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e701aec..1c1cf9c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -184,8 +184,15 @@ provided with an MLA argument nor `completing-read' input."
   :group 'notmuch-show)
 
 (defcustom notmuch-show-mark-read-tags '("-unread")
-  "List of tags to apply when message is read, ie. shown in notmuch-show
-buffer."
+  "List of tag changes to apply to a message when it is marked as read.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message being marked as read.
+
+For example, if you wanted to remove an \"unread\" tag and add a
+\"read\" tag (which would make little sense), you would set:
+    (\"-unread\" \"+read\")"
   :type '(repeat string)
   :group 'notmuch-show)
 
@@ -1390,10 +1397,18 @@ current thread."
   "Are the headers of the current message visible?"
   (notmuch-show-get-prop :headers-visible))
 
-(defun notmuch-show-mark-read ()
-  "Apply `notmuch-show-mark-read-tags' to the message."
+(defun notmuch-show-mark-read (&optional unread)
+  "Mark the current message as read.
+
+Mark the current message as read by applying the tag changes in
+`notmuch-show-mark-read-tags' to it (remove the \"unread\" tag by
+default). If a prefix argument is given, the message will be
+marked as unread, i.e. the tag changes in
+`notmuch-show-mark-read-tags' will be reversed."
+  (interactive "P")
   (when notmuch-show-mark-read-tags
-    (apply 'notmuch-show-tag-message notmuch-show-mark-read-tags)))
+    (apply 'notmuch-show-tag-message
+	   (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))
 
 ;; Functions for getting attributes of several messages in the current
 ;; thread.
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] emacs: add helper for tag change list manipulation
  2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
@ 2012-09-03 11:33   ` Michal Nazarewicz
  2012-09-03 12:06     ` Jani Nikula
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Nazarewicz @ 2012-09-03 11:33 UTC (permalink / raw)
  To: Jani Nikula, notmuch

[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]

Jani Nikula <jani@nikula.org> writes:
> Add a helper to create (and optionally reverse) a list of tag changes.
> ---
>  emacs/notmuch-tag.el |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
> index 0c0fc87..c1aeb99 100644
> --- a/emacs/notmuch-tag.el
> +++ b/emacs/notmuch-tag.el
> @@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run."
>    ;; in all cases we return tag-changes as a list
>    tag-changes)
>  
> +(defun notmuch-tag-change-list (tags &optional reverse)
> +  "Convert TAGS into a list of tag changes.
> +
> +Add a \"+\" prefix to any tag in TAGS list that doesn't already
> +begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
> +\"+\" prefixes with \"-\" and vice versa in the result."
> +  (mapcar (lambda (str)
> +	    (let ((s (if (not (string-match "^[+-]" str))
> +			 (concat "+" str)
> +		       str)))

(if (string-match "^[-+]" str) str (concat "+" str))

Negation only makes things less readable IMO.

> +	      (if reverse
> +		  (concat (if (= (string-to-char s) ?-) "+" "-")
> +			  (substring s 1))
> +		s)))
> +	  tags))
> +
> +
>  ;;
>  
>  (provide 'notmuch-tag)

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive
  2012-09-02 19:58 ` [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive Jani Nikula
@ 2012-09-03 11:39   ` Michal Nazarewicz
  2012-09-03 12:08     ` Jani Nikula
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Nazarewicz @ 2012-09-03 11:39 UTC (permalink / raw)
  To: Jani Nikula, notmuch

[-- Attachment #1: Type: text/plain, Size: 4264 bytes --]

Jani Nikula <jani@nikula.org> writes:
> Add support for customization of the tag changes that are applied when
> a message or a thread is archived. Instead of hard-coded removal of
> the "inbox" tag, the user can now specify a list of tag changes to
> perform.

> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index ce5ea6f..e701aec 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1748,18 +1748,20 @@ argument, hide all of the messages."
>  (defun notmuch-show-archive-thread (&optional unarchive)
>    "Archive each message in thread.
>  
> -Archive each message currently shown by removing the \"inbox\"
> -tag from each.  If a prefix argument is given, the messages will
> -be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
> -removed).
> +Archive each message currently shown by applying the tag changes
> +in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
> +default). If a prefix argument is given, the messages will be
> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
> +will be reversed.
>  
>  Note: This command is safe from any race condition of new messages
>  being delivered to the same thread. It does not archive the
>  entire thread, but only the messages shown in the current
>  buffer."
>    (interactive "P")
> -  (let ((op (if unarchive "+" "-")))
> -    (notmuch-show-tag-all (concat op "inbox"))))
> +  (when notmuch-archive-tags

Strictly speaking (when) should not be needed here (an in the following
changes).  Or is it?

> +    (notmuch-show-tag-all
> +     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>  
>  (defun notmuch-show-archive-thread-then-next ()
>    "Archive all messages in the current buffer, then show next thread from search."
> @@ -1774,14 +1776,17 @@ buffer."
>    (notmuch-show-next-thread))
>  
>  (defun notmuch-show-archive-message (&optional unarchive)
> -  "Archive the current message (remove \"inbox\" tag).
> +  "Archive the current message.
>  
> -If a prefix argument is given, the message will be
> -\"unarchived\" (ie. the \"inbox\" tag will be added instead of
> -removed)."
> +Archive the current message by applying the tag changes in
> +`notmuch-archive-tags' to it (remove the \"inbox\" tag by
> +default). If a prefix argument is given, the message will be
> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
> +will be reversed."
>    (interactive "P")
> -  (let ((op (if unarchive "+" "-")))
> -    (notmuch-show-tag-message (concat op "inbox"))))
> +  (when notmuch-archive-tags
> +    (apply 'notmuch-show-tag-message
> +	   (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>  
>  (defun notmuch-show-archive-message-then-next-or-exit ()
>    "Archive the current message, then show the next open message in the current thread.
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 1c43d3e..64caa3e 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
>    (notmuch-search-tag "-"))
>  
>  (defun notmuch-search-archive-thread ()
> -  "Archive the currently selected thread (remove its \"inbox\" tag).
> +  "Archive the currently selected thread.
> +
> +Archive each message in the currently selected thread by applying
> +the tag changes in `notmuch-archive-tags' to each (remove the
> +\"inbox\" tag by default). If a prefix argument is given, the
> +messages will be \"unarchived\" (i.e. the tag changes in
> +`notmuch-archive-tags' will be reversed).
>  
>  This function advances the next thread when finished."
>    (interactive)
> -  (notmuch-search-tag '("-inbox"))
> +  (when notmuch-archive-tags
> +    (notmuch-search-tag
> +     (notmuch-tag-change-list notmuch-archive-tags)))
>    (notmuch-search-next-thread))
>  
>  (defun notmuch-search-update-result (result &optional pos)
> -- 
> 1.7.9.5
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] emacs: customization for tag changes on archive
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
                   ` (5 preceding siblings ...)
  2012-09-02 19:58 ` [PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read " Jani Nikula
@ 2012-09-03 11:41 ` Michal Nazarewicz
  2012-09-04  7:02 ` Mark Walters
  7 siblings, 0 replies; 16+ messages in thread
From: Michal Nazarewicz @ 2012-09-03 11:41 UTC (permalink / raw)
  To: Jani Nikula, notmuch

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

Jani Nikula <jani@nikula.org> writes:
> Hi all, Michal Nazarewicz added customization for tag changes on marking
> messages as read (commit 1f30f7d2). This series does the same for
> archiving, with some cleanups and minor refactoring. As the tag changes
> may now be more complicated than simple "-inbox" or "-unread", add
> support for "unarchiving" and "unreading" as well.
>
> After this, all the tags recognized and treated special by the emacs
> interface can be customized.
>
> An interesting by-product is that you can filter your mail into multiple
> different inboxes, each with their own inbox tag, and (after you setup
> `notmuch-archive-tags') you can read and archive each inbox separately
> with built-in archiving functions.

Whole patchset looks good to me.  Thanks!

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] emacs: add helper for tag change list manipulation
  2012-09-03 11:33   ` Michal Nazarewicz
@ 2012-09-03 12:06     ` Jani Nikula
  2012-09-06 14:30       ` Tomi Ollila
  0 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-09-03 12:06 UTC (permalink / raw)
  To: Michal Nazarewicz, notmuch

On Mon, 03 Sep 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
> Jani Nikula <jani@nikula.org> writes:
>> Add a helper to create (and optionally reverse) a list of tag changes.
>> ---
>>  emacs/notmuch-tag.el |   17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
>> index 0c0fc87..c1aeb99 100644
>> --- a/emacs/notmuch-tag.el
>> +++ b/emacs/notmuch-tag.el
>> @@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run."
>>    ;; in all cases we return tag-changes as a list
>>    tag-changes)
>>  
>> +(defun notmuch-tag-change-list (tags &optional reverse)
>> +  "Convert TAGS into a list of tag changes.
>> +
>> +Add a \"+\" prefix to any tag in TAGS list that doesn't already
>> +begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
>> +\"+\" prefixes with \"-\" and vice versa in the result."
>> +  (mapcar (lambda (str)
>> +	    (let ((s (if (not (string-match "^[+-]" str))
>> +			 (concat "+" str)
>> +		       str)))
>
> (if (string-match "^[-+]" str) str (concat "+" str))
>
> Negation only makes things less readable IMO.

Agreed.

Jani.

>
>> +	      (if reverse
>> +		  (concat (if (= (string-to-char s) ?-) "+" "-")
>> +			  (substring s 1))
>> +		s)))
>> +	  tags))
>> +
>> +
>>  ;;
>>  
>>  (provide 'notmuch-tag)
>
> -- 
> Best regards,                                         _     _
> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive
  2012-09-03 11:39   ` Michal Nazarewicz
@ 2012-09-03 12:08     ` Jani Nikula
  2012-09-03 13:31       ` Michal Nazarewicz
  0 siblings, 1 reply; 16+ messages in thread
From: Jani Nikula @ 2012-09-03 12:08 UTC (permalink / raw)
  To: Michal Nazarewicz, notmuch

On Mon, 03 Sep 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
> Jani Nikula <jani@nikula.org> writes:
>> Add support for customization of the tag changes that are applied when
>> a message or a thread is archived. Instead of hard-coded removal of
>> the "inbox" tag, the user can now specify a list of tag changes to
>> perform.
>
>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
>> index ce5ea6f..e701aec 100644
>> --- a/emacs/notmuch-show.el
>> +++ b/emacs/notmuch-show.el
>> @@ -1748,18 +1748,20 @@ argument, hide all of the messages."
>>  (defun notmuch-show-archive-thread (&optional unarchive)
>>    "Archive each message in thread.
>>  
>> -Archive each message currently shown by removing the \"inbox\"
>> -tag from each.  If a prefix argument is given, the messages will
>> -be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
>> -removed).
>> +Archive each message currently shown by applying the tag changes
>> +in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
>> +default). If a prefix argument is given, the messages will be
>> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
>> +will be reversed.
>>  
>>  Note: This command is safe from any race condition of new messages
>>  being delivered to the same thread. It does not archive the
>>  entire thread, but only the messages shown in the current
>>  buffer."
>>    (interactive "P")
>> -  (let ((op (if unarchive "+" "-")))
>> -    (notmuch-show-tag-all (concat op "inbox"))))
>> +  (when notmuch-archive-tags
>
> Strictly speaking (when) should not be needed here (an in the following
> changes).  Or is it?

I noticed it was needed in some places, so decided to slam it in all
places for similarity. No harm in that, IMO.

Thanks for the review.

Jani.


>
>> +    (notmuch-show-tag-all
>> +     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>>  
>>  (defun notmuch-show-archive-thread-then-next ()
>>    "Archive all messages in the current buffer, then show next thread from search."
>> @@ -1774,14 +1776,17 @@ buffer."
>>    (notmuch-show-next-thread))
>>  
>>  (defun notmuch-show-archive-message (&optional unarchive)
>> -  "Archive the current message (remove \"inbox\" tag).
>> +  "Archive the current message.
>>  
>> -If a prefix argument is given, the message will be
>> -\"unarchived\" (ie. the \"inbox\" tag will be added instead of
>> -removed)."
>> +Archive the current message by applying the tag changes in
>> +`notmuch-archive-tags' to it (remove the \"inbox\" tag by
>> +default). If a prefix argument is given, the message will be
>> +\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
>> +will be reversed."
>>    (interactive "P")
>> -  (let ((op (if unarchive "+" "-")))
>> -    (notmuch-show-tag-message (concat op "inbox"))))
>> +  (when notmuch-archive-tags
>> +    (apply 'notmuch-show-tag-message
>> +	   (notmuch-tag-change-list notmuch-archive-tags unarchive))))
>>  
>>  (defun notmuch-show-archive-message-then-next-or-exit ()
>>    "Archive the current message, then show the next open message in the current thread.
>> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
>> index 1c43d3e..64caa3e 100644
>> --- a/emacs/notmuch.el
>> +++ b/emacs/notmuch.el
>> @@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
>>    (notmuch-search-tag "-"))
>>  
>>  (defun notmuch-search-archive-thread ()
>> -  "Archive the currently selected thread (remove its \"inbox\" tag).
>> +  "Archive the currently selected thread.
>> +
>> +Archive each message in the currently selected thread by applying
>> +the tag changes in `notmuch-archive-tags' to each (remove the
>> +\"inbox\" tag by default). If a prefix argument is given, the
>> +messages will be \"unarchived\" (i.e. the tag changes in
>> +`notmuch-archive-tags' will be reversed).
>>  
>>  This function advances the next thread when finished."
>>    (interactive)
>> -  (notmuch-search-tag '("-inbox"))
>> +  (when notmuch-archive-tags
>> +    (notmuch-search-tag
>> +     (notmuch-tag-change-list notmuch-archive-tags)))
>>    (notmuch-search-next-thread))
>>  
>>  (defun notmuch-search-update-result (result &optional pos)
>> -- 
>> 1.7.9.5
>>
>
> -- 
> Best regards,                                         _     _
> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive
  2012-09-03 12:08     ` Jani Nikula
@ 2012-09-03 13:31       ` Michal Nazarewicz
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Nazarewicz @ 2012-09-03 13:31 UTC (permalink / raw)
  To: Jani Nikula, notmuch

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

> On Mon, 03 Sep 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
>> Strictly speaking (when) should not be needed here (an in the following
>> changes).  Or is it?

Jani Nikula <jani@nikula.org> writes:
> I noticed it was needed in some places, so decided to slam it in all
> places for similarity. No harm in that, IMO.

Fair enough.

> Thanks for the review.

N/p.

> Jani.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] emacs: customization for tag changes on archive
  2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
                   ` (6 preceding siblings ...)
  2012-09-03 11:41 ` [PATCH 0/6] emacs: customization for tag changes on archive Michal Nazarewicz
@ 2012-09-04  7:02 ` Mark Walters
  7 siblings, 0 replies; 16+ messages in thread
From: Mark Walters @ 2012-09-04  7:02 UTC (permalink / raw)
  To: Jani Nikula, notmuch


Hi

The overall series looks good to me +1. 

I do like the slight tweak suggested by Michal in
id:"xa1tipbvwdb0.fsf@mina86.com" (but don't feel strongly). Also,
ideally there should be some tests, particularly for the multiple tag
case as I imagine most people will just have a single tag so breakage
would be unnoticed.

However, neither of these should hold up the series.

Finally:

> An interesting by-product is that you can filter your mail into multiple
> different inboxes, each with their own inbox tag, and (after you setup
> `notmuch-archive-tags') you can read and archive each inbox separately
> with built-in archiving functions.

I am assuming that you are suggesting adding -inbox1 -inbox2 etc to
notmuch-archive-tags? So the "unarchive" option will not work in this
case? (This is *definitely* not a complaint: just a query in case I am
missing something)

Best wishes

Mark

>
> BR,
> Jani.
>
>
> Jani Nikula (6):
>   emacs: add helper for tag change list manipulation
>   emacs: fix notmuch-message-replied-tags defcustom type
>   emacs: use new tag change helper to mark messages as replied
>   emacs: add support for custom tag changes on message/thread archive
>   emacs: add support for reversing notmuch-search-archive-thread tag
>     changes
>   emacs: add support for reversing notmuch-show-mark-read tag changes
>
>  emacs/notmuch-lib.el     |   14 ++++++++++++
>  emacs/notmuch-message.el |   26 ++++++++++------------
>  emacs/notmuch-show.el    |   54 +++++++++++++++++++++++++++++++---------------
>  emacs/notmuch-tag.el     |   17 +++++++++++++++
>  emacs/notmuch.el         |   16 ++++++++++----
>  5 files changed, 91 insertions(+), 36 deletions(-)
>
> -- 
> 1.7.9.5
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] emacs: add helper for tag change list manipulation
  2012-09-03 12:06     ` Jani Nikula
@ 2012-09-06 14:30       ` Tomi Ollila
  2012-09-06 15:35         ` Jani Nikula
  0 siblings, 1 reply; 16+ messages in thread
From: Tomi Ollila @ 2012-09-06 14:30 UTC (permalink / raw)
  To: Jani Nikula, Michal Nazarewicz, notmuch

On Mon, Sep 03 2012, Jani Nikula wrote:

> On Mon, 03 Sep 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
>> Jani Nikula <jani@nikula.org> writes:
>>> Add a helper to create (and optionally reverse) a list of tag changes.
>>> ---
>>>  emacs/notmuch-tag.el |   17 +++++++++++++++++
>>>  1 file changed, 17 insertions(+)
>>>
>>> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
>>> index 0c0fc87..c1aeb99 100644
>>> --- a/emacs/notmuch-tag.el
>>> +++ b/emacs/notmuch-tag.el
>>> @@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run."
>>>    ;; in all cases we return tag-changes as a list
>>>    tag-changes)
>>>  
>>> +(defun notmuch-tag-change-list (tags &optional reverse)
>>> +  "Convert TAGS into a list of tag changes.
>>> +
>>> +Add a \"+\" prefix to any tag in TAGS list that doesn't already
>>> +begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
>>> +\"+\" prefixes with \"-\" and vice versa in the result."
>>> +  (mapcar (lambda (str)
>>> +	    (let ((s (if (not (string-match "^[+-]" str))
>>> +			 (concat "+" str)
>>> +		       str)))
>>
>> (if (string-match "^[-+]" str) str (concat "+" str))
>>
>> Negation only makes things less readable IMO.
>
> Agreed.

The whole series LGTM -- but are you still going to do 
changes here ?

> Jani.

Tomi


>
>>
>>> +	      (if reverse
>>> +		  (concat (if (= (string-to-char s) ?-) "+" "-")
>>> +			  (substring s 1))
>>> +		s)))
>>> +	  tags))
>>> +
>>> +
>>>  ;;
>>>  
>>>  (provide 'notmuch-tag)
>>
>> -- 
>> Best regards,                                         _     _
>> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
>> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
>> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] emacs: add helper for tag change list manipulation
  2012-09-06 14:30       ` Tomi Ollila
@ 2012-09-06 15:35         ` Jani Nikula
  0 siblings, 0 replies; 16+ messages in thread
From: Jani Nikula @ 2012-09-06 15:35 UTC (permalink / raw)
  To: Tomi Ollila, Michal Nazarewicz, notmuch

On Thu, 06 Sep 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> The whole series LGTM -- but are you still going to do 
> changes here ?

Yes, id:"cover.1346945257.git.jani@nikula.org"

J.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-09-06 15:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
2012-09-03 11:33   ` Michal Nazarewicz
2012-09-03 12:06     ` Jani Nikula
2012-09-06 14:30       ` Tomi Ollila
2012-09-06 15:35         ` Jani Nikula
2012-09-02 19:58 ` [PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type Jani Nikula
2012-09-02 19:58 ` [PATCH 3/6] emacs: use new tag change helper to mark messages as replied Jani Nikula
2012-09-02 19:58 ` [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive Jani Nikula
2012-09-03 11:39   ` Michal Nazarewicz
2012-09-03 12:08     ` Jani Nikula
2012-09-03 13:31       ` Michal Nazarewicz
2012-09-02 19:58 ` [PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes Jani Nikula
2012-09-02 19:58 ` [PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read " Jani Nikula
2012-09-03 11:41 ` [PATCH 0/6] emacs: customization for tag changes on archive Michal Nazarewicz
2012-09-04  7:02 ` Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).