[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: No copy-rectangle-as-kill?
From: |
Mathias Dahl |
Subject: |
Re: No copy-rectangle-as-kill? |
Date: |
Wed, 01 Jun 2005 15:01:52 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) |
"Chris F.A. Johnson" <cfajohnson@gmail.com> writes:
> On Wed, 01 Jun 2005 at 09:50 GMT, Hattuari wrote:
>> Am I overlooking something, or is there no command in Emacs to copy a
>> rectangle into the last killed rectangle "special place" without also
>> removing it from the current buffer? I gotta tell y'all, XEmacs has better
>> rectangle support than Emacs. ;)
>
> (defun copy-rectangle-as-kill ()
> (interactive)
> (save-excursion
> (kill-rectangle (mark) (point))
> (exchange-point-and-mark)
> (yank-rectangle)))
I like this better:
(defun copy-rectangle-as-kill (start end)
"Copy rectangle with corners at point and mark; save as last killed one.
Calling from program, supply two args START and END, buffer positions.
But in programs you might prefer to use `extract-rectangle'."
(interactive "r")
(setq killed-rectangle (extract-rectangle start end))
(message "Rectangle saved."))
It does not feel right to me messing with the buffer just to get a
copy of some of it.
/Mathias