unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mekeor Melire <mekeor.melire@gmail.com>
To: npostavs@users.sourceforge.net
Cc: Mekeor Melire <mekeor.melire@gmail.com>, 27507@debbugs.gnu.org
Subject: bug#27507: [PATCH] Make `cycle-spacing' allow 'negative-zero in place of an integer
Date: Sat, 01 Jul 2017 18:17:06 +0200	[thread overview]
Message-ID: <87fuegdtdp.fsf@gmail.com> (raw)
In-Reply-To: <87zicql0v5.fsf@users.sourceforge.net>


npostavs@users.sourceforge.net writes:

> Mekeor Melire <mekeor.melire@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!





  reply	other threads:[~2017-07-01 16:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 16:18 bug#27507: [PATCH] Make `cycle-spacing' allow 'negative-zero in place of an integer Mekeor Melire
2017-06-30  1:29 ` npostavs
2017-07-01 16:17   ` Mekeor Melire [this message]
2017-07-01 18:15     ` npostavs
2017-10-17  0:25       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fuegdtdp.fsf@gmail.com \
    --to=mekeor.melire@gmail.com \
    --cc=27507@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).