Improving spam-tagging keybinding function to act on region in emacs
Mark Walters
markwalters1009 at gmail.com
Thu May 22 01:06:54 PDT 2014
On Wed, 07 May 2014, Olivier Berger <olivier.berger at telecom-sudparis.eu> wrote:
> Hi.
>
> Mark Walters <markwalters1009 at 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 at 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 at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list