* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
@ 2014-01-29 17:21 ` Bastien
2014-01-29 17:44 ` Eli Zaretskii
` (5 subsequent siblings)
6 siblings, 0 replies; 27+ messages in thread
From: Bastien @ 2014-01-29 17:21 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
Glenn Morris <rgm@gnu.org> writes:
> Objections?
FWIW, none. I'm glad to discover this command.
--
Bastien
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
2014-01-29 17:21 ` Bastien
@ 2014-01-29 17:44 ` Eli Zaretskii
2014-01-29 18:35 ` Glenn Morris
2014-01-29 19:18 ` Teemu Likonen
` (4 subsequent siblings)
6 siblings, 1 reply; 27+ messages in thread
From: Eli Zaretskii @ 2014-01-29 17:44 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
> From: Glenn Morris <rgm@gnu.org>
> Date: Wed, 29 Jan 2014 12:15:52 -0500
>
> Therefore I suggest that `cycle-spacing' take the M-SPC binding
> of `just-one-space', since it provides a superset of the latter's
> functionality. People who do not like this can simply rebind
> `just-one-space' to M-SPC.
>
> Objections?
Not during feature freeze, please.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:44 ` Eli Zaretskii
@ 2014-01-29 18:35 ` Glenn Morris
2014-01-29 18:46 ` Glenn Morris
2014-01-29 18:49 ` Eli Zaretskii
0 siblings, 2 replies; 27+ messages in thread
From: Glenn Morris @ 2014-01-29 18:35 UTC (permalink / raw
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii wrote:
> Not during feature freeze, please.
It's a new command I have only discovered now when going through the
NEWS to do documentation updates. So:
i) It was impossible for me to propose this before now, because I was
unaware of it.
ii) IMO this kind of polishing/smoother integration of features
implemented during the previous development cycle is part of the point
of a feature freeze.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 18:35 ` Glenn Morris
@ 2014-01-29 18:46 ` Glenn Morris
2014-01-29 18:49 ` Eli Zaretskii
1 sibling, 0 replies; 27+ messages in thread
From: Glenn Morris @ 2014-01-29 18:46 UTC (permalink / raw
To: Eli Zaretskii; +Cc: emacs-devel
PS It's even literally the same code; as in, internally just-one-space
is nothing more than a call to cycle-spacing.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 18:35 ` Glenn Morris
2014-01-29 18:46 ` Glenn Morris
@ 2014-01-29 18:49 ` Eli Zaretskii
2014-01-30 2:33 ` Glenn Morris
2014-01-31 22:36 ` Tassilo Horn
1 sibling, 2 replies; 27+ messages in thread
From: Eli Zaretskii @ 2014-01-29 18:49 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
> From: Glenn Morris <rgm@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Wed, 29 Jan 2014 13:35:57 -0500
>
> Eli Zaretskii wrote:
>
> > Not during feature freeze, please.
>
> It's a new command I have only discovered now when going through the
> NEWS to do documentation updates. So:
>
> i) It was impossible for me to propose this before now, because I was
> unaware of it.
>
> ii) IMO this kind of polishing/smoother integration of features
> implemented during the previous development cycle is part of the point
> of a feature freeze.
I hear you, but M-SPC is a very old keybinding, so I'm not sure we
should change that now.
That said, it's just my opinion (you asked for opinions, right?).
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
2014-01-29 17:21 ` Bastien
2014-01-29 17:44 ` Eli Zaretskii
@ 2014-01-29 19:18 ` Teemu Likonen
2014-01-29 19:53 ` David Kastrup
2014-01-29 20:28 ` Alan Mackenzie
` (3 subsequent siblings)
6 siblings, 1 reply; 27+ messages in thread
From: Teemu Likonen @ 2014-01-29 19:18 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
Glenn Morris [2014-01-29 12:15:52 -05:00] wrote:
> Therefore I suggest that `cycle-spacing' take the M-SPC binding of
> `just-one-space', since it provides a superset of the latter's
> functionality. People who do not like this can simply rebind
> `just-one-space' to M-SPC.
I think it's a good change. It's basically the same functionality, just
an improved version of it.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 19:18 ` Teemu Likonen
@ 2014-01-29 19:53 ` David Kastrup
0 siblings, 0 replies; 27+ messages in thread
From: David Kastrup @ 2014-01-29 19:53 UTC (permalink / raw
To: emacs-devel
Teemu Likonen <tlikonen@iki.fi> writes:
> Glenn Morris [2014-01-29 12:15:52 -05:00] wrote:
>
>> Therefore I suggest that `cycle-spacing' take the M-SPC binding of
>> `just-one-space', since it provides a superset of the latter's
>> functionality. People who do not like this can simply rebind
>> `just-one-space' to M-SPC.
>
> I think it's a good change. It's basically the same functionality, just
> an improved version of it.
I think it is likely a good change, but the "basically the same
functionality" has seen no significant testing, and a feature freeze is
the wrong time for it to do so.
--
David Kastrup
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
` (2 preceding siblings ...)
2014-01-29 19:18 ` Teemu Likonen
@ 2014-01-29 20:28 ` Alan Mackenzie
2014-01-30 2:37 ` Glenn Morris
` (2 more replies)
2014-01-29 20:30 ` key-binding for cycle-spacing Johan Bockgård
` (2 subsequent siblings)
6 siblings, 3 replies; 27+ messages in thread
From: Alan Mackenzie @ 2014-01-29 20:28 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
Hi, Glenn.
On Wed, Jan 29, 2014 at 12:15:52PM -0500, Glenn Morris wrote:
> The new command `cycle-spacing' has no key-binding.
> If you have not used it, the first time you call it in a consecutive
> sequence, it acts like `just-one-space'.
Not quite. It's more complicated than that.
> The next time, it removes all whitespace. The third time, it restores
> the original whitespace.
> On the other hand, `just-one-space' only does something the first time
> you call it.
`just-one-space' has a precisely defined and strong functionality.
`cycle-spacing' has lots of complicated edge cases.
> Therefore I suggest that `cycle-spacing' take the M-SPC binding
> of `just-one-space', since it provides a superset of the latter's
> functionality.
Not quite. It's more complicated than that.
> People who do not like this can simply rebind `just-one-space' to
> M-SPC.
> Objections?
Yes. As Eli mentioned, it's late in the day.
Also, why do we need this function? Surely somebody adjusting her
whitespace at some place will know in advance whether she wants:
(a) 1 space;
(b) n spaces;
(c) no space,
and cycling through the possibilities to get there is an inefficient
waste of time.
There are already suitable commands and bindings for them to do each of
the things done by `cycle-spacing', namely M-SPC, C-u n M-space, M-\,
and C-_.
I don't thing we need this function. I can't see a use case. It seems
to violate the KISS principle.
Please keep M-SPC bound to `just-one-space'.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 20:28 ` Alan Mackenzie
@ 2014-01-30 2:37 ` Glenn Morris
2014-01-30 6:11 ` Alan Mackenzie
2014-01-31 22:40 ` Tassilo Horn
2014-02-10 13:45 ` Michal Nazarewicz
2 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2014-01-30 2:37 UTC (permalink / raw
To: Alan Mackenzie; +Cc: emacs-devel
Alan Mackenzie wrote:
>> If you have not used it, the first time you call it in a consecutive
>> sequence, it acts like `just-one-space'.
>
> Not quite. It's more complicated than that.
Please say how (were you referring to Johan's point?), otherwise this is
not helpful.
> `cycle-spacing' has lots of complicated edge cases.
Could you give say two examples of such cases?
You could avoid all the extra functionality by simply not using the
command more than once in a row (a no-op for just-one-space).
> It seems to violate the KISS principle.
So do many things. cc-bytecomp is a favourite of mine.
> Please keep M-SPC bound to `just-one-space'.
For ever, or for now?
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-30 2:37 ` Glenn Morris
@ 2014-01-30 6:11 ` Alan Mackenzie
0 siblings, 0 replies; 27+ messages in thread
From: Alan Mackenzie @ 2014-01-30 6:11 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
Hi, Glenn.
On Wed, Jan 29, 2014 at 09:37:36PM -0500, Glenn Morris wrote:
> Alan Mackenzie wrote:
> >> If you have not used it, the first time you call it in a consecutive
> >> sequence, it acts like `just-one-space'.
> > Not quite. It's more complicated than that.
> Please say how (were you referring to Johan's point?), otherwise this is
> not helpful.
If you type M-9 M-SPC, with `just-one-space' you'll end up with 9 spaces.
With `cycle-spacing', you'll usually get 9, sometime you'll get zero.
> > `cycle-spacing' has lots of complicated edge cases.
> Could you give say two examples of such cases?
One is above. A second one is what happens if you give a different
argument on the second invocation from the first. A third one is what
happens when there's just a tab in the buffer, which occupies one visible
space.
> You could avoid all the extra functionality by simply not using the
> command more than once in a row (a no-op for just-one-space).
Not quite. The first time round, `cycle-spacing''s behaviour is
different according to how much space is already there.
> > It seems to violate the KISS principle.
> So do many things. cc-bytecomp is a favourite of mine.
Yes, there are many things in CC Mode which are complicated, and believe
me, I suffer because of it. But `cycle-spacing' is complicated at the
basic user level and doesn't seem to have any utility.
> > Please keep M-SPC bound to `just-one-space'.
> For ever, or for now?
For ever. :-)
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 20:28 ` Alan Mackenzie
2014-01-30 2:37 ` Glenn Morris
@ 2014-01-31 22:40 ` Tassilo Horn
2014-01-31 22:55 ` Alan Mackenzie
2014-02-10 13:45 ` Michal Nazarewicz
2 siblings, 1 reply; 27+ messages in thread
From: Tassilo Horn @ 2014-01-31 22:40 UTC (permalink / raw
To: Alan Mackenzie; +Cc: emacs-devel
Alan Mackenzie <acm@muc.de> writes:
> Also, why do we need this function? Surely somebody adjusting her
> whitespace at some place will know in advance whether she wants:
> (a) 1 space;
> (b) n spaces;
> (c) no space,
> and cycling through the possibilities to get there is an inefficient
> waste of time.
FWIW, I have the habit of doing M-SPC DEL when I want no space, and I
use that sequence very frequently. M-SPC M-SPC is much more convenient
in that case.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-31 22:40 ` Tassilo Horn
@ 2014-01-31 22:55 ` Alan Mackenzie
2014-01-31 23:35 ` Tassilo Horn
0 siblings, 1 reply; 27+ messages in thread
From: Alan Mackenzie @ 2014-01-31 22:55 UTC (permalink / raw
To: Glenn Morris, emacs-devel
Hi, Tasillo.
On Fri, Jan 31, 2014 at 11:40:59PM +0100, Tassilo Horn wrote:
> Alan Mackenzie <acm@muc.de> writes:
> > Also, why do we need this function? Surely somebody adjusting her
> > whitespace at some place will know in advance whether she wants:
> > (a) 1 space;
> > (b) n spaces;
> > (c) no space,
> > and cycling through the possibilities to get there is an inefficient
> > waste of time.
> FWIW, I have the habit of doing M-SPC DEL when I want no space, and I
> use that sequence very frequently. M-SPC M-SPC is much more convenient
> in that case.
For no space, why don't you use `delete-horizontal-space', with its
standard binding of M-\? This surely beats M-SPC M-SPC, at least on an
English keyboard layout.
I use M-\ a lot in the minibuffer after making a typing mistake, but I
can't remember exactly why.
> Bye,
> Tassilo
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-31 22:55 ` Alan Mackenzie
@ 2014-01-31 23:35 ` Tassilo Horn
0 siblings, 0 replies; 27+ messages in thread
From: Tassilo Horn @ 2014-01-31 23:35 UTC (permalink / raw
To: Alan Mackenzie; +Cc: emacs-devel
Alan Mackenzie <acm@muc.de> writes:
Hi Anal [1],
>> FWIW, I have the habit of doing M-SPC DEL when I want no space, and I
>> use that sequence very frequently. M-SPC M-SPC is much more convenient
>> in that case.
>
> For no space, why don't you use `delete-horizontal-space', with its
> standard binding of M-\? This surely beats M-SPC M-SPC, at least on
> an English keyboard layout.
Yes, maybe, but I use a German Dvorak Type II layout, and then it's
three keys: Alt + Shift + /
That wouldn't be different with a normal German layout, too. And I
haven't memorized too many keys anyway. Rather I prefer if I need to
remember only a few keys that just do what I want depending on context.
Bye,
Tassilo
[1] Revenge for misspelling my name. ;-)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 20:28 ` Alan Mackenzie
2014-01-30 2:37 ` Glenn Morris
2014-01-31 22:40 ` Tassilo Horn
@ 2014-02-10 13:45 ` Michal Nazarewicz
2014-02-10 12:19 ` [PATCH] Make `cycle-spacing' behave more like `just-one-space' if called once Michal Nazarewicz
2 siblings, 1 reply; 27+ messages in thread
From: Michal Nazarewicz @ 2014-02-10 13:45 UTC (permalink / raw
To: Alan Mackenzie, Glenn Morris; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 2622 bytes --]
On Wed, Jan 29 2014, Alan Mackenzie wrote:
> Also, why do we need this function? Surely somebody adjusting her
> whitespace at some place will know in advance whether she wants:
> (a) 1 space;
> (b) n spaces;
> (c) no space,
> and cycling through the possibilities to get there is an inefficient
> waste of time.
Albeit no. I'm using `cycle-spacing' with the following binding:
(define-key esc-map " "
(lambda (n) (interactive "*p")
(cycle-spacing (- n) t)))
and I sometimes end up with a situation like this one:
const unsigned long long foo =-!-
calculate_stuff() * calculate_other_stuff();
(-!- denoting point) in which case I don't know if I want 1 space or
whatever there is now. What I end up doing is hit M-SPC to end up with:
const unsigned long long foo = calculate_stuff() * calculate_other_stuff();
and if it fits in my window (which is 80-character wide) I go on with my
life, if it does not, I press M-SPC two more times.
(And before you ask, yes, I am aware of M-^ and C-_ but see below.)
> There are already suitable commands and bindings for them to do each of
> the things done by `cycle-spacing', namely M-SPC, C-u n M-space, M-\,
> and C-_.
Sure, but:
* It is *much* easier to press the same key sequence three times in
a row than to use different key sequences. Compare:
- hold ALT down
- press SPACE
- press SPACE
- press SPACE
- release ALT
with:
- hold ALT down
- press SPACE
- press \ (which in many keyboard layouts is on far right which
forces you to extend your pinky)
- release ALT
- hold SHIFT and CTRL down
- press _
- release SHIFT and CTRL
* I find it easier to remember one key sequence that does magic stuff
then to remember bindings for everything. I never use M-\ and don't
have to remember it's there because M-SPC almost always does what
I want it to do if I press it enough times.
Similarly, I have no idea what is the key binding is for going back to
indention or to the beginning of buffer since my C-a does all that for
me.
BTW. M-\ does not work on new line characters whereas `cycle-spacing'
can.
> I don't thing we need this function. I can't see a use case.
Hope the above helps.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH] Make `cycle-spacing' behave more like `just-one-space' if called once.
2014-02-10 13:45 ` Michal Nazarewicz
@ 2014-02-10 12:19 ` Michal Nazarewicz
2014-03-27 14:27 ` Stefan Monnier
0 siblings, 1 reply; 27+ messages in thread
From: Michal Nazarewicz @ 2014-02-10 12:19 UTC (permalink / raw
To: bug-gnu-emacs
Cc: Alan Mackenzie, emacs-devel, Stefan Monnier, Richard Stallman
* simple.el (cycle-spacing): Never delete spaces on first run by
default, but do so in a new 'fast mode and if there are already
N spaces (the previous behaviour).
Compare N with its value in previous invocation so that changing
prefix argument restarts `cycle-spacing' sequence.
The idea is that with this change, binding M-SPC to
`cycle-spacing' should not introduce any changes in behaviour of
the binding so long as users do not type M-SPC twice in a raw with
the same prefix argument or lack thereof.
---
lisp/ChangeLog | 14 ++++++++++++++
lisp/simple.el | 59 ++++++++++++++++++++++++++++++++--------------------------
2 files changed, 47 insertions(+), 26 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b61da99..e53eacd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
+2014-03-26 Michal Nazarewicz <mina86@mina86.com>
+
+ * simple.el (cycle-spacing): Never delete spaces on first run by
+ default, but do so in a new 'fast mode and if there are already
+ N spaces (the previous behaviour).
+
+ Compare N with its value in previous invocation so that changing
+ prefix argument restarts `cycle-spacing' sequence.
+
+ The idea is that with this change, binding M-SPC to
+ `cycle-spacing' should not introduce any changes in behaviour of
+ the binding so long as users do not type M-SPC twice in a raw with
+ the same prefix argument or lack thereof.
+
2014-03-26 Daniel Colascione <dancol@dancol.org>
* simple.el (process-menu-mode-map): New variable.
diff --git a/lisp/simple.el b/lisp/simple.el
index 2ee6231..2bfab4a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -801,44 +801,51 @@ If BACKWARD-ONLY is non-nil, only delete them before point."
If N is negative, delete newlines as well, leaving -N spaces.
See also `cycle-spacing'."
(interactive "*p")
- (cycle-spacing n nil t))
+ (cycle-spacing n nil 'single-shot))
(defvar cycle-spacing--context nil
"Store context used in consecutive calls to `cycle-spacing' command.
-The first time this function is run, it saves the original point
-position and original spacing around the point in this
-variable.")
+The first time this function is run, it saves N argument, the
+original point position and original spacing around the point in
+this variable.")
-(defun cycle-spacing (&optional n preserve-nl-back single-shot)
+(defun cycle-spacing (&optional n preserve-nl-back mode)
"Manipulate whitespace around point in a smart way.
-In interactive use, this function behaves differently in successive
-consecutive calls.
+In interactive use, this function behaves differently in
+successive consecutive calls.
-The first call in a sequence acts like `just-one-space'.
-It deletes all spaces and tabs around point, leaving one space
-\(or N spaces). N is the prefix argument. If N is negative,
-it deletes newlines as well, leaving -N spaces.
-\(If PRESERVE-NL-BACK is non-nil, it does not delete newlines before point.)
+The first call in a sequence acts like `just-one-space'. It
+deletes all spaces and tabs around point, leaving one space \(or
+N spaces). N is the prefix argument. If N is negative, it
+deletes newlines as well leaving -N spaces. (If PRESERVE-NL-BACK
+is non-nil, it does not delete newlines before point.)
-The second call in a sequence (or the first call if the above does
-not result in any changes) deletes all spaces.
+The second call in a sequence deletes all spaces.
-The third call in a sequence restores the original whitespace (and point).
+The third call in a sequence restores the original
+whitespace (and point).
-If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
+If MODE is 'single-shot only the first step is performed. If
+MODE is 'fast and the first step did not result in any
+change (i.e. there was exactly (abs N) spaces around point)
+function goes to the second step immediately.
+
+Running the function with different N arguments initiates a new
+sequence each time."
(interactive "*p")
(let ((orig-pos (point))
(skip-characters (if (and n (< n 0)) " \t\n\r" " \t"))
- (n (abs (or n 1))))
+ (num (abs (or n 1))))
(skip-chars-backward (if preserve-nl-back " \t" skip-characters))
(constrain-to-field nil orig-pos)
(cond
- ;; Command run for the first time or single-shot is non-nil.
- ((or single-shot
+ ;; Command run for the first time, single-shot mode or different argument
+ ((or (eq 'single-shot mode)
(not (equal last-command this-command))
- (not cycle-spacing--context))
+ (not cycle-spacing--context)
+ (not (eq (car cycle-spacing--context) n)))
(let* ((start (point))
- (n (- n (skip-chars-forward " " (+ n (point)))))
+ (num (- num (skip-chars-forward " " (+ num (point)))))
(mid (point))
(end (progn
(skip-chars-forward skip-characters)
@@ -846,12 +853,12 @@ If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
(setq cycle-spacing--context ;; Save for later.
;; Special handling for case where there was no space at all.
(unless (= start end)
- (cons orig-pos (buffer-substring start (point)))))
+ (cons n (cons orig-pos (buffer-substring start (point))))))
;; If this run causes no change in buffer content, delete all spaces,
;; otherwise delete all excess spaces.
- (delete-region (if (and (not single-shot) (zerop n) (= mid end))
+ (delete-region (if (and (eq mode 'fast) (zerop num) (= mid end))
start mid) end)
- (insert (make-string n ?\s))))
+ (insert (make-string num ?\s))))
;; Command run for the second time.
((not (equal orig-pos (point)))
@@ -859,8 +866,8 @@ If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
;; Command run for the third time.
(t
- (insert (cdr cycle-spacing--context))
- (goto-char (car cycle-spacing--context))
+ (insert (cddr cycle-spacing--context))
+ (goto-char (cadr cycle-spacing--context))
(setq cycle-spacing--context nil)))))
\f
(defun beginning-of-buffer (&optional arg)
--
1.9.1.423.g4596e3a
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH] Make `cycle-spacing' behave more like `just-one-space' if called once.
2014-02-10 12:19 ` [PATCH] Make `cycle-spacing' behave more like `just-one-space' if called once Michal Nazarewicz
@ 2014-03-27 14:27 ` Stefan Monnier
2014-03-28 16:29 ` Michal Nazarewicz
0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-03-27 14:27 UTC (permalink / raw
To: Michal Nazarewicz
Cc: Alan Mackenzie, bug-gnu-emacs, emacs-devel, Richard Stallman
> * simple.el (cycle-spacing): Never delete spaces on first run by
> default, but do so in a new 'fast mode and if there are already
> N spaces (the previous behaviour).
Looks OK to me (for trunk).
Stefan
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] Make `cycle-spacing' behave more like `just-one-space' if called once.
2014-03-27 14:27 ` Stefan Monnier
@ 2014-03-28 16:29 ` Michal Nazarewicz
0 siblings, 0 replies; 27+ messages in thread
From: Michal Nazarewicz @ 2014-03-28 16:29 UTC (permalink / raw
To: Stefan Monnier
Cc: Alan Mackenzie, bug-gnu-emacs, emacs-devel, Richard Stallman
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
On Thu, Mar 27 2014, Stefan Monnier wrote:
>> * simple.el (cycle-spacing): Never delete spaces on first run by
>> default, but do so in a new 'fast mode and if there are already
>> N spaces (the previous behaviour).
>
> Looks OK to me (for trunk).
Thanks, pushed.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
` (3 preceding siblings ...)
2014-01-29 20:28 ` Alan Mackenzie
@ 2014-01-29 20:30 ` Johan Bockgård
2014-01-30 2:32 ` Glenn Morris
2014-01-30 14:09 ` Richard Stallman
2014-02-10 13:06 ` [PATCH] Make `cycle-spacing' behave more like `just-one-space' if colled once Michal Nazarewicz
6 siblings, 1 reply; 27+ messages in thread
From: Johan Bockgård @ 2014-01-29 20:30 UTC (permalink / raw
To: emacs-devel
Glenn Morris <rgm@gnu.org> writes:
> If you have not used it, the first time you call it in a consecutive
> sequence, it acts like `just-one-space'.
Except if there are already exactly N spaces (think keyboard macros).
Actually, is cycling when there is an explicit prefix argument ever
useful?
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 20:30 ` key-binding for cycle-spacing Johan Bockgård
@ 2014-01-30 2:32 ` Glenn Morris
0 siblings, 0 replies; 27+ messages in thread
From: Glenn Morris @ 2014-01-30 2:32 UTC (permalink / raw
To: emacs-devel
Johan Bockgård wrote:
> Glenn Morris <rgm@gnu.org> writes:
>
>> If you have not used it, the first time you call it in a consecutive
>> sequence, it acts like `just-one-space'.
>
> Except if there are already exactly N spaces (think keyboard macros).
That's true, thanks for pointing that out.
I think that's the only difference that exists?
If that turns out to be the only thing stopping this replacing
just-one-space (whenever that might be), I suggest removing that behaviour.
Yours-with-no-investment-in-this-and-without-the-energy-to-push-for-this,
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
` (4 preceding siblings ...)
2014-01-29 20:30 ` key-binding for cycle-spacing Johan Bockgård
@ 2014-01-30 14:09 ` Richard Stallman
2014-01-30 15:21 ` Stefan Monnier
2014-02-10 13:06 ` [PATCH] Make `cycle-spacing' behave more like `just-one-space' if colled once Michal Nazarewicz
6 siblings, 1 reply; 27+ messages in thread
From: Richard Stallman @ 2014-01-30 14:09 UTC (permalink / raw
To: Glenn Morris; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Therefore I suggest that `cycle-spacing' take the M-SPC binding
of `just-one-space', since it provides a superset of the latter's
functionality. People who do not like this can simply rebind
`just-one-space' to M-SPC.
Objections?
I will probably find it inconvenient. I sometimes type M-SPC when
there is already just one space, by force of habit.
Of course, I can rebind it -- but how many will dislike the change?
The way to find out is by _polling the users_, asking a lot of
people to try the change for a few weeks and seeing whether they
want it or not.
There is no rush about this change. Please poll the users.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-30 14:09 ` Richard Stallman
@ 2014-01-30 15:21 ` Stefan Monnier
2014-01-30 23:23 ` Richard Stallman
2014-02-10 13:09 ` Michal Nazarewicz
0 siblings, 2 replies; 27+ messages in thread
From: Stefan Monnier @ 2014-01-30 15:21 UTC (permalink / raw
To: Richard Stallman; +Cc: emacs-devel
> I will probably find it inconvenient. I sometimes type M-SPC when
> there is already just one space, by force of habit.
I think this means that M-SPC should only cycle when repeated (i.e. it
should test last-command).
Stefan
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-30 15:21 ` Stefan Monnier
@ 2014-01-30 23:23 ` Richard Stallman
2014-02-10 13:09 ` Michal Nazarewicz
1 sibling, 0 replies; 27+ messages in thread
From: Richard Stallman @ 2014-01-30 23:23 UTC (permalink / raw
To: Stefan Monnier; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
I think this means that M-SPC should only cycle when repeated (i.e. it
should test last-command).
With that change, it probably will never bother me.
I still think the users should be polled about a change like this.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: key-binding for cycle-spacing
2014-01-30 15:21 ` Stefan Monnier
2014-01-30 23:23 ` Richard Stallman
@ 2014-02-10 13:09 ` Michal Nazarewicz
1 sibling, 0 replies; 27+ messages in thread
From: Michal Nazarewicz @ 2014-02-10 13:09 UTC (permalink / raw
To: Stefan Monnier, Richard Stallman; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 720 bytes --]
On Thu, Jan 30 2014, Stefan Monnier wrote:
>> I will probably find it inconvenient. I sometimes type M-SPC when
>> there is already just one space, by force of habit.
>
> I think this means that M-SPC should only cycle when repeated (i.e. it
> should test last-command).
It does that already, but there's also a special case for deleting
spaces in case nothing changed in the buffer. This case is not executed
if single-shot is non-nil.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH] Make `cycle-spacing' behave more like `just-one-space' if colled once.
2014-01-29 17:15 key-binding for cycle-spacing Glenn Morris
` (5 preceding siblings ...)
2014-01-30 14:09 ` Richard Stallman
@ 2014-02-10 13:06 ` Michal Nazarewicz
6 siblings, 0 replies; 27+ messages in thread
From: Michal Nazarewicz @ 2014-02-10 13:06 UTC (permalink / raw
To: Glenn Morris, Teemu Likonen, David Kastrup, Alan Mackenzie,
Johan Bockgård, Richard Stallman
Cc: emacs-devel
From: Michal Nazarewicz <mina86@mina86.com>
* simple.el (cycle-spacing): Never delete spaces on first run by
default, but do so in a new 'fast mode and if there are already
N spaces (the previous behaviour).
Compare N with its value in previous invocation so that changing
prefix argument restarts `cycle-spacing' sequence.
The idea is that with this change, binding M-SPC to
`cycle-spacing' should not introduce any changes in behaviour of
the binding so long as users do not type M-SPC twice in a raw with
the same prefix argument or lack thereof.
---
lisp/ChangeLog | 14 ++++++++++++++
lisp/simple.el | 59 ++++++++++++++++++++++++++++++++--------------------------
2 files changed, 47 insertions(+), 26 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2e6ef1f..fc0d891 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
+2014-02-10 Michal Nazarewicz <mina86@mina86.com>
+
+ * simple.el (cycle-spacing): Never delete spaces on first run by
+ default, but do so in a new 'fast mode and if there are already
+ N spaces (the previous behaviour).
+
+ Compare N with its value in previous invocation so that changing
+ prefix argument restarts `cycle-spacing' sequence.
+
+ The idea is that with this change, binding M-SPC to
+ `cycle-spacing' should not introduce any changes in behaviour of
+ the binding so long as users do not type M-SPC twice in a raw with
+ the same prefix argument or lack thereof.
+
2014-02-10 Michael Albinus <michael.albinus@gmx.de>
* net/tramp-sh.el (tramp-sh-handle-start-file-process): Do not
diff --git a/lisp/simple.el b/lisp/simple.el
index c20bf13..6ee895b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -800,44 +800,51 @@ If BACKWARD-ONLY is non-nil, only delete them before point."
If N is negative, delete newlines as well, leaving -N spaces.
See also `cycle-spacing'."
(interactive "*p")
- (cycle-spacing n nil t))
+ (cycle-spacing n nil 'single-shot))
(defvar cycle-spacing--context nil
"Store context used in consecutive calls to `cycle-spacing' command.
-The first time this function is run, it saves the original point
-position and original spacing around the point in this
-variable.")
+The first time this function is run, it saves N argument, the
+original point position and original spacing around the point in
+this variable.")
-(defun cycle-spacing (&optional n preserve-nl-back single-shot)
+(defun cycle-spacing (&optional n preserve-nl-back mode)
"Manipulate whitespace around point in a smart way.
-In interactive use, this function behaves differently in successive
-consecutive calls.
+In interactive use, this function behaves differently in
+successive consecutive calls.
-The first call in a sequence acts like `just-one-space'.
-It deletes all spaces and tabs around point, leaving one space
-\(or N spaces). N is the prefix argument. If N is negative,
-it deletes newlines as well, leaving -N spaces.
-\(If PRESERVE-NL-BACK is non-nil, it does not delete newlines before point.)
+The first call in a sequence acts like `just-one-space'. It
+deletes all spaces and tabs around point, leaving one space \(or
+N spaces). N is the prefix argument. If N is negative, it
+deletes newlines as well leaving -N spaces. (If PRESERVE-NL-BACK
+is non-nil, it does not delete newlines before point.)
-The second call in a sequence (or the first call if the above does
-not result in any changes) deletes all spaces.
+The second call in a sequence deletes all spaces.
-The third call in a sequence restores the original whitespace (and point).
+The third call in a sequence restores the original
+whitespace (and point).
-If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
+If MODE is 'single-shot only the first step is performed. If
+MODE is 'fast and the first step did not result in any
+change (i.e. there was exactly (abs N) spaces around point)
+function goes to the second step immediately.
+
+Running the function with different N arguments initiates a new
+sequence each time."
(interactive "*p")
(let ((orig-pos (point))
(skip-characters (if (and n (< n 0)) " \t\n\r" " \t"))
- (n (abs (or n 1))))
+ (num (abs (or n 1))))
(skip-chars-backward (if preserve-nl-back " \t" skip-characters))
(constrain-to-field nil orig-pos)
(cond
- ;; Command run for the first time or single-shot is non-nil.
- ((or single-shot
+ ;; Command run for the first time, single-shot mode or different argument
+ ((or (eq 'single-shot mode)
(not (equal last-command this-command))
- (not cycle-spacing--context))
+ (not cycle-spacing--context)
+ (not (eq (car cycle-spacing--context) n)))
(let* ((start (point))
- (n (- n (skip-chars-forward " " (+ n (point)))))
+ (num (- num (skip-chars-forward " " (+ num (point)))))
(mid (point))
(end (progn
(skip-chars-forward skip-characters)
@@ -845,12 +852,12 @@ If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
(setq cycle-spacing--context ;; Save for later.
;; Special handling for case where there was no space at all.
(unless (= start end)
- (cons orig-pos (buffer-substring start (point)))))
+ (cons n (cons orig-pos (buffer-substring start (point))))))
;; If this run causes no change in buffer content, delete all spaces,
;; otherwise delete all excess spaces.
- (delete-region (if (and (not single-shot) (zerop n) (= mid end))
+ (delete-region (if (and (eq mode 'fast) (zerop num) (= mid end))
start mid) end)
- (insert (make-string n ?\s))))
+ (insert (make-string num ?\s))))
;; Command run for the second time.
((not (equal orig-pos (point)))
@@ -858,8 +865,8 @@ If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
;; Command run for the third time.
(t
- (insert (cdr cycle-spacing--context))
- (goto-char (car cycle-spacing--context))
+ (insert (cddr cycle-spacing--context))
+ (goto-char (cadr cycle-spacing--context))
(setq cycle-spacing--context nil)))))
\f
(defun beginning-of-buffer (&optional arg)
--
1.8.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread