emacs-devel
[Top][All Lists]
Advanced

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

Re: Question about copy-region-as-kill


From: John Wiegley
Subject: Re: Question about copy-region-as-kill
Date: Sat, 06 Apr 2002 13:38:39 -0700
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu)

>>>>> On Sat Apr  6, RMS writes:

> Text properties are part of the text.  Aside from special cases
> there is no reason not to copy them.

Yet there DO exist reasons to avoid doing so, which at present force
people to resort to overlays.  I think there is sufficient evidence to
show that not copying text properties in certain buffers is a good
thing.

We're talking about such a small change here (see below).  I can't
believe there is a valid philosophical reason to _deny_ such
configurability, forcing an entirely different paradigm (overlays)
just to avoid the copy.

And whether these are stripped at kill or yank, I don't care.  I just
don't want read-only copied around when I kill text from Eshell, and
then yank it into an e-mail message!

John

----------------------------------------------------------------------

(defvar copy-properties-on-kill t)
(make-variable-buffer-local 'copy-properties-on-kill))

(defun copy-region-as-kill (beg end)
  "Save the region as if killed, but don't kill it.
In Transient Mark mode, deactivate the mark.
If `interprogram-cut-function' is non-nil, also save the text for a window
system cut and paste."
  (interactive "r")
  (let ((str (if copy-properties-on-kill
                 (buffer-substring beg end)
               (buffer-substring-no-properties beg end))))
    (if (eq last-command 'kill-region)
        (kill-append str (< end beg))
      (kill-new str)))
  (if transient-mark-mode
      (setq deactivate-mark t))
  nil)



reply via email to

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