From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: multiple kill and paste from X clipboard Date: Wed, 17 Jan 2024 15:52:15 +0100 Message-ID: <87ttncm2qo.fsf@ledu-giraud.fr> References: <874jfi1s5l.fsf@ledu-giraud.fr> <83h6jiimbw.fsf@gnu.org> <87zfxazdxs.fsf@ledu-giraud.fr> <87wmse12tb.fsf@yahoo.com> <871qajykib.fsf@ledu-giraud.fr> <871qaizo14.fsf@ledu-giraud.fr> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6824"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , Po Lu To: Manuel Giraud via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 17 15:53:02 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rQ7Hp-0001Td-JQ for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Jan 2024 15:53:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQ7HI-0003vh-Ge; Wed, 17 Jan 2024 09:52:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQ7HD-0003v5-RD for help-gnu-emacs@gnu.org; Wed, 17 Jan 2024 09:52:25 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQ7HA-0001pQ-6f for help-gnu-emacs@gnu.org; Wed, 17 Jan 2024 09:52:22 -0500 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=nfe5l9KF THS8b/TH9IUp6f6Xuxn+8PuX0FW57o9iz9s=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=Ob/1R6ZyWkkgOFIQLj8cKoKwgOr9TX qKdFgJr9m+a9nTPW2Gm9+DhSFd5z/qH3N2HpRAWLieQt5/rGvO76sjBQ== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=nfe5l9KFTHS8b/TH 9IUp6f6Xuxn+8PuX0FW57o9iz9s=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=CcKgPNKSDY58G7rx9LEdcO9dQEGddwXhLOlaby fgYPn2tQQgVVnfwdRs6zLnR2aKqyRGZgf6/mWyUGaNM6R/J9EgbjMdapflD15JL98sWqGH 68yfH/UxKZA2aFihQE7WVty83JK9UcszV31h5hqiZS+2z9RNvpVbUmqm9SnKwovJoSZRtw tULrhzBS02HqbJPAirToPcfp360PRmburWhcmhyYXzJ0123TBdaAGVOsVHS8WeYObKevhZ YMDGS3cnrIpjzdxMQSvMD3LEVN/8uPz+4JCmAyML2tq0tYncuGReBLrPmTXHELgjU3P0fy p54SdzsOMUmFOBGsC5MZDOtA== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 5c07a1b8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 17 Jan 2024 15:52:16 +0100 (CET) In-Reply-To: <871qaizo14.fsf@ledu-giraud.fr> (Manuel Giraud via Users list for the's message of "Mon, 15 Jan 2024 15:09:27 +0100") Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145750 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Manuel Giraud via Users list for the GNU Emacs text editor writes: > Stefan Monnier via Users list for the GNU Emacs text editor > writes: > >>> (add-hook 'x-sent-selection-functions 'next-primary) >> >> That's what I was about to suggest. I've never seen it used until now, >> so I wouldn't be surprised if it's quirky, tho. > > Yes, I've tested it lightly and it is not 100% reliable: sometimes it > works and sometimes I just get one in two selections. Hi, I'm still toying with this idea with the following Lisp code (no more timer involved): --8<---------------cut here---------------start------------->8--- (defvar primary-list nil) (defun next-primary (name type success) (when (and (eq name 'PRIMARY) (not (eq type 'TARGETS)) success) (if primary-list (gui-set-selection 'PRIMARY (pop primary-list)) ;; Remove me and clear PRIMARY (remove-hook 'x-sent-selection-functions 'next-primary) (gui-set-selection 'PRIMARY "")))) (defun successively-in-primary (list) (add-hook 'x-sent-selection-functions 'next-primary) (gui-set-selection 'PRIMARY (car list)) (setq primary-list (cdr list))) (defun test-me () (interactive) (successively-in-primary (list "hello" "how" "are" "you?"))) --8<---------------cut here---------------end--------------->8--- As I said previously, it works with some X client (like xterm) but with a more useful one (Firefox) I just get half of the selections. I tried to debug this and it seems to me that it is because Firefox issues some "PRIMARY TARGETS" requests that ends up =C2=AB=C2=A0consuming= =C2=A0=C2=BB the user data (I'm not sure this is what happen but this is my interpretation of it). Anyway, I have put the following patch in place and it solves this issue with Firefox. Maybe Po you have an idea of what is going on here? Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=targets.patch diff --git a/src/xselect.c b/src/xselect.c index fd0f06eeed9..27c86cf86ed 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1231,6 +1231,10 @@ x_handle_selection_request (struct selection_input_event *event) xfree (cs.data); } + else if (EQ (target_symbol, QTARGETS)) + { + success = true; + } else { if (property == None) --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--