From: Ioan-Adrian Ratiu <adi@adirat.com>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: add tag jump menu
Date: Sun, 18 Sep 2016 10:00:24 +0300 [thread overview]
Message-ID: <87h99dg0af.fsf@adiPC.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <1474146583-28476-1-git-send-email-markwalters1009@gmail.com>
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 <markwalters1009@gmail.com> 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
next prev parent reply other threads:[~2016-09-18 7:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-17 21:09 [PATCH] emacs: add tag jump menu Mark Walters
2016-09-18 7:00 ` Ioan-Adrian Ratiu [this message]
2016-09-18 9:08 ` Mark Walters
2016-09-18 12:13 ` David Bremner
2016-09-18 15:43 ` Jani Nikula
2016-09-18 14:30 ` Ioan-Adrian Ratiu
2016-09-18 15:53 ` Jani Nikula
2016-09-18 16:45 ` Ioan-Adrian Ratiu
2016-09-20 17:28 ` Amadeusz Żołnowski
2016-09-18 13:31 ` David Bremner
2016-09-20 3:04 ` Matt Armstrong
2016-09-18 14:06 ` Amadeusz Żołnowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h99dg0af.fsf@adiPC.i-did-not-set--mail-host-address--so-tickle-me \
--to=adi@adirat.com \
--cc=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).