Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeping save highlighted region to kill ring #4

Closed
tomhk215 opened this issue Jan 15, 2016 · 6 comments
Closed

Keeping save highlighted region to kill ring #4

tomhk215 opened this issue Jan 15, 2016 · 6 comments

Comments

@tomhk215
Copy link

I just have this configuration.

(add-to-list 'after-init-hook 'clipmon-mode-start)

Upon highlighting a region, no matter in emacs or in other applications, it keeps pushing the highlighted text to the kill ring. Can it be configured so that text only push to kill ring when I copy it?

@bburns
Copy link
Owner

bburns commented Jan 16, 2016

Hmm, it's not supposed to do that - I think you found a bug -

I'm on Windows, where there is just the clipboard - you have to explicitly copy things to it, whereas on Linux, you can just select text and it will be added to the primary selection, which is separate from the clipboard - I hadn't understood that when I wrote this, and just did some cursory tests on a Linux VM, which seemed to check out.

So there should be a way to distinguish those in Emacs - I'll take a look at it.

Thanks for the report!

@tomhk215
Copy link
Author

Finally, I figure out the solution. Under the GNU Emacs Manual:

Under X, whenever the region is active (see Chapter 8 [Mark], page 45), the text in the
region is saved in the primary selection. This applies regardless of whether the region was
made by dragging or clicking the mouse (see Section 18.1 [Mouse Commands], page 162),
or by keyboard commands (e.g., by typing C-SPC and moving point; see Section 8.1 [Setting
Mark], page 45).
If you change the variable select-active-regions to only, Emacs saves only temporar-
ily active regions to the primary selection, i.e., those made with the mouse or with shift
selection (see Section 8.6 [Shift Selection], page 49). If you change select-active-regions
to nil, Emacs avoids saving active regions to the primary selection entirely.

So, I just do (setq select-active-regions nil)
I think this may also be related to the gui hanging issue. Still trying.

@bburns
Copy link
Owner

bburns commented Jan 18, 2016

That's great, thanks for finding that! I'll put out an update later
tonight.

Brian

On Mon, Jan 18, 2016 at 4:30 AM, tomhk215 notifications@github.com wrote:

Finally, I figure out the solution. Under the GNU Emacs Manual:

Under X, whenever the region is active (see Chapter 8 [Mark], page 45),
the text in the
region is saved in the primary selection. This applies regardless of
whether the region was
made by dragging or clicking the mouse (see Section 18.1 [Mouse Commands],
page 162),
or by keyboard commands (e.g., by typing C-SPC and moving point; see
Section 8.1 [Setting
Mark], page 45).
If you change the variable select-active-regions to only, Emacs saves only
temporar-
ily active regions to the primary selection, i.e., those made with the
mouse or with shift
selection (see Section 8.6 [Shift Selection], page 49). If you change
select-active-regions
to nil, Emacs avoids saving active regions to the primary selection
entirely.

So, I just do (setq select-active-regions nil)


Reply to this email directly or view it on GitHub
#4 (comment).

@bburns
Copy link
Owner

bburns commented Jan 19, 2016

Well this seems to have fixed it -
(ignore-errors (x-get-selection 'CLIPBOARD)))
instead of
(ignore-errors (x-get-selection-value)))

the latter defaults to using the primary selection. Unfortunately it didn't help with the gui bug - I'll have to keep working on that one.

Uploading to Melpa soon - might take a while for it to show up.

Thanks again,
Brian

@bburns bburns closed this as completed Jan 19, 2016
@bburns
Copy link
Owner

bburns commented Jan 19, 2016

Actually I think I'll make it an option to use the primary selection instead of the clipboard, as some people might prefer to use it that way - then they could just select text in the browser to copy it to Emacs, for instance. Will try to get it to cooperate for both Windows and Linux.

@bburns bburns reopened this Jan 19, 2016
@bburns bburns closed this as completed in e1620af Jan 28, 2016
@bburns
Copy link
Owner

bburns commented Jan 28, 2016

Okay, I finally fixed the problem with the duplicates in the kill-ring - it needed to check if Emacs was the owner of the selection with x-selection-owner-p.

And I initially added an option clipmon-use-primary-selection, which worked - you could select some text in Firefox, and it would be added to the kill-ring. But if the timer happened to fire when you were in the midst of making a selection, it would add the partial text to the kill-ring, or insert it if autoinsert was on. So I just removed that option. Now to get something added to the kill-ring from an external application the user will need to copy it to the clipboard, which was the original intent of the program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants