Search code examples
mutt

mutt - index search on yanked text


I'm wondering if there is anyway to "search" or "limit" in the mutt index based on text yanked from either an "edit" or "page" mode.

I'm trying to build a macro for the index, that when pressed will limit the index to only mail from (~f) the From: .*$ regex of the current item.

What this will help me to do is see the context of all the messages from a particular sender... it also helps when people accidentally "break threads" when they shouldn't.

I was hoping it would be similar to vim as discussed here and i could yank text from one area and then type ^R" to paste back into the "search" or "limit" prompt.

I tried to make a macro to go into edit and then search for the from string, but i can't figure out how to paste it back into anything in the index...


Solution

  • Here is an incomplete (and ugly) solution:

    macro index O "|grep ^From | awk 'NR==1 {printf \"macro index Q l%s\",$2}' > /tmp/from;echo>>/tmp/from\n:source /tmp/from\nQ"
    

    The O macro will extract the from address from the current message, and save a new macro definition to /tmp/from.

    Then it will source that definition, and finally execute it.

    Note: I'm having trouble adding newlines in the script (that's the reason for the echo>>, and the need for you to press enter at the end of the limit prompt. Will try to improve this.