unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Improving spam-tagging keybinding function to act on region in emacs
@ 2014-05-06 12:17 Olivier Berger
  2014-05-06 16:08 ` Mark Walters
  0 siblings, 1 reply; 8+ messages in thread
From: Olivier Berger @ 2014-05-06 12:17 UTC (permalink / raw)
  To: notmuch

Hi.

I've tried tu use the tips indicated at
http://notmuchmail.org/emacstips/#index8h2 so as to add a keybinding to
tag spam messages, and wonder if there's a possibility to make it apply
on selected regions, like what notmuch-search-archive-thread does.

I can achieve the same result using a macro to iterate over lines, but a
single key press to tag results of a search filter would be quite
convienent.

And... at the moment, it seems to me that with the current suggested
lambdas, if one presses 'S' after selecting a whole region results in
tagging all sorts of messages (all ?) with the spam tag ! :-/


Btw, I think that the current examples could be improved by adding a (next-line)
at the end, like :
(define-key notmuch-search-mode-map "S"
        (lambda ()
          "mark messages in thread as spam"
          (interactive)
          (notmuch-search-tag '("+spam" "-inbox"))
          (next-line)))

Thanks in advance.

Best regards,
-- 
Olivier BERGER 
http://www-public.telecom-sudparis.eu/~berger_o/ - OpenPGP-Id: 2048R/5819D7E8
Ingenieur Recherche - Dept INF
Institut Mines-Telecom, Telecom SudParis, Evry (France)

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

* Re: Improving spam-tagging keybinding function to act on region in emacs
  2014-05-06 12:17 Improving spam-tagging keybinding function to act on region in emacs Olivier Berger
@ 2014-05-06 16:08 ` Mark Walters
  2014-05-07 11:37   ` Olivier Berger
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2014-05-06 16:08 UTC (permalink / raw)
  To: Olivier Berger, notmuch


Hello

As this section was rather outdated I have updated to modern notmuch. (In
fact the lisp snippets should work back to at least 0.13)

On Tue, 06 May 2014, Olivier Berger <olivier.berger@telecom-sudparis.eu> wrote:
> Hi.
>
> I've tried tu use the tips indicated at
> http://notmuchmail.org/emacstips/#index8h2 so as to add a keybinding to
> tag spam messages, and wonder if there's a possibility to make it apply
> on selected regions, like what notmuch-search-archive-thread does.

I have added a snippet showing how to do this (and noted that is not
possible in notmuch-tree as we don't have a tag region option there).

> I can achieve the same result using a macro to iterate over lines, but a
> single key press to tag results of a search filter would be quite
> convienent.
>
> And... at the moment, it seems to me that with the current suggested
> lambdas, if one presses 'S' after selecting a whole region results in
> tagging all sorts of messages (all ?) with the spam tag ! :-/
>
>
> Btw, I think that the current examples could be improved by adding a (next-line)
> at the end, like :
> (define-key notmuch-search-mode-map "S"
>         (lambda ()
>           "mark messages in thread as spam"
>           (interactive)
>           (notmuch-search-tag '("+spam" "-inbox"))
>           (next-line)))

I have left this as it is as this works in search mode, but not show
mode and I didn't want to have too many examples. Obviously feel free to
edit the wiki if you like!


Best wishes

Mark

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

* Re: Improving spam-tagging keybinding function to act on region in emacs
  2014-05-06 16:08 ` Mark Walters
@ 2014-05-07 11:37   ` Olivier Berger
  2014-05-22  8:06     ` Mark Walters
  2014-06-06 12:48     ` [PATCH] emacs: search archive tweak Mark Walters
  0 siblings, 2 replies; 8+ messages in thread
From: Olivier Berger @ 2014-05-07 11:37 UTC (permalink / raw)
  To: notmuch

Hi.

Mark Walters <markwalters1009@gmail.com> writes:

> Hello
>
> As this section was rather outdated I have updated to modern notmuch. (In
> fact the lisp snippets should work back to at least 0.13)
>
> On Tue, 06 May 2014, Olivier Berger <olivier.berger@telecom-sudparis.eu> wrote:
>> Hi.
>>
>> I've tried tu use the tips indicated at
>> http://notmuchmail.org/emacstips/#index8h2 so as to add a keybinding to
>> tag spam messages, and wonder if there's a possibility to make it apply
>> on selected regions, like what notmuch-search-archive-thread does.
>
> I have added a snippet showing how to do this (and noted that is not
> possible in notmuch-tree as we don't have a tag region option there).
>

Thanks. This works exactly I like it :-)

>> Btw, I think that the current examples could be improved by adding a (next-line)
>> at the end, like :
>> (define-key notmuch-search-mode-map "S"
>>         (lambda ()
>>           "mark messages in thread as spam"
>>           (interactive)
>>           (notmuch-search-tag '("+spam" "-inbox"))
>>           (next-line)))
>
> I have left this as it is as this works in search mode, but not show
> mode and I didn't want to have too many examples. Obviously feel free to
> edit the wiki if you like!
>

Note that I'm now using the following :
  (define-key notmuch-search-mode-map "S"
        (lambda (&optional beg end)
          "mark messages in thread as spam"
          (interactive (notmuch-search-interactive-region))
          (notmuch-search-tag '("+spam" "-inbox") beg end)
          (if (eq beg end) (notmuch-search-next-thread))))

This offers the possibility to jump to the next line when tagging
individual lines, and not do so when acting on a region.

Btw, such a difference in behaviour may be a tiny, but still nice
improvement on the code of notmuch-search-archive-thread too.

I haven't touched the wiki, as I'm not sure this is the best way to
write it and everyone would be interested.

Hope this helps.

Best regards,

-- 
Olivier BERGER 
http://www-public.telecom-sudparis.eu/~berger_o/ - OpenPGP-Id: 2048R/5819D7E8
Ingenieur Recherche - Dept INF
Institut Mines-Telecom, Telecom SudParis, Evry (France)

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

* Re: Improving spam-tagging keybinding function to act on region in emacs
  2014-05-07 11:37   ` Olivier Berger
@ 2014-05-22  8:06     ` Mark Walters
  2014-05-22  8:59       ` Olivier Berger
  2014-06-06 12:48     ` [PATCH] emacs: search archive tweak Mark Walters
  1 sibling, 1 reply; 8+ messages in thread
From: Mark Walters @ 2014-05-22  8:06 UTC (permalink / raw)
  To: Olivier Berger, notmuch

On Wed, 07 May 2014, Olivier Berger <olivier.berger@telecom-sudparis.eu> wrote:
> Hi.
>
> Mark Walters <markwalters1009@gmail.com> writes:
>
>> Hello
>>
>> As this section was rather outdated I have updated to modern notmuch. (In
>> fact the lisp snippets should work back to at least 0.13)
>>
>> On Tue, 06 May 2014, Olivier Berger <olivier.berger@telecom-sudparis.eu> wrote:
>>> Hi.
>>>
>>> I've tried tu use the tips indicated at
>>> http://notmuchmail.org/emacstips/#index8h2 so as to add a keybinding to
>>> tag spam messages, and wonder if there's a possibility to make it apply
>>> on selected regions, like what notmuch-search-archive-thread does.
>>
>> I have added a snippet showing how to do this (and noted that is not
>> possible in notmuch-tree as we don't have a tag region option there).
>>
>
> Thanks. This works exactly I like it :-)
>
>>> Btw, I think that the current examples could be improved by adding a (next-line)
>>> at the end, like :
>>> (define-key notmuch-search-mode-map "S"
>>>         (lambda ()
>>>           "mark messages in thread as spam"
>>>           (interactive)
>>>           (notmuch-search-tag '("+spam" "-inbox"))
>>>           (next-line)))
>>
>> I have left this as it is as this works in search mode, but not show
>> mode and I didn't want to have too many examples. Obviously feel free to
>> edit the wiki if you like!
>>
>
> Note that I'm now using the following :
>   (define-key notmuch-search-mode-map "S"
>         (lambda (&optional beg end)
>           "mark messages in thread as spam"
>           (interactive (notmuch-search-interactive-region))
>           (notmuch-search-tag '("+spam" "-inbox") beg end)
>           (if (eq beg end) (notmuch-search-next-thread))))
>
> This offers the possibility to jump to the next line when tagging
> individual lines, and not do so when acting on a region.
>
> Btw, such a difference in behaviour may be a tiny, but still nice
> improvement on the code of notmuch-search-archive-thread too.

I think this is worth doing: do you want to send a patch? The above lisp
is fine but I would replace the "if" by "when". (The main difference is
that "when" cannot take an else clause so using when flags up that there
is not an else clause.)

If the above is inconvenient then I am happy to post such a patch.

Best wishes

Mark


>
> I haven't touched the wiki, as I'm not sure this is the best way to
> write it and everyone would be interested.
>
> Hope this helps.
>
> Best regards,
>
> -- 
> Olivier BERGER 
> http://www-public.telecom-sudparis.eu/~berger_o/ - OpenPGP-Id: 2048R/5819D7E8
> Ingenieur Recherche - Dept INF
> Institut Mines-Telecom, Telecom SudParis, Evry (France)
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: Improving spam-tagging keybinding function to act on region in emacs
  2014-05-22  8:06     ` Mark Walters
@ 2014-05-22  8:59       ` Olivier Berger
  0 siblings, 0 replies; 8+ messages in thread
From: Olivier Berger @ 2014-05-22  8:59 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> On Wed, 07 May 2014, Olivier Berger <olivier.berger@telecom-sudparis.eu> wrote:
>>>
>>
>> Note that I'm now using the following :
>>   (define-key notmuch-search-mode-map "S"
>>         (lambda (&optional beg end)
>>           "mark messages in thread as spam"
>>           (interactive (notmuch-search-interactive-region))
>>           (notmuch-search-tag '("+spam" "-inbox") beg end)
>>           (if (eq beg end) (notmuch-search-next-thread))))
>>
>> This offers the possibility to jump to the next line when tagging
>> individual lines, and not do so when acting on a region.
>>
>> Btw, such a difference in behaviour may be a tiny, but still nice
>> improvement on the code of notmuch-search-archive-thread too.
>
> I think this is worth doing: do you want to send a patch? The above lisp
> is fine but I would replace the "if" by "when". (The main difference is
> that "when" cannot take an else clause so using when flags up that there
> is not an else clause.)
>
> If the above is inconvenient then I am happy to post such a patch.
>

AFAI'm concerned, feel free to do so ;)

Best regards,
-- 
Olivier BERGER 
http://www-public.telecom-sudparis.eu/~berger_o/ - OpenPGP-Id: 2048R/5819D7E8
Ingenieur Recherche - Dept INF
Institut Mines-Telecom, Telecom SudParis, Evry (France)

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

* [PATCH] emacs: search archive tweak
  2014-05-07 11:37   ` Olivier Berger
  2014-05-22  8:06     ` Mark Walters
@ 2014-06-06 12:48     ` Mark Walters
  2014-06-07 13:38       ` Tomi Ollila
  2014-07-15 23:10       ` David Bremner
  1 sibling, 2 replies; 8+ messages in thread
From: Mark Walters @ 2014-06-06 12:48 UTC (permalink / raw)
  To: notmuch

notmuch-search-archive-thread moves to the next line after tagging. In
the normal case this makes sense, but if the region is active, it tags
the whole region and then it doesn't really. Thus only move to the
next line if region is not active.
---

In response to the request in the parent message.

Best wishes

Mark

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

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f6bf9c8..2a9876f 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -580,7 +580,8 @@ (defun notmuch-search-archive-thread (&optional unarchive beg end)
   (when notmuch-archive-tags
     (notmuch-search-tag
      (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))
-  (notmuch-search-next-thread))
+  (when (eq beg end)
+    (notmuch-search-next-thread)))
 
 (defun notmuch-search-update-result (result &optional pos)
   "Replace the result object of the thread at POS (or point) by
-- 
1.7.10.4

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

* Re: [PATCH] emacs: search archive tweak
  2014-06-06 12:48     ` [PATCH] emacs: search archive tweak Mark Walters
@ 2014-06-07 13:38       ` Tomi Ollila
  2014-07-15 23:10       ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2014-06-07 13:38 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Fri, Jun 06 2014, Mark Walters <markwalters1009@gmail.com> wrote:

> notmuch-search-archive-thread moves to the next line after tagging. In
> the normal case this makes sense, but if the region is active, it tags
> the whole region and then it doesn't really. Thus only move to the
> next line if region is not active.
> ---

Looks good, although I have no idea how to test this ;)

Tomi

>
> In response to the request in the parent message.
>
> Best wishes
>
> Mark
>
>  emacs/notmuch.el |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index f6bf9c8..2a9876f 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -580,7 +580,8 @@ (defun notmuch-search-archive-thread (&optional unarchive beg end)
>    (when notmuch-archive-tags
>      (notmuch-search-tag
>       (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))
> -  (notmuch-search-next-thread))
> +  (when (eq beg end)
> +    (notmuch-search-next-thread)))
>  
>  (defun notmuch-search-update-result (result &optional pos)
>    "Replace the result object of the thread at POS (or point) by
> -- 
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH] emacs: search archive tweak
  2014-06-06 12:48     ` [PATCH] emacs: search archive tweak Mark Walters
  2014-06-07 13:38       ` Tomi Ollila
@ 2014-07-15 23:10       ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2014-07-15 23:10 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> notmuch-search-archive-thread moves to the next line after tagging. In
> the normal case this makes sense, but if the region is active, it tags
> the whole region and then it doesn't really. Thus only move to the
> next line if region is not active.
> ---

pushed to master.

d

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

end of thread, other threads:[~2014-07-15 23:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 12:17 Improving spam-tagging keybinding function to act on region in emacs Olivier Berger
2014-05-06 16:08 ` Mark Walters
2014-05-07 11:37   ` Olivier Berger
2014-05-22  8:06     ` Mark Walters
2014-05-22  8:59       ` Olivier Berger
2014-06-06 12:48     ` [PATCH] emacs: search archive tweak Mark Walters
2014-06-07 13:38       ` Tomi Ollila
2014-07-15 23:10       ` David Bremner

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).