From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: emacs24/gtk3 - how to mark rectangle of to primary selection? Date: Fri, 29 Jun 2012 09:38:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3ba9c601-e80d-49d4-821c-63cf3210c469@mi5g2000pbc.googlegroups.com> References: <87sjdi3p0y.wl%lists@groll.co.za> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1340988020 13350 80.91.229.3 (29 Jun 2012 16:40:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 29 Jun 2012 16:40:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 29 18:40:19 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SkeF0-00086N-L8 for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Jun 2012 18:40:18 +0200 Original-Received: from localhost ([::1]:50738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkeF0-0003Te-KT for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Jun 2012 12:40:18 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!mi5g2000pbc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 42 Original-NNTP-Posting-Host: 76.126.112.84 Original-X-Trace: posting.google.com 1340987933 31625 127.0.0.1 (29 Jun 2012 16:38:53 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 29 Jun 2012 16:38:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: mi5g2000pbc.googlegroups.com; posting-host=76.126.112.84; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.43 Safari/536.11,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:193178 comp.emacs:102528 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85569 Archived-At: On Jun 27, 10:15=A0am, Aur=E9lien Aptel 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 () > =A0 (interactive) > =A0 (when (region-active-p) > =A0 =A0 (let ((text (mapconcat 'identity > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(extract-rectangle > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (region-beginning= ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (region-end)) "\n= "))) > =A0 =A0 =A0 (deactivate-mark) ;; lost 30mn because of this > =A0 =A0 =A0 (x-set-selection 'PRIMARY text) > =A0 =A0 =A0 (message "%s" text)))) hi Aur=E9lien, 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