Pipe and replace message

Jon LaBadie mutter at jgcomp.com
Fri Nov 24 04:40:15 UTC 2023


On Wed, Nov 22, 2023 at 08:12:17PM +0100, David Santinoli wrote:
>
>Hallo,
>
>I could not find a way to pipe a message to an external filter and have
>the output replace the original message.  As a workaround I open the
>message in vim, pipe the whole buffer to the filter, and save it back as
>a new message while the original one gets marked for deletion.
>It works but it's a bit cumbersome.  Anything more straightforward —
>possibly from the index screen?
>
>I'm using mutt 2.1.4 as included in Ubuntu 22.04.
>
Still doing the same thing, but perhaps reducing keystrokes to 2 total.

In your ~/.vimrc file, map a key sequence of your choice to do the work.
For example:

   map <f3> !Gpr -t -d^M:wq^M  

Here I'm mapping my function key F3.  I sometimes use ",," or ",x" as
my mapped sequence.

Editing your message from the index positions the cursor on the first
blank line after the headers.  "!G" sends line to a filter.  The lines
are the current one to the end of the file.  If you want the headers
sent to the filter shift the cursor first.  Such as:

   map <f3> 1G!G.......

My example filter "pr -t -d" merely double spaces the lines.  Replace
with a call to your filter.

The ^M (essentially <Enter>) is typed in as <ctrl>-V followed by the
<Enter> key.

The modified message is then saved and the editor exited with:

   :wq^M

The ^M typed as described above.

-- 
Jon H. LaBadie                 jon at labadie.us
  154 Milkweed Dr                 (540) 868-8052 (H)
  Lake Frederick, VA 22630        (703) 935-6720 (M)



More information about the Mutt-users mailing list