(setq wl-copy-process nil)
(defun wl-copy (text)
  (setq wl-copy-process (make-process :name "wl-copy"
  				      :buffer nil
				      :command '("wl-copy" "-f" "-n")
				      :connection-type 'pipe
				      :noquery t))
  (process-send-string wl-copy-process text)
  (process-send-eof wl-copy-process))

(defun wl-paste ()
  (if (and wl-copy-process (process-live-p wl-copy-process))
      nil
      (shell-command-to-string "wl-paste -n | tr -d \r")))

(setq interprogram-cut-function #'wl-copy
      interprogram-paste-function #'wl-paste)

(provide 'clipboard)