bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#19267: 25.0.50; Enhance cycle-spacing with a state where only whites


From: Robert Pluim
Subject: bug#19267: 25.0.50; Enhance cycle-spacing with a state where only whitespace after point is deleted
Date: Fri, 13 May 2022 15:33:45 +0200

>>>>> On Fri, 13 May 2022 10:50:22 +0200, Tassilo Horn <tsdh@gnu.org> said:

    Tassilo> Tassilo Horn <tsdh@gnu.org> writes:
    Tassilo> Hi all,

    >> Perfect.  If you are not already implementing that, I'd give it a shot
    >> when I find some spare time.

    Tassilo> Ok, attached is a first version of the patch for discussion.  The
    Tassilo> supported actions are:

    Tassilo> (setq cycle-spacing-actions
    Tassilo>       '( just-one-space        ; you name it
    Tassilo>          ;; delete-space-after ; delete spaces after point
    Tassilo>          delete-space-before   ; delete spaces before point
    Tassilo>          delete-all-space      ; delete all spaces around point
    Tassilo>          restore))             ; restore the original spacing

Can we add something to the description of `delete-all-space' (or
change the name) that makes it clear it deletes newlines as well?

    Tassilo> In addition, you can add functions (symbols) into that list which 
are
    Tassilo> simply funcall-ed.

    Tassilo> Here are some thoughts I'd like to discuss:

    Tassilo> 1. Currently as previously, changing the prefix arg will start a 
new
    Tassilo>    sequence, e.g., M-4 M-SPC M-8 M-SPC will call just-one-space 
twice
    Tassilo>    with 4 and then 8.  I think that made sense when just-one-space 
was
    Tassilo>    guaranteed to be the first action ("Oh, I mistyped my prefix 
arg so
    Tassilo>    let's just correct that!").

    Tassilo>    However, with the new version, I think it would make more sense 
when
    Tassilo>    the prefix arg given to the initial invocation is passed on to
    Tassilo>    following invocations of this cycle.  The reason is that only
    Tassilo>    just-one-space actually cares about the exact numerical value 
whereas
    Tassilo>    all actions (except 'restore) care about the prefix arg being
    Tassilo>    positive or negative.  A negative arg always indicates that 
newlines
    Tassilo>    are treated as a deletable space whereas arg => 0 only 
considers tabs
    Tassilo>    and spaces.  So right now, if you want to delete all space 
including
    Tassilo>    newlines, you have to type M-- M-SPC M-- M-SPC M-- M-SPC which 
is
    Tassilo>    inconvenient.  If the initial arg was passed on, it would just 
be M--
    Tassilo>    M-SPC M-SPC M-SPC which is much easier to type.

I think that makes sense. You can always specify a prefix arg of a
different sign in subsequent invocations of M-SPC if you want.

    Tassilo>    Of course, that comes with the (IMHO little) downside that you 
need
    Tassilo>    to do something else to break a cycle, e.g., C-g.  That could be
    Tassilo>    fixed by starting a new cycle only if the prefix arg is not 1 
(the
    Tassilo>    default).

Would a motion command not suffice?

    Tassilo> 2. With my configured emacs (but not with emacs -Q) it may take a
    Tassilo>    substantial amount of time (up to a second) until the action's 
effect
    Tassilo>    is displayed, most notably when cycling with negative prefix arg
    Tassilo>    where also newlines may be deleted.  Profiling revealed that 
this
    Tassilo>    comes mostly through stuff sitting in post-command-hook or
    Tassilo>    after-change-functions.  To name a few: aggressive-indent, 
show-paren
    Tassilo>    (which I use with the costly show-paren-context-when-offscreen
    Tassilo>    value 'child-frame), eldoc,...

    Tassilo>    Ok, aggressive-indent is countering manual spacing adjustments
    Tassilo>    fundamentally but can be tamed with:

    Tassilo>        (add-to-list 'aggressive-indent-dont-indent-if
    Tassilo>                     '(eq last-command 'cycle-spacing))

    Tassilo>    But is there some good way to tame the others?  It's hard to 
decide
    Tassilo>    which known performance hogs to inhibit and there might be much 
worse
    Tassilo>    unknown ones.  (Well, I also don't know how to inhibit.  I guess
    Tassilo>    let-binding post-command-hook in a command has no effect since 
it's
    Tassilo>    run after the command, right?)

I think we should worry about any performance side-effects once we run
into them.

Robert
-- 





reply via email to

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