* kill-region and white space
@ 2004-08-30 18:18 kgold
2004-08-31 15:14 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: kgold @ 2004-08-30 18:18 UTC (permalink / raw)
I post this periodically. It's bothered me for years.
I set mouse-3 to kill-region, and mouse-2 to mouse-yank-at-click. So
I can cut and paste using only the mouse.
mouse-1 double click selects a word, so I'd like to be able to select,
cut, and paste a word using the mouse. However, the double click
doesn't select the white space after the word. I grabbed this code for
kill-word to do what I want. Is there something similar for mouse-1
double click?
(defadvice kill-word (after delete-horizontal-space activate)
"Delete trailing whitespace as well."
(if (looking-at "\\s ")
(just-one-space)))
That is, with this line
aaaaa bbbbb ccccc ddddd
Double click on the bbbbb, mounse-3, and mouse-2 before the ddddd
currently gives:
aaaaa ccccc bbbbbddddd
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: kill-region and white space
2004-08-30 18:18 kill-region and white space kgold
@ 2004-08-31 15:14 ` Kevin Rodgers
2004-09-01 13:31 ` kgold
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2004-08-31 15:14 UTC (permalink / raw)
kgold wrote:
> I set mouse-3 to kill-region, and mouse-2 to mouse-yank-at-click. So
> I can cut and paste using only the mouse.
>
> mouse-1 double click selects a word, so I'd like to be able to select,
> cut, and paste a word using the mouse. However, the double click
> doesn't select the white space after the word. I grabbed this code for
> kill-word to do what I want. Is there something similar for mouse-1
> double click?
>
> (defadvice kill-word (after delete-horizontal-space activate)
> "Delete trailing whitespace as well."
> (if (looking-at "\\s ")
> (just-one-space)))
Why not advise kill-region similarly, since that's what you've bound
mouse-3 to?
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: kill-region and white space
2004-08-31 15:14 ` Kevin Rodgers
@ 2004-09-01 13:31 ` kgold
2004-09-01 16:16 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: kgold @ 2004-09-01 13:31 UTC (permalink / raw)
Kevin Rodgers <ihs_4664@yahoo.com> writes:
> kgold wrote:
> > I set mouse-3 to kill-region, and mouse-2 to mouse-yank-at-click. So
> > I can cut and paste using only the mouse.
> >
> > mouse-1 double click selects a word, so I'd like to be able to select,
> > cut, and paste a word using the mouse. However, the double click
> > doesn't select the white space after the word. I grabbed this code for
> > kill-word to do what I want. Is there something similar for mouse-1
> > double click?
> >
> > (defadvice kill-word (after delete-horizontal-space activate)
> > "Delete trailing whitespace as well."
> > (if (looking-at "\\s ")
> > (just-one-space)))
>
> Why not advise kill-region similarly, since that's what you've bound
> mouse-3 to?
Here's what I tried. They both kill correctly, but the yank does not
yank the whitespace. I think I need the mouse-1 double click to
select the word and the whitespace after it.
That is, I think the problem and solution involve the select, not the
kill.
(defadvice kill-region (after delete-horizontal-space activate)
"Delete trailing whitespace as well."
(if (looking-at "\\s ")
(just-one-space)))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: kill-region and white space
2004-09-01 13:31 ` kgold
@ 2004-09-01 16:16 ` Kevin Rodgers
2004-09-01 18:47 ` kgold
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2004-09-01 16:16 UTC (permalink / raw)
kgold wrote:
> Kevin Rodgers <ihs_4664@yahoo.com> writes:
>>kgold wrote:
>> > (defadvice kill-word (after delete-horizontal-space activate)
>> > "Delete trailing whitespace as well."
>> > (if (looking-at "\\s ")
>> > (just-one-space)))
>>
>>Why not advise kill-region similarly, since that's what you've bound
>>mouse-3 to?
>
> Here's what I tried. They both kill correctly, but the yank does not
> yank the whitespace. I think I need the mouse-1 double click to
> select the word and the whitespace after it.
>
> (defadvice kill-region (after delete-horizontal-space activate)
> "Delete trailing whitespace as well."
> (if (looking-at "\\s ")
> (just-one-space)))
>
> That is, I think the problem and solution involve the select, not the
> kill.
OK, get rid of both command advices -- a word does not include
trailing whitespace, and altering the text at the region boundary
could adversely affect other calls to kill-region. Instead, there are
2 utility functions that try be intelligent about what the user is
selecting depending on where the mouse clicks occur: mouse-start-end
and mouse-skip-word. So I think you could advise mouse-skip-word like
this:
(defadvice mouse-skip-word (after trailing-whitespace activate)
"Skip trailing whitespace at a word boundary when going forward."
(if (and (> (ad-get-arg 0) 0) (looking-at "\\>"))
(skip-syntax-forward " ")))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: kill-region and white space
2004-09-01 16:16 ` Kevin Rodgers
@ 2004-09-01 18:47 ` kgold
0 siblings, 0 replies; 5+ messages in thread
From: kgold @ 2004-09-01 18:47 UTC (permalink / raw)
Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Instead, there are
> 2 utility functions that try be intelligent about what the user is
> selecting depending on where the mouse clicks occur: mouse-start-end
> and mouse-skip-word. So I think you could advise mouse-skip-word like
> this:
>
> (defadvice mouse-skip-word (after trailing-whitespace activate)
> "Skip trailing whitespace at a word boundary when going forward."
> (if (and (> (ad-get-arg 0) 0) (looking-at "\\>"))
> (skip-syntax-forward " ")))
That was it. I'm a happy mouse-clicker. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-09-01 18:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-30 18:18 kill-region and white space kgold
2004-08-31 15:14 ` Kevin Rodgers
2004-09-01 13:31 ` kgold
2004-09-01 16:16 ` Kevin Rodgers
2004-09-01 18:47 ` kgold
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).