Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0E412431FAF for ; Wed, 7 May 2014 04:37:25 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cd9q6SOdRd80 for ; Wed, 7 May 2014 04:37:18 -0700 (PDT) Received: from zproxy120.enst.fr (zproxy120.enst.fr [137.194.52.34]) by olra.theworths.org (Postfix) with ESMTP id 9183A431FAE for ; Wed, 7 May 2014 04:37:18 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zproxy120.enst.fr (Postfix) with ESMTP id 93F3A1134DE for ; Wed, 7 May 2014 13:37:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at zproxy120.enst.fr Received: from zproxy120.enst.fr ([127.0.0.1]) by localhost (zproxy120.enst.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kye+ceGE79eY for ; Wed, 7 May 2014 13:37:13 +0200 (CEST) Received: from localhost (bauxite.int-evry.fr [157.159.110.64]) by zproxy120.enst.fr (Postfix) with ESMTPSA id 384A01134A3 for ; Wed, 7 May 2014 13:37:13 +0200 (CEST) From: Olivier Berger To: notmuch@notmuchmail.org Subject: Re: Improving spam-tagging keybinding function to act on region in emacs In-Reply-To: <87mweuzy87.fsf@qmul.ac.uk> References: <87oazb9k5f.fsf@inf-8660.int-evry.fr> <87mweuzy87.fsf@qmul.ac.uk> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Wed, 07 May 2014 13:37:10 +0200 Message-ID: <87bnv92521.fsf@inf-8660.int-evry.fr> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2014 11:37:25 -0000 Hi. Mark Walters 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 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)