From: Manuel Giraud via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: Manuel Giraud via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: multiple kill and paste from X clipboard
Date: Sun, 14 Jan 2024 16:58:36 +0100 [thread overview]
Message-ID: <871qajykib.fsf@ledu-giraud.fr> (raw)
In-Reply-To: <87wmse12tb.fsf@yahoo.com> (Po Lu's message of "Sat, 13 Jan 2024 08:42:40 +0800")
Hi,
FTR, I was able to get the behaviour I wanted with the following code.
So far, it has two drawbacks:
- it works with the primary selection and is, therefore, X11
only
- it does not work on Emacs itself (but we have better
alternatives here ;-)
--8<---------------cut here---------------start------------->8---
(defvar primary-list nil)
(defvar my-timer nil)
(defun next-primary (name type success)
(when (and (eq name 'PRIMARY)
(not (eq type 'TARGETS))
success
primary-list)
(gui-set-selection 'PRIMARY (pop primary-list))))
(defun clean-up-when-empty ()
(unless primary-list
(cancel-timer my-timer)
(setq my-timer nil)
(remove-hook 'x-sent-selection-functions 'next-primary)))
(defun put-list-into-primary (list)
(gui-set-selection 'PRIMARY (car list))
(setq primary-list (cdr list))
(add-hook 'x-sent-selection-functions 'next-primary)
(setq my-timer (run-with-timer t 1 'clean-up-when-empty)))
(defun test-me ()
(interactive)
(put-list-into-primary (list "hello" "how" "are" "you?")))
--8<---------------cut here---------------end--------------->8---
--
Manuel Giraud
next prev parent reply other threads:[~2024-01-14 15:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 15:35 multiple kill and paste from X clipboard Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-12 15:49 ` Eli Zaretskii
2024-01-12 16:58 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-12 19:49 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-13 0:42 ` Po Lu
2024-01-13 10:08 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-14 15:58 ` Manuel Giraud via Users list for the GNU Emacs text editor [this message]
2024-01-14 22:45 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-01-15 14:09 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-17 14:52 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-31 19:27 ` Stefan Monnier
2024-02-02 15:58 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-02-02 16:54 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-01-12 20:12 ` orzodk
2024-01-12 21:32 ` Manuel Giraud via Users list for the GNU Emacs text editor
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=871qajykib.fsf@ledu-giraud.fr \
--to=help-gnu-emacs@gnu.org \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.com \
--cc=manuel@ledu-giraud.fr \
/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).