From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: yank-match.el -- yank matches for a regexp from kill-ring Date: Tue, 04 Mar 2008 02:35:31 +0200 Organization: JURTA Message-ID: <87ablffho4.fsf@jurta.org> References: <87bqedqltf.fsf@red-bean.com> <873ar9xfps.fsf@red-bean.com> <87zlthatxy.fsf@jurta.org> <87tzjowus6.fsf@red-bean.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204591568 20306 80.91.229.12 (4 Mar 2008 00:46:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Mar 2008 00:46:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 04 01:46:34 2008 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 1JWLIf-0005NA-KT for ged-emacs-devel@m.gmane.org; Tue, 04 Mar 2008 01:46:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWLI8-0004Ej-CS for ged-emacs-devel@m.gmane.org; Mon, 03 Mar 2008 19:46:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JWLHF-0003Bq-Hp for emacs-devel@gnu.org; Mon, 03 Mar 2008 19:45:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JWLHD-00038E-VM for emacs-devel@gnu.org; Mon, 03 Mar 2008 19:45:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWLHD-00037z-FN for emacs-devel@gnu.org; Mon, 03 Mar 2008 19:45:03 -0500 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JWLHC-0003A0-VA for emacs-devel@gnu.org; Mon, 03 Mar 2008 19:45:03 -0500 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JWLH9-0001zf-I4; Tue, 04 Mar 2008 02:44:59 +0200 In-Reply-To: <87tzjowus6.fsf@red-bean.com> (Karl Fogel's message of "Sun, 02 Mar 2008 18:50:01 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu) X-Scanner-Signature: f216f799903dddc2f9accd11d8a1fded X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2349 [Mar 3 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 11 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) 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:91262 Archived-At: >> May I make some remarks? Usually a good function is harder to find >> in a separate small file. Also it is more difficult to incorporate a >> separate file into the core functionality. But this would be useful: >> when I tried using your `yank-match' at the first try it yanked the >> first match but I needed one of the next matches. Then I typed M-y >> to cycle next matches, but this method failed. I think just like a >> sequence of `C-y M-y M-y M-y' cycles the kill-ring it would be good to >> do the same for `yank-match' as `M-x yank-match RET regexp RET M-y M-y' >> to cycle matches from the kill-ring. > > Thank you, this is a good idea. > > Repeated invocations of `yank-match' will have this effect. It never > occurred to me to make M-y DTRT, but it seems obvious in retrospect: > M-y (that is, `yank-pop') should cycle through the kill-ring in the > usual way if the initial command was `yank', but cycle matches if the > initial command was `yank-match'. > >> But in any case, there's no need for a separate file for such >> a small function. > > Okay. Shall I make the changes Juri suggests above re M-y, and put > both the `yank-match' code and his code above into simple.el? Modifying `yank-pop' in simple.el to take into account the initial command `yank-match' has also benefits of using the recent and more correct code to do this. For instance, your command uses `delete-region' to replace the previously-yanked text, but `yank-pop' has more advanced code that calls (funcall (or yank-undo-function 'delete-region) ...) Also your command uses `insert' to insert the previously-yanked text, but `yank-pop' uses `insert-for-yank' to strip text properties from the inserted text according to `yank-excluded-properties'. I guess your patch was written when there was no such functions in Emacs? I think it would be safer to reuse code in `yank-pop' and just find places in it that differ from `yank-match' functionality, like `current-kill'. Maybe you could just add a new match-string argument to `current-kill' that will rotate the yanking point by N matching places? -- Juri Linkov http://www.jurta.org/emacs/