Re: Need help with function

Glynn Clements <[email protected]> Mon, 19 Jul 2004 23:59:50 +0100
Newsgroups gmane.emacs.xemacs.general
Message-ID <[email protected]>
[email protected] wrote:

> >> But there is still a problem: It seems "own-clipboard" uses the wrong 
> >> clipboard: I can paste the desired string with "yank-clipboard-selection", 
> >> but not with the middle mouse button. I'll have to find another  function 
> >> to fill the clipboard...
> 
> >own-clipboard just calls own-selection with a "type" argument of
> >'CLIPBOARD; try using (own-selection  'PRIMARY) instead, i.e.:
> 
> Don't know why, but this didn't work for me... But some search showed me 
> the function "x-store-cutbuffer" and now I have exactly what I wanted :) 

Cut buffers are yet another form of X selection, which are no longer
widely used (if they ever were).

The default button-2 behaviour for xterm is:

	~Ctrl ~Meta <Btn2Up>:insert-selection(PRIMARY, CUT_BUFFER0)

This inserts (pastes) the primary selection if it exists, and the
topmost cut buffer otherwise.

If (own-selection ... 'PRIMARY) didn't work, it's possible that
something else in your code is clearing the primary selection (i.e. 
taking then releasing it).

If you want your code to work with most X programs, it may be worth
trying to get the primary selection to work, as not all
programs/toolkits support cut buffers (e.g. Gtk doesn't).

Alternatively, you can make xterm support the clipboard with a
resource setting such as the following:

XTerm*vt100.translations:	#override	\n\
	~Ctrl ~Meta <Btn2Up>:	insert-selection(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\

> Now I only have to find out how to add "my" (aehem) function to the menu 
> that appears when I press the right mouse button.

See:
	C-h f popup-menu
	C-h v global-popup-menu
	C-h v mode-popup-menu
	C-h k <right mouse button>

-- 
Glynn Clements <[email protected]>