Re: Need help with function
Glynn Clements <[email protected]> Sun, 18 Jul 2004 17:08:23 +0100
| Newsgroups | gmane.emacs.xemacs.general |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Your function quite hits the spot: > > >(defun mg-copy-position () > > "Copy a string of the form filename:linenumber into the clipboard" > > (interactive) > > (own-clipboard (format "%s:%d" > > (or > (file-name-nondirectory buffer-file-name) "") > > (line-number)))) > > 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... The middle mouse button usually pastes the primary selection, not the clipboard. own-clipboard just calls own-selection with a "type" argument of 'CLIPBOARD; try using (own-selection 'PRIMARY) instead, i.e.: (defun mg-copy-position () "Copy a string of the form filename:linenumber into the clipboard" (interactive) (own-selection (format "%s:%d" (or (file-name-nondirectory buffer-file-name) "") (line-number)) 'PRIMARY)) However, note that the primary selection is more "transient" than the clipboard. Highlighting text in an application usually causes that application to take the primary selection, discarding what was previously there. OTOH, an application normally only takes the clipboard in response to a distinct user action (e.g. Ctrl-Insert, Ctrl-C). -- Glynn Clements <[email protected]>