[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-11 Thread Aaron Ecay
On Tue, 10 Jan 2012 18:56:29 -0800, Jameson Graef Rollins  wrote:
> Actually, the show-next argument was already part of the function.  I
> did not introduce it.  And it wasn't optional originally, so if we want
> to change that behavior we should probably do so in a separate patch.

Hrm.  I didn?t communicate as clearly as I could have ? you are correct
that the show-next argument to the notmuch-show-archive-internal function
was pre-existing.  But notmuch-show-tag-thread-internal is a new function,
with potentially expanded usefulness to third-party code.  Thus I think
I?m in the clear to bikeshed about its calling convention.  :) It?s your
patch, though, so it?s your call if you feel that the  goes best
in a new change.

-- 
Aaron Ecay


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-10 Thread Jameson Graef Rollins
On Wed, 11 Jan 2012 00:53:35 -0500, Aaron Ecay  wrote:
> On Tue, 10 Jan 2012 18:56:29 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > Actually, the show-next argument was already part of the function.  I
> > did not introduce it.  And it wasn't optional originally, so if we want
> > to change that behavior we should probably do so in a separate patch.
> 
> Hrm.  I didn?t communicate as clearly as I could have ? you are correct
> that the show-next argument to the notmuch-show-archive-internal function
> was pre-existing.  But notmuch-show-tag-thread-internal is a new function,
> with potentially expanded usefulness to third-party code.  Thus I think
> I?m in the clear to bikeshed about its calling convention.  :) It?s your
> patch, though, so it?s your call if you feel that the  goes best
> in a new change.

No, I see your point, Aaron.  I'll rework it to make it a little clean
and more flexible when I resend.  Thanks again.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-10 Thread Jameson Graef Rollins
On Mon, 09 Jan 2012 00:02:20 -0500, Aaron Ecay  wrote:
> On Sun, 08 Jan 2012 18:49:56 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay  
> > wrote:
> > >
> > > - It would be good to make show-next   This will enable code
> > >   to call the fn with only two arguments, and not showing next will be
> > >   the default behavior.
> > 
> > That's a nice idea.  Probably better for a separate patch, though.
> 
> This patch introduces show-next as a new argument to the function.  So it
> can and should make it , if that is the appropriate semantics
> for it to have.

Actually, the show-next argument was already part of the function.  I
did not introduce it.  And it wasn't optional originally, so if we want
to change that behavior we should probably do so in a separate patch.

> That said, here?s an alternate proposal: provide two functions as the
> ?external? API, namely ?notmuch-show-{add,remove}-tag-thread? (by
> parallelism with ?notmuch-show-{add,remove}-tag?).  These could be
> thin wrappers around ?notmuch-show-tag-thread-internal?, which would
> then not be intended to be called by user code.

I think that's a better idea.  In the next version I'll add something
like this instead.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-10 Thread Jameson Graef Rollins
On Mon, 09 Jan 2012 00:02:20 -0500, Aaron Ecay aarone...@gmail.com wrote:
 On Sun, 08 Jan 2012 18:49:56 -0800, Jameson Graef Rollins 
 jroll...@finestructure.net wrote:
  On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay aarone...@gmail.com wrote:
  
   - It would be good to make show-next optional.  This will enable code
 to call the fn with only two arguments, and not showing next will be
 the default behavior.
  
  That's a nice idea.  Probably better for a separate patch, though.
 
 This patch introduces show-next as a new argument to the function.  So it
 can and should make it optional, if that is the appropriate semantics
 for it to have.

Actually, the show-next argument was already part of the function.  I
did not introduce it.  And it wasn't optional originally, so if we want
to change that behavior we should probably do so in a separate patch.

 That said, here’s an alternate proposal: provide two functions as the
 “external” API, namely ‘notmuch-show-{add,remove}-tag-thread’ (by
 parallelism with ‘notmuch-show-{add,remove}-tag’).  These could be
 thin wrappers around ‘notmuch-show-tag-thread-internal’, which would
 then not be intended to be called by user code.

I think that's a better idea.  In the next version I'll add something
like this instead.

jamie.


pgpJAsOUWyEHn.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-10 Thread Aaron Ecay
On Tue, 10 Jan 2012 18:56:29 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 Actually, the show-next argument was already part of the function.  I
 did not introduce it.  And it wasn't optional originally, so if we want
 to change that behavior we should probably do so in a separate patch.

Hrm.  I didn’t communicate as clearly as I could have – you are correct
that the show-next argument to the notmuch-show-archive-internal function
was pre-existing.  But notmuch-show-tag-thread-internal is a new function,
with potentially expanded usefulness to third-party code.  Thus I think
I’m in the clear to bikeshed about its calling convention.  :) It’s your
patch, though, so it’s your call if you feel that the optional goes best
in a new change.

-- 
Aaron Ecay
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-10 Thread Jameson Graef Rollins
On Wed, 11 Jan 2012 00:53:35 -0500, Aaron Ecay aarone...@gmail.com wrote:
 On Tue, 10 Jan 2012 18:56:29 -0800, Jameson Graef Rollins 
 jroll...@finestructure.net wrote:
  Actually, the show-next argument was already part of the function.  I
  did not introduce it.  And it wasn't optional originally, so if we want
  to change that behavior we should probably do so in a separate patch.
 
 Hrm.  I didn’t communicate as clearly as I could have – you are correct
 that the show-next argument to the notmuch-show-archive-internal function
 was pre-existing.  But notmuch-show-tag-thread-internal is a new function,
 with potentially expanded usefulness to third-party code.  Thus I think
 I’m in the clear to bikeshed about its calling convention.  :) It’s your
 patch, though, so it’s your call if you feel that the optional goes best
 in a new change.

No, I see your point, Aaron.  I'll rework it to make it a little clean
and more flexible when I resend.  Thanks again.

jamie.


pgpzvAbw1h0Kw.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-09 Thread Aaron Ecay
On Sun, 08 Jan 2012 18:49:56 -0800, Jameson Graef Rollins  wrote:
> Thanks so much for the review, Aaron.
> 
> On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay  wrote:
> > A couple of comments on the arguments:
> > - It would be good to make show-next   This will enable code
> >   to call the fn with only two arguments, and not showing next will be
> >   the default behavior.
> 
> That's a nice idea.  Probably better for a separate patch, though.

This patch introduces show-next as a new argument to the function.  So it
can and should make it , if that is the appropriate semantics
for it to have.

> 
> > - A more lispy way of specifying the sign would be to use a
> >   boolean.  Perhaps you could call this ?remove?; a value of ?t? would
> >   remove the tag; ?nil? would add it.  Moving this argument after ?tag?
> >   and also making it  woudl allow this fn to be called with one
> >   arg to add a tag.  (Maybe this is too minimalist and API, however.) 
> 
> That might be more lispy, but it seems a lot less clear to me.  It might
> save a few keystrokes when coding, but it would definitely make the code
> a lot harder to read ("remove" to add a tag?).  I think I would prefer
> people to give the sign explicitly.

Using a string value makes it harder to interface with other code.  For
example, the prefix argument (C-u) is delivered to emacs commands as a
boolean value (nil if no arg, something truthy if the arg is given).  A
plausible custom end user function/keybinding would be one to add a tag
to the open messages, or remove that tag if the prefix arg is given to
the same command.  (So that ?d? deletes and ?C-u d? undeletes, for
example.)  In order to do that, the user?s code has to convert the
prefix arg into a string.  Making something ?lispy? isn?t just about
code readability/saving keystrokes, but also refers to how well the
code interfaces with the conventions used by the rest of the emacs
environment.

That said, here?s an alternate proposal: provide two functions as the
?external? API, namely ?notmuch-show-{add,remove}-tag-thread? (by
parallelism with ?notmuch-show-{add,remove}-tag?).  These could be
thin wrappers around ?notmuch-show-tag-thread-internal?, which would
then not be intended to be called by user code.

> 
> > No second set of parens is needed around tag-function.
> 
> Yeah, I've seen this either way.  I guess it's just a stylistic
> choice.

Using double parens is semantically correct, but makes the code less
idiomatic and harder to read (IMO).  To test my intuition, I looked at
?let? invocations in the Emacs source that have a non-initialized
variable (because the multiple variable case is hard to grep for).
Double parens are used only 3% of the time (44 double vs 1468 single).
Make of this data what you will.

-- 
Aaron Ecay


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-08 Thread Aaron Ecay
Jameson,

Some comments below:

On Sat,  7 Jan 2012 14:28:12 -0800, Jameson Graef Rollins  wrote:
> Instead of having a function that is only used for archiving a thread,
> we instead make it useful for any tagging operation.  The new
> function, notmuch-show-tag-thread-internal, now takes two more
> arguments, for the "sign" of the tagging operation ("-" or "+"), and
> the tag to be added or removed.  This will allow this function to be
> used for any generic thread tagging operation.
> 
> The higher level functions that call this function are modified
> accordingly.
> ---
>  emacs/notmuch-show.el |   34 --
>  1 files changed, 20 insertions(+), 14 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5502efd..1e16f05 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1414,20 +1414,26 @@ argument, hide all of the messages."
>(interactive)
>(backward-button 1))
>  
> -(defun notmuch-show-archive-thread-internal (show-next)
> +(defun notmuch-show-tag-thread-internal (sign tag show-next)

A couple of comments on the arguments:
- It would be good to make show-next   This will enable code
  to call the fn with only two arguments, and not showing next will be
  the default behavior.
- A more lispy way of specifying the sign would be to use a
  boolean.  Perhaps you could call this ?remove?; a value of ?t? would
  remove the tag; ?nil? would add it.  Moving this argument after ?tag?
  and also making it  woudl allow this fn to be called with one
  arg to add a tag.  (Maybe this is too minimalist and API, however.) 

>;; Remove the tag from the current set of messages.
>(goto-char (point-min))
> -  (loop do (notmuch-show-remove-tag "inbox")
> - until (not (notmuch-show-goto-message-next)))
> -  ;; Move to the next item in the search results, if any.
> -  (let ((parent-buffer notmuch-show-parent-buffer))
> -(notmuch-kill-this-buffer)
> -(if parent-buffer
> - (progn
> -   (switch-to-buffer parent-buffer)
> -   (forward-line)
> -   (if show-next
> -   (notmuch-search-show-thread))
> +  (let ((tag-function))

No second set of parens is needed around tag-function.

> +(cond
> + ((string= sign "-")
> +  (setq tag-function 'notmuch-show-remove-tag))
> + ((string= sign "+")
> +  (setq tag-function 'notmuch-show-add-tag)))
> +(loop do (funcall tag-function tag)
> +   until (not (notmuch-show-goto-message-next)))
> +;; Move to the next item in the search results, if any.

Does it make sense to separate the tagging and the movement?  It seems
plausible that some code somewhere might want to add/remove a tag from
all messages in the thread w/o changing the display.

> +(let ((parent-buffer notmuch-show-parent-buffer))
> +  (notmuch-kill-this-buffer)
> +  (if parent-buffer
> +   (progn
> + (switch-to-buffer parent-buffer)
> + (forward-line)
> + (if show-next
> + (notmuch-search-show-thread)))

-- 
Aaron Ecay


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-08 Thread Jameson Graef Rollins
Thanks so much for the review, Aaron.

On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay  wrote:
> A couple of comments on the arguments:
> - It would be good to make show-next   This will enable code
>   to call the fn with only two arguments, and not showing next will be
>   the default behavior.

That's a nice idea.  Probably better for a separate patch, though.

> - A more lispy way of specifying the sign would be to use a
>   boolean.  Perhaps you could call this ?remove?; a value of ?t? would
>   remove the tag; ?nil? would add it.  Moving this argument after ?tag?
>   and also making it  woudl allow this fn to be called with one
>   arg to add a tag.  (Maybe this is too minimalist and API, however.) 

That might be more lispy, but it seems a lot less clear to me.  It might
save a few keystrokes when coding, but it would definitely make the code
a lot harder to read ("remove" to add a tag?).  I think I would prefer
people to give the sign explicitly.

> No second set of parens is needed around tag-function.

Yeah, I've seen this either way.  I guess it's just a stylistic choice.

I think it might make sense, but again I think that's out of the scope
of this patch series.  The point was to make a minimal set of
modifications here.  If we want to separate out the functionality, we
should do that in a separate patch.

Thanks again for the review.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-08 Thread Aaron Ecay
Jameson,

Some comments below:

On Sat,  7 Jan 2012 14:28:12 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 Instead of having a function that is only used for archiving a thread,
 we instead make it useful for any tagging operation.  The new
 function, notmuch-show-tag-thread-internal, now takes two more
 arguments, for the sign of the tagging operation (- or +), and
 the tag to be added or removed.  This will allow this function to be
 used for any generic thread tagging operation.
 
 The higher level functions that call this function are modified
 accordingly.
 ---
  emacs/notmuch-show.el |   34 --
  1 files changed, 20 insertions(+), 14 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 5502efd..1e16f05 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1414,20 +1414,26 @@ argument, hide all of the messages.
(interactive)
(backward-button 1))
  
 -(defun notmuch-show-archive-thread-internal (show-next)
 +(defun notmuch-show-tag-thread-internal (sign tag show-next)

A couple of comments on the arguments:
- It would be good to make show-next optional.  This will enable code
  to call the fn with only two arguments, and not showing next will be
  the default behavior.
- A more lispy way of specifying the sign would be to use a
  boolean.  Perhaps you could call this “remove”; a value of ‘t’ would
  remove the tag; ‘nil’ would add it.  Moving this argument after ‘tag’
  and also making it optional woudl allow this fn to be called with one
  arg to add a tag.  (Maybe this is too minimalist and API, however.) 

;; Remove the tag from the current set of messages.
(goto-char (point-min))
 -  (loop do (notmuch-show-remove-tag inbox)
 - until (not (notmuch-show-goto-message-next)))
 -  ;; Move to the next item in the search results, if any.
 -  (let ((parent-buffer notmuch-show-parent-buffer))
 -(notmuch-kill-this-buffer)
 -(if parent-buffer
 - (progn
 -   (switch-to-buffer parent-buffer)
 -   (forward-line)
 -   (if show-next
 -   (notmuch-search-show-thread))
 +  (let ((tag-function))

No second set of parens is needed around tag-function.

 +(cond
 + ((string= sign -)
 +  (setq tag-function 'notmuch-show-remove-tag))
 + ((string= sign +)
 +  (setq tag-function 'notmuch-show-add-tag)))
 +(loop do (funcall tag-function tag)
 +   until (not (notmuch-show-goto-message-next)))
 +;; Move to the next item in the search results, if any.

Does it make sense to separate the tagging and the movement?  It seems
plausible that some code somewhere might want to add/remove a tag from
all messages in the thread w/o changing the display.

 +(let ((parent-buffer notmuch-show-parent-buffer))
 +  (notmuch-kill-this-buffer)
 +  (if parent-buffer
 +   (progn
 + (switch-to-buffer parent-buffer)
 + (forward-line)
 + (if show-next
 + (notmuch-search-show-thread)))

-- 
Aaron Ecay
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-08 Thread Jameson Graef Rollins
Thanks so much for the review, Aaron.

On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay aarone...@gmail.com wrote:
 A couple of comments on the arguments:
 - It would be good to make show-next optional.  This will enable code
   to call the fn with only two arguments, and not showing next will be
   the default behavior.

That's a nice idea.  Probably better for a separate patch, though.

 - A more lispy way of specifying the sign would be to use a
   boolean.  Perhaps you could call this “remove”; a value of ‘t’ would
   remove the tag; ‘nil’ would add it.  Moving this argument after ‘tag’
   and also making it optional woudl allow this fn to be called with one
   arg to add a tag.  (Maybe this is too minimalist and API, however.) 

That might be more lispy, but it seems a lot less clear to me.  It might
save a few keystrokes when coding, but it would definitely make the code
a lot harder to read (remove to add a tag?).  I think I would prefer
people to give the sign explicitly.

 No second set of parens is needed around tag-function.

Yeah, I've seen this either way.  I guess it's just a stylistic choice.

I think it might make sense, but again I think that's out of the scope
of this patch series.  The point was to make a minimal set of
modifications here.  If we want to separate out the functionality, we
should do that in a separate patch.

Thanks again for the review.

jamie.


pgpIvCV7XaEoi.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-08 Thread Aaron Ecay
On Sun, 08 Jan 2012 18:49:56 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 Thanks so much for the review, Aaron.
 
 On Sun, 08 Jan 2012 20:08:59 -0500, Aaron Ecay aarone...@gmail.com wrote:
  A couple of comments on the arguments:
  - It would be good to make show-next optional.  This will enable code
to call the fn with only two arguments, and not showing next will be
the default behavior.
 
 That's a nice idea.  Probably better for a separate patch, though.

This patch introduces show-next as a new argument to the function.  So it
can and should make it optional, if that is the appropriate semantics
for it to have.

 
  - A more lispy way of specifying the sign would be to use a
boolean.  Perhaps you could call this “remove”; a value of ‘t’ would
remove the tag; ‘nil’ would add it.  Moving this argument after ‘tag’
and also making it optional woudl allow this fn to be called with one
arg to add a tag.  (Maybe this is too minimalist and API, however.) 
 
 That might be more lispy, but it seems a lot less clear to me.  It might
 save a few keystrokes when coding, but it would definitely make the code
 a lot harder to read (remove to add a tag?).  I think I would prefer
 people to give the sign explicitly.

Using a string value makes it harder to interface with other code.  For
example, the prefix argument (C-u) is delivered to emacs commands as a
boolean value (nil if no arg, something truthy if the arg is given).  A
plausible custom end user function/keybinding would be one to add a tag
to the open messages, or remove that tag if the prefix arg is given to
the same command.  (So that ‘d’ deletes and ‘C-u d’ undeletes, for
example.)  In order to do that, the user’s code has to convert the
prefix arg into a string.  Making something “lispy” isn’t just about
code readability/saving keystrokes, but also refers to how well the
code interfaces with the conventions used by the rest of the emacs
environment.

That said, here’s an alternate proposal: provide two functions as the
“external” API, namely ‘notmuch-show-{add,remove}-tag-thread’ (by
parallelism with ‘notmuch-show-{add,remove}-tag’).  These could be
thin wrappers around ‘notmuch-show-tag-thread-internal’, which would
then not be intended to be called by user code.

 
  No second set of parens is needed around tag-function.
 
 Yeah, I've seen this either way.  I guess it's just a stylistic
 choice.

Using double parens is semantically correct, but makes the code less
idiomatic and harder to read (IMO).  To test my intuition, I looked at
‘let’ invocations in the Emacs source that have a non-initialized
variable (because the multiple variable case is hard to grep for).
Double parens are used only 3% of the time (44 double vs 1468 single).
Make of this data what you will.

-- 
Aaron Ecay
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-07 Thread Jameson Graef Rollins
Instead of having a function that is only used for archiving a thread,
we instead make it useful for any tagging operation.  The new
function, notmuch-show-tag-thread-internal, now takes two more
arguments, for the "sign" of the tagging operation ("-" or "+"), and
the tag to be added or removed.  This will allow this function to be
used for any generic thread tagging operation.

The higher level functions that call this function are modified
accordingly.
---
 emacs/notmuch-show.el |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..1e16f05 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1414,20 +1414,26 @@ argument, hide all of the messages."
   (interactive)
   (backward-button 1))

-(defun notmuch-show-archive-thread-internal (show-next)
+(defun notmuch-show-tag-thread-internal (sign tag show-next)
   ;; Remove the tag from the current set of messages.
   (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag "inbox")
-   until (not (notmuch-show-goto-message-next)))
-  ;; Move to the next item in the search results, if any.
-  (let ((parent-buffer notmuch-show-parent-buffer))
-(notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+  (let ((tag-function))
+(cond
+ ((string= sign "-")
+  (setq tag-function 'notmuch-show-remove-tag))
+ ((string= sign "+")
+  (setq tag-function 'notmuch-show-add-tag)))
+(loop do (funcall tag-function tag)
+ until (not (notmuch-show-goto-message-next)))
+;; Move to the next item in the search results, if any.
+(let ((parent-buffer notmuch-show-parent-buffer))
+  (notmuch-kill-this-buffer)
+  (if parent-buffer
+ (progn
+   (switch-to-buffer parent-buffer)
+   (forward-line)
+   (if show-next
+   (notmuch-search-show-thread)))

 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.
@@ -1441,12 +1447,12 @@ being delivered to the same thread. It does not archive 
the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-internal t))
+  (notmuch-show-tag-thread-internal "-" "inbox" t))

 (defun notmuch-show-archive-thread-then-exit ()
   "Archive each message in thread, then exit back to search results."
   (interactive)
-  (notmuch-show-archive-thread-internal nil))
+  (notmuch-show-tag-thread-internal "-" "inbox" nil))

 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
-- 
1.7.7.3



[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-07 Thread Jameson Graef Rollins
Instead of having a function that is only used for archiving a thread,
we instead make it useful for any tagging operation.  The new
function, notmuch-show-tag-thread-internal, now takes two more
arguments, for the sign of the tagging operation (- or +), and
the tag to be added or removed.  This will allow this function to be
used for any generic thread tagging operation.

The higher level functions that call this function are modified
accordingly.
---
 emacs/notmuch-show.el |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..1e16f05 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1414,20 +1414,26 @@ argument, hide all of the messages.
   (interactive)
   (backward-button 1))
 
-(defun notmuch-show-archive-thread-internal (show-next)
+(defun notmuch-show-tag-thread-internal (sign tag show-next)
   ;; Remove the tag from the current set of messages.
   (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag inbox)
-   until (not (notmuch-show-goto-message-next)))
-  ;; Move to the next item in the search results, if any.
-  (let ((parent-buffer notmuch-show-parent-buffer))
-(notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+  (let ((tag-function))
+(cond
+ ((string= sign -)
+  (setq tag-function 'notmuch-show-remove-tag))
+ ((string= sign +)
+  (setq tag-function 'notmuch-show-add-tag)))
+(loop do (funcall tag-function tag)
+ until (not (notmuch-show-goto-message-next)))
+;; Move to the next item in the search results, if any.
+(let ((parent-buffer notmuch-show-parent-buffer))
+  (notmuch-kill-this-buffer)
+  (if parent-buffer
+ (progn
+   (switch-to-buffer parent-buffer)
+   (forward-line)
+   (if show-next
+   (notmuch-search-show-thread)))
 
 (defun notmuch-show-archive-thread ()
   Archive each message in thread, then show next thread from search.
@@ -1441,12 +1447,12 @@ being delivered to the same thread. It does not archive 
the
 entire thread, but only the messages shown in the current
 buffer.
   (interactive)
-  (notmuch-show-archive-thread-internal t))
+  (notmuch-show-tag-thread-internal - inbox t))
 
 (defun notmuch-show-archive-thread-then-exit ()
   Archive each message in thread, then exit back to search results.
   (interactive)
-  (notmuch-show-archive-thread-internal nil))
+  (notmuch-show-tag-thread-internal - inbox nil))
 
 (defun notmuch-show-stash-cc ()
   Copy CC field of current message to kill-ring.
-- 
1.7.7.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch