Improving spam-tagging keybinding function to act on region in emacs

Olivier Berger olivier.berger at telecom-sudparis.eu
Wed May 7 04:37:10 PDT 2014


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


More information about the notmuch mailing list