Re: display_filter and ex

2017-02-08 Thread Andreas Doll
On 2017-01-31 at 16:26, David Champion wrote:
> par is superior to all other text reformatters.

Cool, I didn't knew about par. Indeed more powerful than vims reformatting.


> But to your question:
> The display filter is a filter in a strict sense: the message is send on
> its stdin, and its stdout goes back to mutt.  
> [...]

Thanks for also clarifying display_filter. Very informative reply!

All the best
Andreas


Re: display_filter and ex

2017-02-01 Thread Erik Christiansen
On 01.02.17 00:56, Andreas Doll wrote:
> TL;DR
> Has anyone managed to use ex in conjunction with display_filter?
> 
> 
> I write emails using vim, which provides the handy function gggqG. This
> function reformats text such that it doesn't exceed (say) 72 characters.

The ex exercise is intriguing, but one can have approximate equivalence
with:

a) Reading emails as delivered, in an xterm wide enough to accommodate
   80 or 90 character lines, without inconvenience.¹

b) When trimming quoted text in Vim, gq} can be repeated on each
   retained paragraph with overlong lines, with quoting (even
   multilevel) well handled, as you describe. A longer reformat seems a
   temptation to fullquoting?

   With gq} mapped to e.g. ^W, it's only necessary to whack ^W three
   times to format three paragraphs.

Dunno if this alternative appeals - after all, it unfortunately obviates
the need to play with display_filter. ;-)

¹ I do have:
set smart_wrap  # Wrap
set wrapmargin=10   # long lines. 
unset markers   # No '+' email line continuation crap.
# Busts URLs!

Erik


Re: display_filter and ex

2017-01-31 Thread David Champion
* On 31 Jan 2017, Patrick Shanahan wrote: 
> * David Champion  [01-31-17 19:31]:
> > * On 31 Jan 2017, Andreas Doll wrote: 
> > > 
> > > I write emails using vim, which provides the handy function gggqG. This
> > > function reformats text such that it doesn't exceed (say) 72 characters. 
> > > The
> > > function is superior to e.g.
> > > 
> > > $ fold -s -w 72 inputFile
> > 
> > par is superior to all other text reformatters.
> > set display_filter="env PARINIT='rT4bgq B=.,?!_A_a Q=_s>|+' par"
> 
> Your display_filter mangles display of the headers.  How to avoid this?

Yeah, I don't actually use this.  I suppose vim would do the same,
though.

The avoidance trick would be something akin to:

#!/bin/sh

# Read up to the first blank line unaltered
while read line; do
echo "$line"
case "$line" in
'') break;;
esac
done

# Pump the remainder through par
par 'rT4bgq B=.,?!_A_a Q=_s>|+'

-- 
David Champion • d...@bikeshed.us


signature.asc
Description: PGP signature


Re: display_filter and ex

2017-01-31 Thread Patrick Shanahan
* David Champion  [01-31-17 19:31]:
> * On 31 Jan 2017, Andreas Doll wrote: 
> > 
> > I write emails using vim, which provides the handy function gggqG. This
> > function reformats text such that it doesn't exceed (say) 72 characters. The
> > function is superior to e.g.
> > 
> > $ fold -s -w 72 inputFile
> 
> par is superior to all other text reformatters.
> set display_filter="env PARINIT='rT4bgq B=.,?!_A_a Q=_s>|+' par"

Your display_filter mangles display of the headers.  How to avoid this?

tks,
-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  @ptilopteri
http://en.opensuse.orgopenSUSE Community Memberfacebook/ptilopteri
Photos: http://wahoo.no-ip.org/gallery2  Registered Linux User #207535  
  
Photos: http://wahoo.no-ip.org/piwigo@ http://linuxcounter.net


Re: display_filter and ex

2017-01-31 Thread David Champion
* On 31 Jan 2017, Andreas Doll wrote: 
> 
> I write emails using vim, which provides the handy function gggqG. This
> function reformats text such that it doesn't exceed (say) 72 characters. The
> function is superior to e.g.
> 
> $ fold -s -w 72 inputFile

par is superior to all other text reformatters.
set display_filter="env PARINIT='rT4bgq B=.,?!_A_a Q=_s>|+' par"

But to your question:

> Recently I've learned about the display_filter option, and now I want to use
> this vim function to also reformat emails I read, not just those I send. Ex is
> (roughly) a way to perform vim actions and commands without starting a vim
> instance. So I thought I create a file commands.vim containing
> 
> :normal gggqG
> :%print
> :%quit!
> 
> and use in my muttrc
> 
> set display_filter='cat commands.vim | ex'

The display filter is a filter in a strict sense: the message is send on
its stdin, and its stdout goes back to mutt.  So what you get is
analogous to the following:

cat emailmessage.txt | cat commands.vim | ex

The first cat is a no-op since the second cat doesn't read its stdin in
this case.  You can combine a file with stdin with, e.g.

cat commands.vim -

But that isn't what you want.  You need to compose it so that ex gets
your message and the stdin:

#!/bin/sh
tmp=${TMPDIR-/tmp}/tmp.$$
touch $tmp
trap "rm $tmp" 0 1 2 3 15
cat >$tmp
cat commands.vim | ex $tmp

Then set display_filter to run that script.

This is all approximate - untested. Some tweaks might be necessary.

-- 
David Champion • d...@bikeshed.us


signature.asc
Description: PGP signature


display_filter and ex

2017-01-31 Thread Andreas Doll
Hello

TL;DR
Has anyone managed to use ex in conjunction with display_filter?


I write emails using vim, which provides the handy function gggqG. This
function reformats text such that it doesn't exceed (say) 72 characters. The
function is superior to e.g.

$ fold -s -w 72 inputFile

because it doesn't just break long lines, but rather reformats a paragraph
such that if a line gets broken, the following line is joined. Moreover it
takes care of inserting quotation signs if a quoted line is broken.

Recently I've learned about the display_filter option, and now I want to use
this vim function to also reformat emails I read, not just those I send. Ex is
(roughly) a way to perform vim actions and commands without starting a vim
instance. So I thought I create a file commands.vim containing

:normal gggqG
:%print
:%quit!

and use in my muttrc

set display_filter='cat commands.vim | ex'

but when I try to read a mail (using the mutt default pager) my terminal
pastes

Press any key to continue... (acutally the P is missing)

in my mutt instance, and the pager shows nothing.

Has anyone managed to use ex in conjunction with display_filter?

Thanks
Best regards,
Andreas