[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs24/gtk3 - how to mark rectangle of to primary selection?
From: |
Xah Lee |
Subject: |
Re: emacs24/gtk3 - how to mark rectangle of to primary selection? |
Date: |
Fri, 29 Jun 2012 09:38:53 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Jun 27, 10:15 am, Aurélien Aptel <aurelien.aptel+em...@gmail.com>
wrote:
> Well, it was longer than expected... Turns out if you don't deactive
> the mark, emacs copies the regular active region. My guess is it
> corresponds to mouse selection: once a region is selected it is copied
> to the primary selection.
>
> (defun my-copy-rect-to-primary ()
> (interactive)
> (when (region-active-p)
> (let ((text (mapconcat 'identity
> (extract-rectangle
> (region-beginning)
> (region-end)) "\n")))
> (deactivate-mark) ;; lost 30mn because of this
> (x-set-selection 'PRIMARY text)
> (message "%s" text))))
hi Aurélien, thank you for coding this.
i tried to use it and it didn't work on Windows.
here's a alt version i coded up for learning:
(defun copy-rectangle-to-clipboard (p1 p2)
"Copy region as column (rectangle) to operating system's clipboard.
This command will also put the text in register 0. (see: `copy-to-
register')"
(interactive "r")
(let ((x-select-enable-clipboard t))
(copy-rectangle-to-register ?0 p1 p2)
(kill-new
(with-temp-buffer
(insert-register ?0)
(buffer-string) )) ) )
it does over-ride register 0 content, but i think one can modify it so
it restores, or not using register all together.
Xah
- Re: emacs24/gtk3 - how to mark rectangle of to primary selection?, (continued)
Message not available
Message not availableRe: emacs24/gtk3 - how to mark rectangle of to primary selection?,
Xah Lee <=