Paste selection to window from lisp

Brett Viren <[email protected]> Sun, 31 Aug 2014 15:31:50 -0400
Newsgroups gmane.comp.window-managers.sawfish
Message-ID <CACA9Uae7K2udV9Lmhd6BOi-9zYz6M0jh+AW4_Yfj9x8uOigqKg@mail.gmail.com>
Hi,

I wrote a little function that lets me paste the contents of the X11
selection to the currently focused window.  I have it working using
the "xdotool" program to perform the paste.  The xdotool "types" the
selection kind of slowly and I'd rather not rely on an external
program.  Is there a rep/sawfish function I can use to perform the
paste.  My searches for one came up empty.  Or, is there maybe a
better way to do this?

Here is the function.

(provide 'bv-paste)
(defun xpasteto (w)
  "Paste current selection into current window"
  (interactive "%f")
  (require 'selection)
  (let ((selection  (x-get-selection 'PRIMARY)))
    (let ((cmd (format nil "xdotool type --window %d \"%s\""
(window-id w) selection)))
      (system cmd))))
(bind-keys global-keymap "C-M-SPC" xpasteto)

-Brett.

-- 
Sawfish ML