emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keymap in yank-excluded-properties


From: Kim F. Storm
Subject: Re: keymap in yank-excluded-properties
Date: 23 Aug 2002 11:52:15 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Tak Ota <address@hidden> writes:

> Since the following change was made to yank's underpinning, a table
> created by `table.el' becomes dead after copying because keymap text
> property is stripped off at yank.
> 
> 2002-04-29  Kim F. Storm  <address@hidden>
> 
>       * subr.el (remove-yank-excluded-properties): New helper function.
>       (insert-for-yank, insert-buffer-substring-as-yank): Use it.
> 
>       * simple.el (yank-excluded-properties): Added help-echo to list.

I cannot take all the credit for this :-)  It was actually Richard who
added the yank-excluded-properties feature in the first place.

> Is it generally a good idea not to copy keymap text property? 

Definitely!

Depending on the target, keeping a keymap text property is like
burying a landmine waiting for someone to step on it.


> If
> majority of you agree that yank normally should not copy keymap
> property, is the following modification to the function
> `remove-yank-excluded-properties' acceptable?  The idea is if a
> special text property `yank-preserve-all-properties' exists in the
> region and its value is non-nil then yank will not strip any text
> properties off.

Again, it depends on what the target is.  I would say that if the
source and target buffers are the same, or have the same major-mode,
then probably keeping (more) text properties when yanking might be
acceptable.  But doing that requires saving some context info with
each kill, so its not trivial to do.


An alternative would be to have a simple function:

(defun yank-with-properties (&optional arg)
  "Like `yank', but does not remove text properties from inserted text."
  (interactive "*P")
  (let ((yank-excluded-properties nil))
    (yank arg)))        

Then you can make an alias if you like.

(defalias 'yank-table 'yank-with-properties)

Of course, the problem is how to put this functionality on C-y ...

Maybe something like this could be used:

(defun yank-keep-tables (&optional arg)
  "Like `yank' but knows about tables."
  (interactive ...)
  (let ((start (point)) end)
    (let ((yank-excluded-properties nil))
      (yank nil)
      (setq end (point)))
    (unless (table-recognize-table start end)  ;; <--- new function
      (remove-yank-excluded-properties start end))
    (if arg
      (goto-char start))))



-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]