* Enhance word-based commands?
@ 2003-01-15 19:16 Kai Großjohann
2003-01-16 7:42 ` Kai Großjohann
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-01-15 19:16 UTC (permalink / raw)
I find that I like to use word-based commands to move words around in
the buffer. So when faced with the task of moving some words from one
place to another, I'll intuitively try to use word-based motion to
position point (to spot A, say), then use word-based killing to delete
(well, kill) the phrase, then use word-based motion again to reach the
target spot (B, say), then use C-y to yank.
It turns out that this only works with some restrictions:
If you have reached spot A with M-f, then you must use M-d to kill
and again use M-f to reach spot B. OTOH, if you have reached spot A
with M-b, then you must use M-DEL to kill and again use M-b to reach
the target spot.
Does this make sense?
The kill is wont to contain whitespace at one end, which causes the
problems.
I think it might help to change the behavior of the word-based
commands, as follows: Right now, M-f positions point after the end of
the next word. If there are non-word characters at point, those are
skipped first. I think it might help to change M-f as follows: if
there are non-word characters at point, skip past them but no
further. The behavior of M-b would be the same: if at a non-word
character, skip past the chunk of non-word characters but no further.
With this change, it would be easy for me to get a kill which has
whitespace on neither end, thus leading to more predictable
behavior. (The superfluous whitespace at the source location could
be fixed up with M-SPC or M-\, and missing whitespace could be added
to the target location in a similar way.)
What do people think?
It goes without saying that I'm not suggesting to change the default
behavior of Emacs, just to add a new behavior at user option.
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
@ 2003-01-16 7:42 ` Kai Großjohann
2003-01-16 23:54 ` Kim F. Storm
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-01-16 7:42 UTC (permalink / raw)
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> I think it might help to change the behavior of the word-based
> commands, as follows: Right now, M-f positions point after the end of
> the next word. If there are non-word characters at point, those are
> skipped first. I think it might help to change M-f as follows: if
> there are non-word characters at point, skip past them but no
> further. The behavior of M-b would be the same: if at a non-word
> character, skip past the chunk of non-word characters but no further.
Another alternative would be to consider each non-word character
(that is not whitespace) a `word' in its own right. I think this is
what C-w does in isearch-mode. So there is precedence for this
behavior in Emacs.
Still looking for opinions...
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
2003-01-16 7:42 ` Kai Großjohann
@ 2003-01-16 23:54 ` Kim F. Storm
2003-01-17 11:48 ` Kai Großjohann
2003-01-17 2:56 ` Miles Bader
2003-01-17 9:22 ` Richard Stallman
3 siblings, 1 reply; 12+ messages in thread
From: Kim F. Storm @ 2003-01-16 23:54 UTC (permalink / raw)
Cc: emacs-devel
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> I find that I like to use word-based commands to move words around in
> the buffer. ...
I'm working on a more flexible yank functionality where you can
actually mark killed text as e.g. a word and have it inserted
intelligently using a dedicated `yank-word' function (rather than a
dumb insert).
The basic functionality is already working, but I still need to
implement the intelligent kill-word/yank-word functions.
More details will follow...
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-16 23:54 ` Kim F. Storm
@ 2003-01-17 11:48 ` Kai Großjohann
2003-01-17 15:31 ` Andreas Schwab
0 siblings, 1 reply; 12+ messages in thread
From: Kai Großjohann @ 2003-01-17 11:48 UTC (permalink / raw)
Cc: emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> I'm working on a more flexible yank functionality where you can
> actually mark killed text as e.g. a word and have it inserted
> intelligently using a dedicated `yank-word' function (rather than a
> dumb insert).
Hey, cool!
However, I think just changing yanking is not enough, I think it would
also be useful to change killing. Hm. How to explain... In C code,
it might be useful to kill "*var" as a unit, and this is not currently
possible with backwards killing:
a = *b + c;
(I have no idea if this is valid C code...) Suppose you want to kill
"*b". Using M-DEL won't do it.
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-17 11:48 ` Kai Großjohann
@ 2003-01-17 15:31 ` Andreas Schwab
0 siblings, 0 replies; 12+ messages in thread
From: Andreas Schwab @ 2003-01-17 15:31 UTC (permalink / raw)
Cc: Kim F. Storm
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
|> However, I think just changing yanking is not enough, I think it would
|> also be useful to change killing. Hm. How to explain... In C code,
|> it might be useful to kill "*var" as a unit, and this is not currently
|> possible with backwards killing:
|>
|> a = *b + c;
|>
|> (I have no idea if this is valid C code...) Suppose you want to kill
|> "*b". Using M-DEL won't do it.
M-DEL M-1 DEL
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
2003-01-16 7:42 ` Kai Großjohann
2003-01-16 23:54 ` Kim F. Storm
@ 2003-01-17 2:56 ` Miles Bader
2003-01-17 11:45 ` Kai Großjohann
2003-01-17 9:22 ` Richard Stallman
3 siblings, 1 reply; 12+ messages in thread
From: Miles Bader @ 2003-01-17 2:56 UTC (permalink / raw)
Cc: emacs-devel
On Wed, Jan 15, 2003 at 08:16:03PM +0100, Kai Gro?johann wrote:
> I think it might help to change the behavior of the word-based
> commands, as follows
...
> It goes without saying that I'm not suggesting to change the default
> behavior of Emacs, just to add a new behavior at user option.
I think it couldn't be just a global toggle because some lisp code probably
depends on the current behavior.
-Miles
--
I have seen the enemy, and he is us. -- Pogo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
` (2 preceding siblings ...)
2003-01-17 2:56 ` Miles Bader
@ 2003-01-17 9:22 ` Richard Stallman
2003-01-17 11:44 ` Kai Großjohann
3 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2003-01-17 9:22 UTC (permalink / raw)
Cc: emacs-devel
I am against changing something as basic as the word commands.
They have worked this way for 28 years.
You could implement an alternative set of word commands for those who
want them. I suggest giving these commands different names, and
putting them in a separate file as a minor mode.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-17 9:22 ` Richard Stallman
@ 2003-01-17 11:44 ` Kai Großjohann
2003-01-17 13:53 ` Kim F. Storm
2003-01-19 1:35 ` Richard Stallman
0 siblings, 2 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-01-17 11:44 UTC (permalink / raw)
Cc: emacs-devel
Richard Stallman <rms@gnu.org> writes:
> You could implement an alternative set of word commands for those who
> want them.
That's what I meant by it being a user option.
> I suggest giving these commands different names, and putting them in
> a separate file as a minor mode.
I was thinking about using the nifty remap feature that Kim has
implemented for CUA mode. Then interactively invoking word-based
commands would exhibit the new behavior, whereas Lisp code would
still see the same old behavior.
But of course, it's also possible to use a minor mode map to change
several keybindings.
But let's wait for Kim's yank-word feature. I think it might be
better than what I had in mind (at least for part of the
functionality).
--
Ambibibentists unite!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-17 11:44 ` Kai Großjohann
@ 2003-01-17 13:53 ` Kim F. Storm
2003-01-19 2:18 ` Kim F. Storm
2003-01-19 1:35 ` Richard Stallman
1 sibling, 1 reply; 12+ messages in thread
From: Kim F. Storm @ 2003-01-17 13:53 UTC (permalink / raw)
Cc: emacs-devel
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> Richard Stallman <rms@gnu.org> writes:
>
> > You could implement an alternative set of word commands for those who
> > want them.
>
> That's what I meant by it being a user option.
>
> > I suggest giving these commands different names, and putting them in
> > a separate file as a minor mode.
That's my intention.
>
> I was thinking about using the nifty remap feature that Kim has
> implemented for CUA mode. Then interactively invoking word-based
> commands would exhibit the new behavior, whereas Lisp code would
> still see the same old behavior.
I definitely think this should be a minor mode -- even if it only
remaps two commands:
[remap kill-word] => dynaword-kill-word
[remap backward-kill-word] => dynaword-backward-kill-word
It can then be selectively turned on using mode hooks (or some modes
may turn it on unconditionally).
The fun thing about my "yank-function" functionality is that using
dynaword-kill-word can (silently) arrange for C-y to insert the killed
word(s) in a certain "non-trivial" way.
>
> But let's wait for Kim's yank-word feature. I think it might be
> better than what I had in mind (at least for part of the
> functionality).
Let's see :-)
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-17 13:53 ` Kim F. Storm
@ 2003-01-19 2:18 ` Kim F. Storm
0 siblings, 0 replies; 12+ messages in thread
From: Kim F. Storm @ 2003-01-19 2:18 UTC (permalink / raw)
Cc: emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> The fun thing about my "yank-function" functionality is that using
> dynaword-kill-word can (silently) arrange for C-y to insert the killed
> word(s) in a certain "non-trivial" way.
I renamed it to "yank-handler" (see NEWS), but here is a replacement
to kill-rectangle which allows you to insert the rectangle using C-y
(from the kill-ring), and even use M-y to cycle the kill-ring with
rectangles on the ring:
(defun kill-rectangle (start end &optional fill)
(interactive "*r\nP")
(when buffer-read-only
(setq killed-rectangle (extract-rectangle start end))
(barf-if-buffer-read-only))
(setq killed-rectangle (delete-extract-rectangle start end fill))
(kill-new "=" nil
(list 'insert-rectangle killed-rectangle t
(lambda (s e)
(delete-rectangle s e)
(goto-char s)))))
It is not perfect though. If inserting the rectangle changes tabs to
spaces, M-y may not completely restore the buffer to the state before
the rectangle was inserted, before inserting the next element from the
kill-ring. But it's close, so I hope you can see the potential in the
new functionality.
Now, this should allow a new intelligent i-kill-word function to
install a yank-handler which will correctly insert the killed words
with appropriate spaces according to context [i.e. don't insert a
space before punctuation or at beginning/end of line].
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Enhance word-based commands?
2003-01-17 11:44 ` Kai Großjohann
2003-01-17 13:53 ` Kim F. Storm
@ 2003-01-19 1:35 ` Richard Stallman
1 sibling, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2003-01-19 1:35 UTC (permalink / raw)
Cc: emacs-devel
I was thinking about using the nifty remap feature that Kim has
implemented for CUA mode. Then interactively invoking word-based
commands would exhibit the new behavior, whereas Lisp code would
still see the same old behavior.
That is worth a try.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-01-19 2:18 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
2003-01-16 7:42 ` Kai Großjohann
2003-01-16 23:54 ` Kim F. Storm
2003-01-17 11:48 ` Kai Großjohann
2003-01-17 15:31 ` Andreas Schwab
2003-01-17 2:56 ` Miles Bader
2003-01-17 11:45 ` Kai Großjohann
2003-01-17 9:22 ` Richard Stallman
2003-01-17 11:44 ` Kai Großjohann
2003-01-17 13:53 ` Kim F. Storm
2003-01-19 2:18 ` Kim F. Storm
2003-01-19 1:35 ` Richard Stallman
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.