unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: bkhl@elektrubadur.se (Björn Lindström)
Subject: interprogram-cut/paste-functions
Date: Tue, 02 Aug 2005 14:52:25 +0200	[thread overview]
Message-ID: <87iryotsae.fsf@lucien.dreaming> (raw)

I'm trying to get my text mode Emacs session to interoperate with my X
clipboard, using xsel (http://www.vergenet.net/~conrad/software/xsel/).

The following sort of works, except that when I yank something in Emacs,
the empty string gets pushed to kill-ring. I suspect that I
misunderstand when interprogram-paste-function is supposed to return
nil, but I need help figuring out how.

Here's my attempt so far:

(defun bkhl-cut-function (text &optional push)
    (with-temp-buffer
      (insert text)
      (call-process-region (point-min) (point-max) "xsel" nil 0 "--input")))
(setq interprogram-cut-function 'bkhl-cut-function)

(defun bkhl-paste-function ()
  (let ((text (with-output-to-string
		(with-current-buffer standard-output
		  (call-process "xsel" nil standard-output nil "--output")))))
    (unless (string= (car kill-ring) text)
      text)))
(setq interprogram-paste-function 'bkhl-paste-function)

                 reply	other threads:[~2005-08-02 12:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iryotsae.fsf@lucien.dreaming \
    --to=bkhl@elektrubadur.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).