nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Request For New Feature: Unadorned Plus Sign

2012-02-10 17:10:20
ralph wrote:
Hi Norm,

Folder name completion was what I wanted for. I guess that it's not to
be.

I did work out the tcsh(1) spell for that in another millenium, these
days I use bash as it's what to hand.  I've had a go at what you
requested and it seems to work;  I don't use it myself and haven't tried
to define a bash completion before so be warned.

    comp_nmh_folder() 
    { 
        local w=${COMP_WORDS[COMP_CWORD]} &&
        [[ $w == +* ]] && w=${w#+} &&
        COMPREPLY=($(
            folders -fast |
            awk -v "w=$w" -v "l=${#w}" 'substr($0, 1, l) == w'
        ))
    }
    complete -P + -F comp_nmh_folder -D

It assumes if you are completing a word starting with a plus that it's a
folder.  It does this for all commands, -D for default, not a hard-coded
list of scan, refile, ...  That way it works with your ~/bin.  Tap Tab
multiple times for a list of possible completions.

ralph is quickly becoming my new MH-tools hero.  thanks!

(i've written my own version of the mh-reader-script-using-less trick
that ralph described the other day.  when i've used it for a full day
without tweaking it, i'll share it here.  no hard dependencies on my
own tools.)

paul


Cheers, Ralph.

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

=---------------------
 paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma, 
where it's 38.3 degrees)

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>