From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id DB3946DE0B2F for ; Sun, 18 Sep 2016 00:00:30 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.672 X-Spam-Level: X-Spam-Status: No, score=-0.672 tagged_above=-999 required=5 tests=[AWL=0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GwOIZV7mx3PL for ; Sun, 18 Sep 2016 00:00:29 -0700 (PDT) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 4EB8F6DE0B14 for ; Sun, 18 Sep 2016 00:00:29 -0700 (PDT) Received: by mail-wm0-f67.google.com with SMTP id b184so9915265wma.3 for ; Sun, 18 Sep 2016 00:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adirat-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=3q+yKtJJ7Aynqpo5SQ0N/dyxXciwEupfiHKVcrQsZ/o=; b=sB76utAWPxp9j4jYZRoJk8nwrdM4vTOGNYoV+OHxYuC+oK/0NCSnBi9bAVL6pHMG57 S5oOVrw5th/z3YEE2xeX8zkwFtJcI0O51QfHNosB2KLF1mBHMQ+dQ973mkPu2kGmXeoo E+E1OwblRziniCm1Ve9mwT0zKevPMQKCTzjxTqPCjYdHaem2J6kVIrzA7xbKkgWHY6bY lBxYw9MShIYhEQvbV7NGwEFMJBwltpHFJE6RqD/ZoVMsp8Cwaj3JjZEeQSK3gPeUQPPg W1GVDI1+98Z+Hklg4DL4gYYkUm/6MqUtosmxrLWEE9HvuKj8G7tqqZmdtvOr/I4d6jfd 75bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=3q+yKtJJ7Aynqpo5SQ0N/dyxXciwEupfiHKVcrQsZ/o=; b=TNzUBH2Ft02H9J4k+zZiww0apiPeK+Ss4qgJQI1bjnVHLgQOCPUY1LFhvo+dYn5OKf OUWDVEo7ROwzj7zz0SvXVzF0RuDAAC5rwUb0vaqulRXUSS2OjI1+pjNl7Mr11fSs8APQ CxC2819KaZ4sAePiIJ4njd6IIA0Ewe5Sfk7rUGD4O54vcKJpkay5/EIrxA0hjg0ztn1s W2t3raNHBVY6zTtT5kYcRf8r2wDG6jZ3XjAYDzmFCbE4Wstk0X3w7lCrHzBVDfRjMXuP AcausAhRNhiJXpEOIXTnxjS8xxMrSUImIpZhVf6TnwVtkSjcf4w6Y30pOevBYBA3aSBz xl5A== X-Gm-Message-State: AE9vXwNScCt6+oJM1BvYt+N/ogakGmX+K+68rd+TLvXU23Ivg+m+nu1+gMPYEMVf8nF9rQ== X-Received: by 10.194.21.200 with SMTP id x8mr19399145wje.129.1474182027075; Sun, 18 Sep 2016 00:00:27 -0700 (PDT) Received: from adiPC ([188.24.78.211]) by smtp.gmail.com with ESMTPSA id a1sm16500577wju.41.2016.09.18.00.00.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Sep 2016 00:00:26 -0700 (PDT) From: Ioan-Adrian Ratiu To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: add tag jump menu In-Reply-To: <1474146583-28476-1-git-send-email-markwalters1009@gmail.com> References: <1474146583-28476-1-git-send-email-markwalters1009@gmail.com> Date: Sun, 18 Sep 2016 10:00:24 +0300 Message-ID: <87h99dg0af.fsf@adiPC.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Sun, 18 Sep 2016 07:00:31 -0000 Hi I have implemented something similar in my tree and I really like the idea. I have one issue though. On Sat, 17 Sep 2016, Mark Walters wrote: > Add a "jump" style menu for doing tagging operations. > --- > > Jani suggested something like this on irc today. This is a first cut > to see if people like it. By default the tagging jump menu is bound to > k (which works in search/show/tree mode), and has the following options > > a (Archive) -inbox -unread > u (Mark Read) -unread > d (Delete) +deleted > > If you do ctrl-u k the it will do the reverse operation. I know C-u is default emacs behaviour but I find very cumbersone to do C-u for unapplying the tag. What I do and want is to simply apply the tag when pressing "d" then unapply it when pressing "d" again if the mail/thread already contains the deleted tag (basically it's a toggle). Here's an example of code I'm using: (define-key notmuch-show-mode-map "d" (lambda () "toggle deleted tag for message" (interactive) (if (member "deleted" (notmuch-show-get-tags)) (notmuch-show-tag (list "-deleted")) (notmuch-show-tag (list "+deleted"))))) (define-key notmuch-search-mode-map "d" (lambda (&optional beg end) "toggle deleted tag for message" (interactive (notmuch-search-interactive-region)) (if (member "deleted" (notmuch-search-get-tags)) (notmuch-search-tag (list "-deleted") beg end) (notmuch-search-tag (list "+deleted") beg end)))) It works really well for me :). "inbox" and other tags work similarly. > > To customize you want the variable notmuch-tagging-keys in the group > notmuch-tag. It is only very lightly tested but seems to work. And the > docstrings will definitely need some work. > > Best wishes > > Mark > > > > > > > > emacs/notmuch-lib.el | 4 ++++ > emacs/notmuch-show.el | 1 + > emacs/notmuch-tag.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ > emacs/notmuch-tree.el | 1 + > emacs/notmuch.el | 1 + > 5 files changed, 58 insertions(+) > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > index 2f015b0..b2cdace 100644 > --- a/emacs/notmuch-lib.el > +++ b/emacs/notmuch-lib.el > @@ -57,6 +57,10 @@ > > (custom-add-to-group 'notmuch-send 'message 'custom-group) > > +(defgroup notmuch-tag nil > + "Tags and tagging in Notmuch." > + :group 'notmuch) > + > (defgroup notmuch-crypto nil > "Processing and display of cryptographic MIME parts." > :group 'notmuch) > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 5a585f3..756c7dd 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1428,6 +1428,7 @@ reset based on the original query." > (define-key map "V" 'notmuch-show-view-raw-message) > (define-key map "c" 'notmuch-show-stash-map) > (define-key map "h" 'notmuch-show-toggle-visibility-headers) > + (define-key map "k" 'notmuch-tag-jump) > (define-key map "*" 'notmuch-show-tag-all) > (define-key map "-" 'notmuch-show-remove-tag) > (define-key map "+" 'notmuch-show-add-tag) > diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el > index ec3c964..4d2feef 100644 > --- a/emacs/notmuch-tag.el > +++ b/emacs/notmuch-tag.el > @@ -28,6 +28,37 @@ > (require 'crm) > (require 'notmuch-lib) > > +(declare-function notmuch-search-tag "notmuch" tag-changes) > +(declare-function notmuch-show-tag "notmuch-show" tag-changes) > +(declare-function notmuch-tree-tag "notmuch-tree" tag-changes) > + > +(autoload 'notmuch-jump "notmuch-jump") > + > + > +(define-widget 'notmuch-tag-key-type 'list > + "A single key tagging binding" > + :format "%v" > + :args '((list :inline t > + :format "%v" > + (key-sequence :tag "Key") > + (repeat :tag "Tag operations" (string :format "%v" :tag "change")) > + (checklist :inline t > + (string :tag "Short Name"))))) > + > +(defcustom notmuch-tagging-keys > + `((,(kbd "a") ("-inbox" "-unread") "Archive") > + (,(kbd "u") ("-unread") "Mark read") > + (,(kbd "d") ("+deleted") "Delete")) > + "A list of keys and corresponding tagging operations > + > +For each key you can specify a sequence of tagging operations to > +apply. By default they will appear in the tagging buffer just as > +this sequence of tags, but you can specify a short name if you > +prefer." > + :tag "List of tagging bindings" > + :type '(repeat notmuch-tag-key-type) > + :group 'notmuch-tag) > + > (define-widget 'notmuch-tag-format-type 'lazy > "Customize widget for notmuch-tag-format and friends" > :type '(alist :key-type (regexp :tag "Tag") > @@ -437,6 +468,26 @@ begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all > s))) > tags)) > > +(defun notmuch-tag-jump (reverse) > + (interactive "P") > + (let (action-map) > + (dolist (binding notmuch-tagging-keys) > + (let* ((tag-function (case major-mode > + (notmuch-search-mode #'notmuch-search-tag) > + (notmuch-show-mode #'notmuch-show-tag) > + (notmuch-tree-mode #'notmuch-tree-tag))) > + (key (first binding)) > + (tag-change (if reverse > + (notmuch-tag-change-list (second binding) 't) > + (second binding))) > + (name (if (third binding) > + (if reverse (concat "Undo " (third binding)) > + (third binding)) > + (mapconcat #'identity tag-change " ")))) > + (push (list key name > + `(lambda () (,tag-function ',tag-change))) > + action-map))) > + (notmuch-jump action-map "Tag: "))) > > ;; > > diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el > index d864e6d..5431384 100644 > --- a/emacs/notmuch-tree.el > +++ b/emacs/notmuch-tree.el > @@ -276,6 +276,7 @@ FUNC." > (define-key map "P" 'notmuch-tree-prev-message) > (define-key map (kbd "M-p") 'notmuch-tree-prev-thread) > (define-key map (kbd "M-n") 'notmuch-tree-next-thread) > + (define-key map "k" 'notmuch-tag-jump) > (define-key map "-" 'notmuch-tree-remove-tag) > (define-key map "+" 'notmuch-tree-add-tag) > (define-key map "*" 'notmuch-tree-tag-thread) > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index 8e14692..888672b 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -169,6 +169,7 @@ there will be called at other points of notmuch execution." > (define-key map "t" 'notmuch-search-filter-by-tag) > (define-key map "l" 'notmuch-search-filter) > (define-key map [mouse-1] 'notmuch-search-show-thread) > + (define-key map "k" 'notmuch-tag-jump) > (define-key map "*" 'notmuch-search-tag-all) > (define-key map "a" 'notmuch-search-archive-thread) > (define-key map "-" 'notmuch-search-remove-tag) > -- > 2.1.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch