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: Sun, 10 Sep 2017 12:01:43 +0900 (JST) Message-ID: <20170910.120143.946950380669459918.tkk@misasa.okayama-u.ac.jp> References: <83k21az5kw.fsf@gnu.org> <20170908.080208.755485899479344801.tkk@misasa.okayama-u.ac.jp> <83vakty4ra.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1505012542 12509 195.159.176.226 (10 Sep 2017 03:02:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 10 Sep 2017 03:02:22 +0000 (UTC) Cc: tkk@misasa.okayama-u.ac.jp, 27530@debbugs.gnu.org To: eliz@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 10 05:02:14 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 1dqsVb-0002Yt-S9 for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Sep 2017 05:02:08 +0200 Original-Received: from localhost ([::1]:51555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqsVi-00046l-Sw for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Sep 2017 23:02:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqsVa-00046c-8b for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 23:02:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqsVW-0005Ug-Bs for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 23:02:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqsVW-0005UQ-8j for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 23:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dqsVV-0007KP-RO for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 23:02: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: Sun, 10 Sep 2017 03:02: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.150501251828160 (code B ref 27530); Sun, 10 Sep 2017 03:02:01 +0000 Original-Received: (at 27530) by debbugs.gnu.org; 10 Sep 2017 03:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:58185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqsVR-0007K7-Ib for submit@debbugs.gnu.org; Sat, 09 Sep 2017 23:01:57 -0400 Original-Received: from mxl065v67.mxlogic.net ([208.81.65.67]:45676 helo=s14p02o144.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqsVO-0007Jx-UV for 27530@debbugs.gnu.org; Sat, 09 Sep 2017 23:01:56 -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 c1ba4b95.0.390417.00-385.819441.s14p02o144.mxlogic.net (envelope-from ); Sat, 09 Sep 2017 21:01:50 -0600 (MDT) X-MXL-Hash: 59b4ab1e332efab7-9b0183538a87bf5028ac86e2755947b8cf29528e Original-Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 0acd_1aed_14317661_1b2b_4bac_87cd_b06da42c7d7d; Sun, 10 Sep 2017 12:01:43 +0900 Original-Received: from localhost (p219225-ipngn200207tottori.tottori.ocn.ne.jp [153.182.218.225]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id E503A4C0A67; Sun, 10 Sep 2017 12:01:43 +0900 (JST) In-Reply-To: <83vakty4ra.fsf@gnu.org> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: ********** X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 10.1 X-NAI-Spam-Rules: 6 Rules triggered TS_MSG_REP_80_512=10, RCVD_BAD_SIP=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_FAIL=0, RV6112=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6112> : inlines <6061> : streams <1762347> : uri <2497855> X-AnalysisOut: [v=2.2 cv=ObLoNlbY c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=2JC] X-AnalysisOut: [JgTwv5E4A:10 a=nCG2lGpIgXSSyZEH_kgA:9 a=7Zwj6sZBwVKJAoWSPK] X-AnalysisOut: [xL6X1jA+E=:19 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017090912); 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:136724 Archived-At: Thank you for the response. > In sum, I think these are too general: they talk about OVERLAY in > general, whereas what you really mean is the special overlay used for > secondary selection. So how about these instead: > > secondary-selection-exist-p > secondary-selection-from-region > secondary-selection-to-region OK. How about three functions like below? I plan to send a patch relative to lisp/mouse.el. (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 region. (delete-overlay mouse-secondary-overlay) ; Delete the secondary selection even on a different buffer. (move-overlay mouse-secondary-overlay (region-beginning) (region-end)))) Point-to-point responses are shown below. >> -- Function: overlay-exchange-region overlay >> This function exchanges the region and OVERLAY. >> When the region is active, this sets OVERLAY from the region. >> When the region is not active but OVERLAY exists, this sets the >> region from OVERLAY. > > Does this do anything but call overlay-to-region and > overlay-from-region? Yes. I agree to exclude this. >> -- Function: overlay-exists-p overlay >> This function returns if OVERLAY exists in current buffer. >> When OVERLAY exists, this returns list of start and end of >> OVERLAY. > > This is just > > (memq OVERLAY (overlays-in (point-min) (point-max))) > > Right? Yes, you are correct. >> -- Function: overlay-to-region overlay >> This function sets the region to text in OVERLAY. >> This works when OVERLAY exists and the region does not exist in >> current buffer. The OVERLAY will be deleted. > > I don't understand this one. I guess "text in OVERLAY" is confusing; > did you mean OVERLAY's beginning and end? Yes, sentence was vague. It should have said as below. -- Function: overlay-to-region overlay This function sets beginning and end of the region to those of OVERLAY. This works when OVERLAY exists and the region does not exist in current buffer. The OVERLAY will be deleted afterward.