* Annoying kill-ring behavior
@ 2014-03-31 22:06 Smith_RS
2014-03-31 22:45 ` Stefan Monnier
[not found] ` <mailman.18630.1396305973.10748.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Smith_RS @ 2014-03-31 22:06 UTC (permalink / raw)
To: help-gnu-emacs
This will be my last question for a while. It's been a persistent niggle for a long time. I was just wondering why this happens and what level of hackery is required to make it go away.
SCENARIO #1
- mouse-1-down, move mouse over text, mouse-1-up, verify kill-ring modified correctly
- re-position mouse pointer over desired yank location in another frame
- notice that frame is not raised, do a mouse-1-down, mouse-1-up to raise the frame and set point at desired yank location
- mouse-2-down, mouse-2-up, observe correct yank behavior
SCENARIO #2
- mouse-1-down, move mouse over text, mouse-1-up, verify kill-ring modified correctly
- re-position mouse pointer over desired yank location in another frame
- notice that frame is not raised, do a mouse-1-down, a very small mouse-drag of just a few pixels, mouse-1-up to raise the frame
- mouse-2-down, mouse-2-up, observe that nothing is yanked, because there is now a zero-length string at the top of the kill-ring
Can someone clue me in as to how I avoid SCENARIO #2?
I want to know how to prevent empty entries from getting into the kill-ring, or remove them after the fact. There is obviously a click-vs-drag pixel threshold being set somewhere, but I can't see where that's exposed so I can modify it.
And I don't really understand why zero-length strings are allowed in the kill-ring at all.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-03-31 22:06 Annoying kill-ring behavior Smith_RS
@ 2014-03-31 22:45 ` Stefan Monnier
[not found] ` <mailman.18630.1396305973.10748.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2014-03-31 22:45 UTC (permalink / raw)
To: help-gnu-emacs
> This will be my last question for a while. It's been a persistent niggle
> for a long time. I was just wondering why this happens and what level of
> hackery is required to make it go away.
I remember fixing this kind of bug, so it might depend on which version
of Emacs you're using.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
[not found] ` <mailman.18630.1396305973.10748.help-gnu-emacs@gnu.org>
@ 2014-04-01 7:54 ` Smith_RS
2014-04-01 16:23 ` Smith_RS
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Smith_RS @ 2014-04-01 7:54 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, March 31, 2014 3:45:37 PM UTC-7, Stefan Monnier wrote:
> I remember fixing this kind of bug, so it might depend on which version
> of Emacs you're using.
Thanks. I first saw this under 24.3.1 build under Windows.
I went back and re-traced my steps. Back when I first started with 24.x I had the cut/paste problem as described here:
http://stackoverflow.com/questions/13036155/how-to-to-combine-emacs-primary-clipboard-copy-and-paste-behavior-on-ms-windows
So I added this to my .emacs, without *really* understanding how it was changing my default behavior:
(when (equal window-system 'w32)
(setq select-active-regions nil)
(setq mouse-drag-copy-region t)
(global-set-key [mouse-2] 'mouse-yank-at-click))
If you execute these three lines and try my scenario as posted above, you should be able to duplicate the issue.
Since I move a lot between Linux and Windows (multiple times during my work day, and I use Git to keep my files straight) I'm keen on techniques that give me consistent cut/paste semantics. But I'm also at a point in my understanding of Emacs that I know the primary selection and the kill-ring are two different things. This commonly-suggested workaround for Windows users created confusion for me.
But it's not a Windows-specific bug, if you C-x C-e on this code:
(progn
(setq select-active-regions nil)
(setq mouse-drag-copy-region t)
(global-set-key [mouse-2] 'mouse-yank-at-click))
And then do the mouse-1-micro-drag that I described earlier, you will see the zero-length entries in the kill-ring, on Windows and Linux.
For me personally, I'm probably going to turn off this "just use the kill ring all the time" behavior until I figure out what the best way to move forward is. It seems like it's one of those things you tell newbies to do so they'll leave you alone.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-04-01 7:54 ` Smith_RS
@ 2014-04-01 16:23 ` Smith_RS
2014-04-02 11:59 ` Stefan Monnier
[not found] ` <mailman.18813.1396529475.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 9+ messages in thread
From: Smith_RS @ 2014-04-01 16:23 UTC (permalink / raw)
To: help-gnu-emacs
Apart from my main question, can anyone tell me how to delete entries from the kill-ring that I don't want to be there? I don't want to just move the pointer, I want to prune out the stuff I don't like.
If I can do that I can construct a work-around that will give me the behavior I want. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-04-01 7:54 ` Smith_RS
2014-04-01 16:23 ` Smith_RS
@ 2014-04-02 11:59 ` Stefan Monnier
[not found] ` <mailman.18813.1396529475.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2014-04-02 11:59 UTC (permalink / raw)
To: help-gnu-emacs
> But it's not a Windows-specific bug, if you C-x C-e on this code:
>
> (progn
> (setq select-active-regions nil)
> (setq mouse-drag-copy-region t)
> (global-set-key [mouse-2] 'mouse-yank-at-click))
>
> And then do the mouse-1-micro-drag that I described earlier, you will see
> the zero-length entries in the kill-ring, on Windows and Linux.
I suggest you M-x report-emacs-bug, then, so that we can fix it for
24.4.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
[not found] ` <mailman.18813.1396529475.10748.help-gnu-emacs@gnu.org>
@ 2014-04-03 16:52 ` Smith_RS
2014-04-03 21:59 ` Smith_RS
0 siblings, 1 reply; 9+ messages in thread
From: Smith_RS @ 2014-04-03 16:52 UTC (permalink / raw)
To: help-gnu-emacs
On Wednesday, April 2, 2014 4:59:23 AM UTC-7, Stefan Monnier wrote:
> I suggest you M-x report-emacs-bug, then, so that we can fix it for 24.4.
I will do that, but I have one last question:
When I try to update the kill-ring "by hand" I find that when I try to access yank-menu it is no longer in sync with the kill-ring.
How do I fix that? The code in menu-bar.el doesn't really explain how it's kept in sync. What am I missing? Is there a hook somewhere?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-04-03 16:52 ` Smith_RS
@ 2014-04-03 21:59 ` Smith_RS
2014-04-04 4:34 ` Joost Kremers
0 siblings, 1 reply; 9+ messages in thread
From: Smith_RS @ 2014-04-03 21:59 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, April 3, 2014 9:52:17 AM UTC-7, Smith_RS wrote:
> When I try to update the kill-ring "by hand" I find that when I try to access yank-menu it is no longer in sync with the kill-ring.
>
> How do I fix that? The code in menu-bar.el doesn't really explain how it's kept in sync. What am I missing? Is there a hook somewhere?
Never mind, I figured it out.
(progn
(setq kill-ring (delete "" kill-ring))
(setq kill-ring-yank-pointer kill-ring)
(setq yank-menu '("Yank Menu"))
(fset 'yank-menu (cons 'keymap yank-menu))
(dolist (my-string kill-ring)
(menu-bar-update-yank-menu my-string nil)))
Life of a programmer, all that effort for just six lines of code that no one else will ever notice. :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-04-03 21:59 ` Smith_RS
@ 2014-04-04 4:34 ` Joost Kremers
2014-04-04 7:00 ` Smith_RS
0 siblings, 1 reply; 9+ messages in thread
From: Joost Kremers @ 2014-04-04 4:34 UTC (permalink / raw)
To: help-gnu-emacs
Smith_RS wrote:
> On Thursday, April 3, 2014 9:52:17 AM UTC-7, Smith_RS wrote:
>> When I try to update the kill-ring "by hand" I find that when I try to access yank-menu it is no longer in sync with the kill-ring.
>>
>> How do I fix that? The code in menu-bar.el doesn't really explain how it's kept in sync. What am I missing? Is there a hook somewhere?
>
> Never mind, I figured it out.
Did you check the doc string of `kill-ring'? There, you'll find the
warning not to use that variable directly. There are functions to update
the kill ring that you should use instead:
,----
| List of killed text sequences.
| Since the kill ring is supposed to interact nicely with cut-and-paste
| facilities offered by window systems, use of this variable should
| interact nicely with `interprogram-cut-function' and
| `interprogram-paste-function'. The functions `kill-new',
| `kill-append', and `current-kill' are supposed to implement this
| interaction; you may want to use them instead of manipulating the kill
| ring directly.
`----
And although it doesn't say so, looking at the source shows that
the yank menu is also updated.
HTH
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Annoying kill-ring behavior
2014-04-04 4:34 ` Joost Kremers
@ 2014-04-04 7:00 ` Smith_RS
0 siblings, 0 replies; 9+ messages in thread
From: Smith_RS @ 2014-04-04 7:00 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, April 3, 2014 9:34:25 PM UTC-7, Joost Kremers wrote:
> Did you check the doc string of `kill-ring'? There, you'll find the
> warning not to use that variable directly. There are functions to update
> the kill ring that you should use instead:
[ ... ]
> And although it doesn't say so, looking at the source shows that
> the yank menu is also updated.
I know, I wanted to see if it could be done.
But you raise a valid point. What I found was that if I modified kill-ring I had to also modify
kill-ring-yank-pointer.
In the simplest case you can do this, and get a clean slate:
(setq kill-ring nil)
(setq kill-ring-yank-pointer nil)
If you edit the kill-ring like this (my original problem was empty strings):
(setq kill-ring (remove "" kill-ring))
You have to do this:
(setq kill-ring-yank-pointer kill-ring)
These two web pages were helpful
http://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dnew-function.html
http://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dring_002dyank_002dpointer.html
So, yes, I'm still confused about what the real difference is between kill-ring and
kill-ring-yank-pointer, but I was able to get the behavior I wanted.
It took some more digging to fix yank-menu, but I got this to work:
(setcdr yank-menu nil)
(dolist (str kill-ring)
(menu-bar-update-yank-menu str nil))
(setcdr yank-menu (reverse (cdr yank-menu)))
Try it for yourself. :)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-04-04 7:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 22:06 Annoying kill-ring behavior Smith_RS
2014-03-31 22:45 ` Stefan Monnier
[not found] ` <mailman.18630.1396305973.10748.help-gnu-emacs@gnu.org>
2014-04-01 7:54 ` Smith_RS
2014-04-01 16:23 ` Smith_RS
2014-04-02 11:59 ` Stefan Monnier
[not found] ` <mailman.18813.1396529475.10748.help-gnu-emacs@gnu.org>
2014-04-03 16:52 ` Smith_RS
2014-04-03 21:59 ` Smith_RS
2014-04-04 4:34 ` Joost Kremers
2014-04-04 7:00 ` Smith_RS
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.