GNU bug report logs - #27507
[PATCH] Make `cycle-spacing' allow 'negative-zero in place of an integer

Previous Next

Package: emacs;

Reported by: Mekeor Melire <mekeor.melire <at> gmail.com>

Date: Tue, 27 Jun 2017 16:55:03 UTC

Severity: wishlist

Tags: moreinfo, patch

Done: Mekeor Melire <mekeor.melire <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 27507 <at> debbugs.gnu.org (full text, mbox):

From: Mekeor Melire <mekeor.melire <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: Mekeor Melire <mekeor.melire <at> gmail.com>, 27507 <at> debbugs.gnu.org
Subject: Re: bug#27507: [PATCH] Make `cycle-spacing' allow 'negative-zero in
 place of an integer
Date: Sat, 01 Jul 2017 18:17:06 +0200
npostavs <at> users.sourceforge.net writes:

> Mekeor Melire <mekeor.melire <at> gmail.com> 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
upon?

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 mode)
      ;; 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!




This bug report was last modified 7 years and 199 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.