No copy-rectangle-as-kill?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

No copy-rectangle-as-kill?

Hattuari
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. ;)
_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
Reply | Threaded
Open this post in threaded view
|

Re: No copy-rectangle-as-kill?

Chris F.A. Johnson
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)))

--
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>
_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
Reply | Threaded
Open this post in threaded view
|

Re: No copy-rectangle-as-kill?

Mathias Dahl
"Chris F.A. Johnson" <[hidden email]> 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
_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
Reply | Threaded
Open this post in threaded view
|

Re: No copy-rectangle-as-kill?

optional
In reply to this post by Hattuari
You could try:

C-x r r R
C-x r i R

where R is a register name such as 'a', 'b', etc.  The first command
puts the rectange in the register named R and the second inserts the
rectange from register R.

_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
Reply | Threaded
Open this post in threaded view
|

Re: No copy-rectangle-as-kill?

Stefan Monnier
In reply to this post by Hattuari
> 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. ;)

Please send your request for enhancement via M-x report-emacs-bug
(and avoid the (X)Emacs cross-bashing because it doesn't put the maintainers
in a mood that lends itself to being nice to feature-requesters).


        Stefan
_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
Reply | Threaded
Open this post in threaded view
|

Re: No copy-rectangle-as-kill?

Holger Sparr
In reply to this post by Hattuari
On Wed, 01 Jun 2005, [hidden email] 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. ;)

There is also rect-mark.el .

The commentary section tells:

;; You can also kill or copy rectangles onto the kill ring which is
;; convenient for yanking rectangles into ordinary buffers (i.e.  ones
;; not in picture mode) and for pasting rectangles into other window
;; system programs (e.g. xterm).  These keys are by default bound to
;; `C-x r C-w' and `C-x r M-w' by analogy to the normal kill and copy
;; counterparts.


--
_______________________________________________
Help-gnu-emacs mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs