From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tak Kunihiro Newsgroups: gmane.emacs.bugs Subject: bug#27530: patch to cut and copy secondary Date: Mon, 11 Sep 2017 11:03:58 +0900 Message-ID: <63B07AE9-1836-4EC5-8913-2D03249B9847@misasa.okayama-u.ac.jp> References: <83k21az5kw.fsf@gnu.org> <20170908.080208.755485899479344801.tkk@misasa.okayama-u.ac.jp> <83vakty4ra.fsf@gnu.org> <20170910.120143.946950380669459918.tkk@misasa.okayama-u.ac.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1505095540 32659 195.159.176.226 (11 Sep 2017 02:05:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 11 Sep 2017 02:05:40 +0000 (UTC) Cc: Kunihiro Tak , 27530@debbugs.gnu.org To: eliz@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 11 04:05:31 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drE67-0007Nu-Vd for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Sep 2017 04:05:16 +0200 Original-Received: from localhost ([::1]:55022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drE6E-0005Yj-Rh for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Sep 2017 22:05:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drE60-0005UP-NI for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2017 22:05:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drE5u-0000Gz-6E for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2017 22:05:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51419) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1drE5u-0000Gt-2N for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2017 22:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1drE5t-0008Q5-Qm for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2017 22:05:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Sep 2017 02:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27530 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 27530-submit@debbugs.gnu.org id=B27530.150509546032314 (code B ref 27530); Mon, 11 Sep 2017 02:05:01 +0000 Original-Received: (at 27530) by debbugs.gnu.org; 11 Sep 2017 02:04:20 +0000 Original-Received: from localhost ([127.0.0.1]:60100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drE5E-0008P8-94 for submit@debbugs.gnu.org; Sun, 10 Sep 2017 22:04:20 -0400 Original-Received: from mxl065v67.mxlogic.net ([208.81.65.67]:48156 helo=s14p02o144.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drE5C-0008Oy-1Z for 27530@debbugs.gnu.org; Sun, 10 Sep 2017 22:04:19 -0400 Original-Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s14p02o144.mxlogic.net(mxl_mta-8.5.0-1834) over TLS secured channel with ESMTP id b1fe5b95.0.403085.00-399.842883.s14p02o144.mxlogic.net (envelope-from ); Sun, 10 Sep 2017 20:04:12 -0600 (MDT) X-MXL-Hash: 59b5ef1c4d8dfcaa-a2865cbe35ccd9f99b50af36e95bce00ee6fce48 Original-Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 478a_26e1_bdf4b484_e9bd_41b4_aaa6_14a4adb5fca5; Mon, 11 Sep 2017 11:04:06 +0900 Original-Received: from [192.168.1.50] (vesta.misasa.okayama-u.ac.jp [150.46.48.154]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id E0D694C0A60; Mon, 11 Sep 2017 11:04:06 +0900 (JST) In-Reply-To: <20170910.120143.946950380669459918.tkk@misasa.okayama-u.ac.jp> X-Mailer: Apple Mail (2.1878.6) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 4 Rules triggered EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_PASS=0, RV6112=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6112> : inlines <6061> : streams <1762485> : uri <2498378> X-AnalysisOut: [v=2.2 cv=ObLoNlbY c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=N659UExz7-8A:10 a=2JC] X-AnalysisOut: [JgTwv5E4A:10 a=q8Ke-AadlAyCB7C3wQIA:9 a=7Zwj6sZBwVKJAoWSPK] X-AnalysisOut: [xL6X1jA+E=:19 a=Rf6LOLzmjq9_XpVi:21 a=ozuXWcog_ikqQnH-:21 ] X-AnalysisOut: [a=pILNOxqGKmIA:10] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017091008); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136758 Archived-At: I am sending a patch relative to lisp/mouse.el to let user to set beginning and end of the region from those of the secondary selection. I hope this meets your comments and please revise when it=92s not good! * Change log 2017-09-11 Tak Kunihiro Add functions to set beginning and end of the region from those of the secondary selection and vise versa * lisp/mouse.el (secondary-selection-exist-p): New function to allow callers to tell existence of the secondary selection in current buffer. (secondary-selection-to-region): New function to set beginning and end of the region from those of the secondary selection. (secondary-selection-from-region): New function to set beginning and end of the secondary selection from those of the region. (Bug#27530) * Patch diff --git a/mouse.260.el b/mouse.el old mode 100644 new mode 100755 index 2fbaaad..6ca44e0 --- a/mouse.260.el +++ b/mouse.el @@ -1916,6 +1916,32 @@ CLICK position, kill the secondary selection." (> (length str) 0) (gui-set-selection 'SECONDARY str)))) =20 +(defun secondary-selection-exist-p () + "Return if there is the secondary selection in current buffer." + (memq mouse-secondary-overlay (overlays-in (point-min) (point-max)))) + +(defun secondary-selection-to-region () + "Set beginning and end of the region to those of the secondary = selection. +This works when the secondary selection exists and the region +does not exist in current buffer. The secondary selection will +be deleted afterward." + (when (and (not (region-active-p)) + (secondary-selection-exist-p)) + (let* ((beg (overlay-start mouse-secondary-overlay)) + (end (overlay-end mouse-secondary-overlay)) + ;; Restore point to whichever closer. + (is-point-front (< (point) (/ (+ beg end) 2)))) + (push-mark (if is-point-front end beg) t t) + (goto-char (if is-point-front beg end))) + ;; Delete the secondary selection on current buffer. + (delete-overlay mouse-secondary-overlay))) + +(defun secondary-selection-from-region () + "Set beginning and end of the secondary selection to those of the = region." + (when (region-active-p) ; Create the secondary selection from the = region. + (delete-overlay mouse-secondary-overlay) ; Delete the secondary = selection even on a different buffer. + (move-overlay mouse-secondary-overlay (region-beginning) = (region-end)))) + =0C (defcustom mouse-buffer-menu-maxlen 20 "Number of buffers in one pane (submenu) of the buffer menu.