[Top][All Lists]

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

bug#27507: [PATCH] Make `cycle-spacing' allow 'negative-zero in place of

From: Mekeor Melire
Subject: bug#27507: [PATCH] Make `cycle-spacing' allow 'negative-zero in place of an integer
Date: Sat, 01 Jul 2017 18:17:06 +0200

address@hidden writes:

> Mekeor Melire <address@hidden> writes:

>> * lisp/simple.el (cycle-spacing): beside accepting an integer as first
>> argument N, also allow N to be 'negative-zero. This allows to delete
>> all spaces including newlines with (cycle-spacing 'negative-zero).

> This behaviour can't be used interactively right?  If you want a
> function to delete all space including newlines, I think it's better to
> add one instead of adding yet another mode to cycle-spacing which won't
> even be used by interactive callers.

> That is, instead of (cycle-spacing 'negative-zero) something like
> (delete-whitespace).

Well, the point is that delete-whitespace would mostly have the same
logic as cycle-spacing. So, should we define a more general function
then, which both delete-whitespace and cycle-spacing would be based

So, currently `cycle-spacing' is used like this:

    (cycle-spacing &optional N PRESERVE-NL-BACK MODE)

And the problem is that the sign(ature) of N is used to determine
whether to delete newlines as well. So, if N is zero, we have a problem.
So, I think we shouldn't use the signature of N but instead that should
be another argument. But maybe let's use that new argument for a new
function so that cycle-spacing stays backwardscompatible?

So, I propose something like this:

    (defun (cycle-spacing &optional n preserve-nl-back mode)
      (cycle-spacing-general n preserve-nl-back (< n 0) mode))

    (defun (cycle-spacing-general &optional n preserve-nl-back delete-newlines 
      ;; use (abs n) in place of n here
      ;; ...

    ;; this is optional:
    (defun (delete-whitespace &optional n preserve-n-back mode)
      (cycle-spacing-general n preserve-nl-back t mode))

>> +  (letrec
> You only need let* here, I think.

Uhm, I'm not sure. I'll check it out.

Thanks for your feedback!

reply via email to

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