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: Tassilo Horn
Subject: bug#19267: 25.0.50; Enhance cycle-spacing with a state where only whitespace after point is deleted
Date: Fri, 13 May 2022 20:48:44 +0200
User-agent: mu4e 1.7.20; emacs 29.0.50

Robert Pluim <rpluim@gmail.com> writes:

>     Tassilo> Ok, attached is a first version of the patch for
>     Tassilo> discussion.  The 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?

It doesn't generally.  All those actions delete newlines only if a
negative prefix arg is given.  The delete-all-space action calls
delete-horizontal-space with prefix arg >= 0 or delete-all-space with
negative prefix arg.

Ok, now I see that the action's name is the same as the command
delete-all-space which I've also introduced and which does delete
newlines.  But an action delete-horizontal-or-all-space is a bit
longish.  I think it's ok as it is but will document that the term
"space" may or may not include newlines.

>     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.

Exactly.

>     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?

Sure.  But after a mistyped M-3 M-SPC with the intention to have "just 4
spaces", being able to do M-4 M-SPC is still one motion command
shorter. ;-)

Bye,
Tassilo





reply via email to

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