On 12Feb2021 23:20, boB Stepp <robertvst...@gmail.com> wrote: >Yeah, I think you have. I have kept those earlier emails from you >nicely >flagged in my inbox for reference. Currently I am trying to see if I can get >something I like working with notmuch. I wish I could use notmuch's tagging >capabilities from within Mutt in the sense of adding multiple tags to a single >email or a set of tagged emails. But the only example of an approach is to >try to adapt the macro I cited earlier in this thread which deletes the inbox >tag. I see how to modify this to do *one* tag, but that would be hard-coded >and not very flexible or useful. I'm sure there must be a way to write a >macro to allow for me to enter multiple tags for notmuch, but I don't know >enough about Mutt macros to see a way forwards yet.
"notmuch tag" itself accepts multiple tags. Write a small shell script to prompt for the tags to change (in the same form as notmuch expects i.e. +tag and -tag) which then invokes notmuch. If you mean this macro: macro index <F6> \ "<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\ <pipe-message>notmuch-mutt tag -- -inbox<enter>\ <enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \ "notmuch: remove message from inbox" it: - saves the pipe_decode and wait_key settings, and turns them off - pipes the current message through notmuch-mutt to remove the "inbox" tag - restores the old pipe_decode and wait_key settings The $my_blah= is a standard mutt hack because there's no "push temporary setting or value", and there are no settings called my_*. So people use $my_blah for "user variables". Piping the whole message through notmuch lets notmuch-mutt get the message-id in order to know which item to tag or untag. The it passes "id:$mid" to notmuch, where $mid is the message id. That's the mechanism. To tag things interactively you have 2 issues: - specifying the messages to tag - specifying the tag changes For the latter I'd have a shell script which prompted for that, then ran notmuch. For the former, from inside mutt, I'd think there are 2 ways forward. With a single message you can just pipe it straight into the script, like the above macro does. With multiple messages I think I would tag them, and pipe all of them _separately_ through the script. Now, there are some ways to make that more convenient, particularly these settings: set auto_tag=yes set pipe_split=yes auto_tag=yes causes mutt to apply commands to all tagged messages (if any) or just the current message (if nothing tagged). pipe_split=yes causes mutt to run separate pipes per message when it pipes multiple messages, instead of concatenating them and running one pipe. You want that for notmuch-mutt. The notmuch-mutt script in the example above expects exactly one message on its input, _entirely_ to grab its message-id. So we want pipe_split-yes to invoke the script once for each message. Regarding prompting, I'd write a script like this (untested): #!/bin/sh set -ue echo -n "Enter tags to change (-tag, +tag): " >/dev/tty read tags </dev/tty set -x exec notmuch-mutt tag -- $tags and stick that in your macro above instead of "notmuch-mutt tag -- -inbox". Then you should be able to (mutt) tag some messages and run the macro to update the notmuch tags interactively via the above script. It should be possible to batch this instead of invoking notmuch-mutt many times. Since we can't get message-ids out of mutt itself easily (hence notmuch-mutt reading the message itself to do that) we could try setting pipe_split=no and writing out own script to suck in multiple message-ids, then pass them all to "notmuch tag". You might also benefit from a mutt macro, again via a script like the above, to prompt for both tags and (separately) notmuch search terms, then to just invoke "notmuch tag" with those, skipping notmuch-mutt entirely. See "notmuch help search-terms" for what you can use. Cheers, Cameron Simpson <c...@cskk.id.au>