From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: yank-handler Date: 15 May 2003 01:09:34 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5x1xz13z2p.fsf@kfs2.cua.dk> References: <200305141603.h4EG3HZW017616@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052947419 27750 80.91.224.249 (14 May 2003 21:23:39 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 14 May 2003 21:23:39 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed May 14 23:23:37 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19G3ir-0007DO-00 for ; Wed, 14 May 2003 23:23:37 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19G3qP-0006Jw-00 for ; Wed, 14 May 2003 23:31:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19G3jw-0005CQ-08 for emacs-devel@quimby.gnus.org; Wed, 14 May 2003 17:24:44 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19G3i4-0004au-00 for emacs-devel@gnu.org; Wed, 14 May 2003 17:22:48 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19G3YV-0001gQ-00 for emacs-devel@gnu.org; Wed, 14 May 2003 17:12:56 -0400 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19G3Wx-0000tD-00 for emacs-devel@gnu.org; Wed, 14 May 2003 17:11:19 -0400 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id 590787C017; Wed, 14 May 2003 23:11:11 +0200 (CEST) Original-To: "Stefan Monnier" In-Reply-To: <200305141603.h4EG3HZW017616@rum.cs.yale.edu> Original-Lines: 55 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13878 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13878 "Stefan Monnier" writes: > I'd like to get diff-mode to behave as follows: > > If I kill a piece of a hunk and then yank it in some other buffer, > the "[+-! ]" prefix added to each and every line should be removed > (unless I'm yanking back into a diff-mode buffer or unless there's > something like a "@@ -463,4 +463,36 @@" marker, obviously). > > I'm still not quite sure whether it's a good idea or not, but to > figure that out, I'd like to experiment with it, but I can't seem > to figure out how to do it. > > More specifically, it seems that the yank-handler property can only be > set by passing the proper argument to `kill-new' (or one > of its front men). Is that right ? Why is that ? Because that was the context in which the idea was conceived (e.g. for a mode like table-mode where a keymap property on text in a table cell (but not on the buffer as a whole) would remap kill-region etc. to table-kill-region etc. which would set the proper yank-handler for yanking killed table contents in some sensible manner. > I don't want to rebind C-k, C-w, M-w and whatnot just to do that. > I'd rather either put the property directly on the text, or set > some buffer-local `default-yank-handler-for-kill' variable. I like the simplicity of having a buffer-local default-yank-handler-for-kill variable (default nil). I guess it would also work by having the yank-handler property directly on the text in the buffer; especially since that property is supposed to be removed automatically when the text is yanked into the buffer (see insert-for-yank). > > Any comment ? Feel free to go ahead and improve the yank-handler functionality. I think those changes can be localized to kill-new and kill-append like this: - In `kill-new' and `kill-append' add this at the beginning: (unless yank-handler (setq yank-handler default-yank-handler-for-kill)) - In `kill-new', simply remove this "else part" in the second if: (remove-list-of-text-properties 0 1 '(yank-handler) string)) Your new functionality for diff-mode will be a good "proof of concept". -- Kim F. Storm http://www.cua.dk