Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Copy variable to system clipboard (as simpleclip)

2 views
Skip to first unread message

Tim Johnson

unread,
Aug 7, 2017, 8:58:54 PM8/7/17
to help-gn...@gnu.org
* Emanuel Berg <moa...@zoho.com> [170807 16:36]:
> Tim Johnson wrote:
>
> > I use simpleclip routinely so that I can copy
> > and paste from the system clipboard without
> > affecting the emacs kill ring. However,
> > I could use a function that would copy any
> > string variable (such as output from
> > buffer-file-name) to the system clipboard.
> >
> > Is such function available?
>
> Yes, use xsel(1x) as I did here - one of the
> first things I wrote in Elisp by the way -
> could probably benefit from an upgrade, but
> hey, if it ain't broke, fix it, to make sure
> it is!
>
> http://user.it.uu.se/~embe8573/emacs-init/xsel.el

Thanks Emanuel. I just installed xsel and will play with your code
later (or tomorrow).

cheers
--
Tim
http://www.akwebsoft.com, http://www.tj49.com

Tim Johnson

unread,
Aug 7, 2017, 9:15:41 PM8/7/17
to help-gn...@gnu.org
* Tim Johnson <t...@akwebsoft.com> [170807 17:01]:
Update: Seems to work. I owe you a beer. :)

Emanuel Berg

unread,
Aug 8, 2017, 2:10:17 PM8/8/17
to help-gn...@gnu.org
Tim Johnson wrote:

> Update: Seems to work. I owe you a beer. :)

Owe me a beer? Have you never heard of free
software, with "free" as in free beer?

Anyway I went thru the code today after all
these years, and found a couple of small things
to change:

http://user.it.uu.se/~embe8573/emacs-init/xsel.el

I also added this:

(defun x-copy-symbol (sym)
"Copy the value of SYM to the X clipboard."
(interactive "S Symbol: ")
(let*((val (symbol-value sym))
(str (format "%s" val)) )
(set-X-clipboard-to-string str) ))
;; Test:
;; (progn (x-copy-symbol 'fill-column) (insert-X-clipboard))
;; (progn (call-interactively #'x-copy-symbol) (insert-X-clipboard))

Keep it up :)

--
underground experts united
http://user.it.uu.se/~embe8573


Tim Johnson

unread,
Aug 8, 2017, 7:49:59 PM8/8/17
to help-gn...@gnu.org
* Emanuel Berg <moa...@zoho.com> [170808 10:22]:
Thanks again!
0 new messages