From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: kill-new discards current X selection Date: Wed, 26 Aug 2009 23:03:33 -0400 Message-ID: References: <4A95606A.6050606@gnu.org> <1f77704b0908261339y2baac531j11c6b230c28f1fd6@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1251342254 19805 80.91.229.12 (27 Aug 2009 03:04:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Aug 2009 03:04:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Sam Steingold Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 27 05:04:07 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MgVHT-0005Kk-Hn for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 05:04:07 +0200 Original-Received: from localhost ([127.0.0.1]:59040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgVHT-0001Sr-1Q for ged-emacs-devel@m.gmane.org; Wed, 26 Aug 2009 23:04:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgVH5-0001GW-1Q for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:03:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgVH0-0001E3-70 for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:03:42 -0400 Original-Received: from [199.232.76.173] (port=40736 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgVGz-0001Dw-TQ for emacs-devel@gnu.org; Wed, 26 Aug 2009 23:03:37 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:48705 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgVGx-00084N-7h; Wed, 26 Aug 2009 23:03:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As8EAAeUlUpFpYuS/2dsb2JhbACBU9ZvhBoFh2M X-IronPort-AV: E=Sophos;i="4.44,283,1249272000"; d="scan'208";a="44274286" Original-Received: from 69-165-139-146.dsl.teksavvy.com (HELO ceviche.home) ([69.165.139.146]) by ironport2-out.teksavvy.com with ESMTP; 26 Aug 2009 23:02:39 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 90764B40F3; Wed, 26 Aug 2009 23:03:33 -0400 (EDT) In-Reply-To: <1f77704b0908261339y2baac531j11c6b230c28f1fd6@mail.gmail.com> (Sam Steingold's message of "Wed, 26 Aug 2009 16:39:25 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114655 Archived-At: >> BTW, here's the version I use in my own local collection of hacks. >>=20 >> =3D=3D=3D modified file 'lisp/simple.el' >> --- lisp/simple.el =A0 =A0 =A02009-08-19 08:31:59 +0000 >> +++ lisp/simple.el =A0 =A0 =A02009-08-21 14:24:38 +0000 >> @@ -2799,6 +2851,21 @@ >> =A0argument is not used by `insert-for-yank'. =A0However, since Lisp code >> =A0may access and use elements from the kill ring directly, the STRING >> =A0argument should still be a \"useful\" string for such uses." >> + =A0;; To better pretend that X-selection =3D head-of-kill-ring, we cop= y other >> + =A0;; application's X-selection to the kill-ring. =A0This comes in han= dy when >> + =A0;; you do something like: >> + =A0;; - copy a piece of text in your web-browser. >> + =A0;; - have to do some editing (including killing) before you can yank >> + =A0;; =A0 that text. >> + =A0;; Note: this piece of code inspired from current-kill. >> + =A0(let ((paste (and interprogram-paste-function >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(funcall interprogram-paste-fun= ction)))) >> + =A0 =A0(when paste >> + =A0 =A0 =A0(let ((interprogram-cut-function nil) >> + =A0 =A0 =A0 =A0 =A0 =A0(interprogram-paste-function nil)) >> + =A0 =A0 =A0 =A0(kill-new paste)))) > I think my version is just a little bit more transparent. Actually, IIRC I specifically (re)used kill-new to avoid code duplication. >> + =A0;; The actual kill-new functionality. >> + =A0(when (equal string (car kill-ring)) (setq replace t)) > this seems to be a separate nice feature, similar to bash > HISTCONTROL=3Dignoredups. > I think it would be a good separate addition, controlled by > kill-ignore-duplicates Yes, it's a separate "feature". I can't remember which use-case this was designed for, but I remember I added it for one particular situation where it makes a big difference (not that it doesn't remove all duplicates, just consecutive duplicates). Stefan