From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs24/gtk3 - how to mark rectangle of to primary selection?
Date: Fri, 29 Jun 2012 09:38:53 -0700 (PDT) [thread overview]
Message-ID: <3ba9c601-e80d-49d4-821c-63cf3210c469@mi5g2000pbc.googlegroups.com> (raw)
In-Reply-To: mailman.3573.1340817336.855.help-gnu-emacs@gnu.org
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
prev parent reply other threads:[~2012-06-29 16:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 14:24 emacs24/gtk3 - how to mark rectangle of to primary selection? Paul K
2012-06-26 14:52 ` Peter Dyballa
2012-06-26 18:29 ` Jonathan Groll
2012-06-26 20:33 ` Paul K
2012-06-26 20:44 ` Peter Dyballa
2012-06-26 20:58 ` Paul K
2012-06-26 21:19 ` suvayu ali
2012-06-27 6:58 ` Yuri Khan
[not found] ` <mailman.3529.1340742812.855.help-gnu-emacs@gnu.org>
2012-06-27 11:47 ` Xah Lee
2012-06-27 17:15 ` Aurélien Aptel
2012-06-27 18:41 ` Andreas Röhler
[not found] ` <mailman.3573.1340817336.855.help-gnu-emacs@gnu.org>
2012-06-29 16:38 ` Xah Lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ba9c601-e80d-49d4-821c-63cf3210c469@mi5g2000pbc.googlegroups.com \
--to=xahlee@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.