vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] Switch for handling of whitespace on J


From: Thomas Dickey
Subject: Re: [vile] Switch for handling of whitespace on J
Date: Thu, 01 Nov 2012 21:05:33 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, Nov 01, 2012 at 02:00:09PM +0000, Steven Lembark wrote:
> 
> On Fri, 26 Oct 2012 18:10:47 -0400
> Thomas Dickey <address@hidden> wrote:
> 
> > spaces-after-sentence
> 
> Example: Let's say I'm editing some Perl code. I start
> to combine the lines:
> 
>     frobnicate
>     (
>         foo => 
>         [
>             qw
>             (
>                 bar
>                 bletch
>                 blort
>             )
>         ]
>     )
> 
> A sequence of J's gets me:
> 
>     frobnicate ( foo => [ qw ( bar bletch blort) ])
> 
> Notice the presence of spaces after "frobnicate", the open
> parens, foo, and the first open paren, but not after "blort"
> or the close brace. 

Just reading the source code, I don't see that (referring to the original
remark) that you lost a switch, but that this might be a nice-to-have but
unimplemented feature.  The C code that's being executed is join_region
in word.c, and it has special cases (hardcoded) for "." and ")", and a
check if the previous character was not already a blank:

            /* join at column 0 to empty line */
            else if (doto < llength(DOT.l)) {
                if (lgetc(DOT.l, doto) == ')') {
                    /*EMPTY */ ;
                }
                /* join after parentheses */
                else if (lgetc(DOT.l, doto - 1) == '.') {
                    status = lins_bytes(2, ' ');
                } else if (!isSpace(c)) {
                    status = lins_bytes(1, ' ');
                }
            }
 
So... thinking this is a new feature request, the question comes up:
what's the most useful way to extend this.  There are 3 choices
embedded here:

        a) join without inserting a space
        b) insert two spaces
        c) insert single space

We could add three corresponding mode values (whether character-class,
regular expression or whatever):

        join-zero-spaces
        join-two-spaces
        join-one-spaces

and then you'd only have to have set something like

        join-zero-spaces={whatever makes no matches}
        join-two-spaces={whatever makes no matches}
        join-one-spaces={nonspace as is done already}

Regular expressions might be overkill, but would at least be consistent
with everything else in vile.  Character classes haven't been used as
mode-values (yet), but would be close to the current logic.  (The syntax
and semantics would differ - gotta choose one or the other at design time).

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]