[Top][All Lists]

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

Re: copy-rectangle-to-kill-ring

From: Kevin Rodgers
Subject: Re: copy-rectangle-to-kill-ring
Date: Wed, 10 Jan 2007 23:14:09 -0700
User-agent: Thunderbird (Macintosh/20061207)

Kevin Rodgers wrote:
Wilmar Igl wrote:
sorry, I don't want to  be a nuisance. However, I'd like to suggest to
include a function to copy a rectangle into the kill ring which is not available at the moment (only copy-rectangle-to-register).

Do you mean "copy a rectangle so that `C-x r y' can insert it"?  Or do
you mean "copy a rectangle so that `C-y' can insert it"?

If the former, this should do the job:

(defun copy-rectangle-as-kill (beg end)
  "Copy rectangular region into `killed-rectangle', but don't delete it.
The rectangle can then be yanked via \\[yank-rectangle]."
  (interactive "r")
  (setq killed-rectangle (extract-rectangle beg end)))

Or if the latter, how about:

(defun copy-rectangle-as-kill-region (beg end)
  "Copy rectangular region into the kill ring, but don't delete it.
The text can then be yanked via \\[yank]."
  ;; Based on copy-region-as-kill, but with no filtering:
  (interactive "r")
  (let ((text (mapconcat 'identity (extract-rectangle beg end) "\n")))
    (if (eq last-command 'kill-region)
        (kill-append text (< end beg))
      (kill-new text)))
  (if transient-mark-mode
      (setq deactivate-mark t))

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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