From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#27530: patch to cut and copy secondary Date: Wed, 20 Sep 2017 10:55:33 +0300 Message-ID: <83o9q5g5xm.fsf@gnu.org> 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> <63B07AE9-1836-4EC5-8913-2D03249B9847@misasa.okayama-u.ac.jp> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1505894174 31283 195.159.176.226 (20 Sep 2017 07:56:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 20 Sep 2017 07:56:14 +0000 (UTC) Cc: 27530@debbugs.gnu.org To: Tak Kunihiro Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 20 09:56:08 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 1duZrY-0007jO-Sq for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Sep 2017 09:56:05 +0200 Original-Received: from localhost ([::1]:47283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duZrg-0006Qo-6v for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Sep 2017 03:56:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duZrY-0006Qb-L6 for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 03:56:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duZrX-0006lG-Em for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 03:56:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duZrW-0006k2-SD for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 03:56:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1duZrW-0006gk-FI for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2017 03:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Sep 2017 07:56:02 +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.150589415725699 (code B ref 27530); Wed, 20 Sep 2017 07:56:02 +0000 Original-Received: (at 27530) by debbugs.gnu.org; 20 Sep 2017 07:55:57 +0000 Original-Received: from localhost ([127.0.0.1]:49049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duZrQ-0006gQ-5z for submit@debbugs.gnu.org; Wed, 20 Sep 2017 03:55:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duZrO-0006gD-Iu for 27530@debbugs.gnu.org; Wed, 20 Sep 2017 03:55:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duZrG-0005hB-5g for 27530@debbugs.gnu.org; Wed, 20 Sep 2017 03:55:49 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duZrG-0005gu-2f; Wed, 20 Sep 2017 03:55:46 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3036 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1duZrC-0002xr-PM; Wed, 20 Sep 2017 03:55:44 -0400 In-reply-to: <63B07AE9-1836-4EC5-8913-2D03249B9847@misasa.okayama-u.ac.jp> (message from Tak Kunihiro on Mon, 11 Sep 2017 11:03:58 +0900) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:137164 Archived-At: > From: Tak Kunihiro > Date: Mon, 11 Sep 2017 11:03:58 +0900 > Cc: Kunihiro Tak , > 27530@debbugs.gnu.org > > 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’s not good! Thanks. A few minor comments below. > +(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." The doc string should describe where we put point and mark as result of this. > + (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))) Is it perhaps better to always put point at the end and mark at the beginning of the overlay? The heuristic seems to be complicating matters for applications, which will have to perform the same calculations to know in advance where point will be. > +(defun secondary-selection-from-region () > + "Set beginning and end of the secondary selection to those of the region." This doc string should tell what happens if there's no active region. Please also add a NEWS entry.