Copy variable to system clipboard (as simpleclip)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Copy variable to system clipboard (as simpleclip)

Tim Johnson-2
Using emacs 25.1.1 in graphic mode on linux ubuntu 14.04. Clipboard
manager is glipper 2.4

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?

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy variable to system clipboard (as simpleclip)

Emanuel Berg-4
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

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy variable to system clipboard (as simpleclip)

Tim Johnson-2
* Emanuel Berg <[hidden email]> [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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy variable to system clipboard (as simpleclip)

Tim Johnson-2
* Tim Johnson <[hidden email]> [170807 17:01]:

> * Emanuel Berg <[hidden email]> [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).
   Update: Seems to work. I owe you a beer. :)
--
Tim
http://www.akwebsoft.com, http://www.tj49.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy variable to system clipboard (as simpleclip)

Emanuel Berg-4
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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy variable to system clipboard (as simpleclip)

Tim Johnson-2
* Emanuel Berg <[hidden email]> [170808 10:22]:

> 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 :)
  Thanks again!
--
Tim
http://www.akwebsoft.com, http://www.tj49.com

Loading...