From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 May 2017 05:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 26725@debbugs.gnu.org Cc: tkk@misasa.okayama-u.ac.jp X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1493617426654 (code B ref -1); Mon, 01 May 2017 05:44:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 May 2017 05:43:46 +0000 Received: from localhost ([127.0.0.1]:48411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d547d-0000AS-CJ for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d547b-0000A9-1r for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d547U-00071c-By for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d547U-00071X-86 for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d547S-0003zN-P1 for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d547P-00070l-Lh for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:34 -0400 Received: from mxl069v65.mxlogic.net ([208.81.69.65]:51855 helo=s18p02o142.mxlogic.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d547P-0006zm-2O for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:31 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o142.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 7fac6095.0.516819.00-390.1147852.s18p02o142.mxlogic.net (envelope-from ); Sun, 30 Apr 2017 23:43:20 -0600 (MDT) X-MXL-Hash: 5906caf82829eb78-8831da9404eac7781ae2e4e6981c9ad7276fb1ab Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 21f4_101d_0c1853b6_fd63_4103_912e_02e6df966265; Mon, 01 May 2017 14:43:13 +0900 Received: from localhost (unknown [172.24.1.79]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id E2EC64C09C9; Mon, 1 May 2017 14:43:13 +0900 (JST) Date: Mon, 01 May 2017 14:43:08 +0900 (JST) Message-Id: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> From: Tak Kunihiro X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_May__1_14_43_08_2017_295)--" Content-Transfer-Encoding: 7bit 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, RV6012=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6012> : inlines <5828> : streams <1743548> : uri <2419250> X-AnalysisOut: [v=2.2 cv=Cr/PSjwD c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=AzvcPWV-tVgA:10 a=XfO] X-AnalysisOut: [3D5wU82Q9Hj0EyNUA:9 a=CjuIK1q_8ugA:10 a=hjlGXw3i1xpCsdrjrh] X-AnalysisOut: [UA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19] X-Spam: [F=0.5000000000; CM=0.500; MH=0.500(2017043007); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) ----Next_Part(Mon_May__1_14_43_08_2017_295)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Drag and drop a file is already supported by Emacs. This patch extends drag and drop to region (text). In other word, this patch lets you `cut and paste' in a buffer only using mouse. When destination is other windows, drag and drop a region will be `copy and paste'. ----Next_Part(Mon_May__1_14_43_08_2017_295)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mouse.el.patch" --- mouse.252.el 2017-05-01 13:45:39.735936700 +0900 +++ mouse.el 2017-05-01 13:59:11.102725500 +0900 @@ -688,12 +688,19 @@ Highlight the drag area as you move the mouse. This must be bound to a button-down mouse event. In Transient Mark mode, the highlighting remains as long as the mark -remains active. Otherwise, it remains until the next input event." - (interactive "e") - ;; Give temporary modes such as isearch a chance to turn off. - (run-hooks 'mouse-leave-buffer-hook) - (mouse-drag-track start-event)) +remains active. Otherwise, it remains until the next input event. +When the region already exists and `mouse-drag-and-drop-region' +is non-nil, this moves text on a region to point where mouse is +dragged over to." + (interactive "e") + (if (and mouse-drag-and-drop-region + (not (member 'triple (event-modifiers start-event))) + (mouse-on-region-p (event-start start-event))) + (mouse-drag-region-pasting start-event) + ;; Give temporary modes such as isearch a chance to turn off. + (run-hooks 'mouse-leave-buffer-hook) + (mouse-drag-track start-event))) (defun mouse-posn-property (pos property) "Look for a property at click position. @@ -1911,6 +1918,94 @@ t (called-interactively-p 'interactive))))))))) +;; Drag and drop support. +(defcustom mouse-drag-and-drop-region nil + "If non-nil, dragging mouse of the region moves text." + :type 'boolean + :version "26.1" + :group 'mouse) + +(defun mouse-on-region-p (position &optional start end) + "Return if POSITION is in between START and END in the current buffer. +When START and END are nil but there is active region, those of +active region is fed." + (when (region-active-p) + (setq start (or start (region-beginning))) + (setq end (or end (region-end)))) + (let ((point (posn-point position))) + (and + (numberp start) + (numberp end) + (numberp point) + (<= start point) + (<= point end)))) + +(defun mouse-drag-region-pasting (event) + "Move text on a region to point where mouse is dragged over to. +The transportation of text is also referred as `drag and drop'. +When text is dragged over to different buffer, the text is copied +instead of cut. This works similar to +`mouse-drag-secondary-moving' but expects region on launch and +specifies point later, by mouse. + +To try this function, evaluate the following line. + (global-set-key [down-mouse-3] \\='mouse-drag-region-pasting) +Then have a region and grab-and-drag it by mouse to point to move +to." + (interactive "e") + (require 'tooltip) + (let ((start (region-beginning)) + (end (region-end)) + (point (point)) + (buffer (current-buffer)) + (window (selected-window)) + value-selection) + (track-mouse + ;; when event was click instead of drag, skip loop + (while (progn + (setq event (read-event)) + (mouse-movement-p event)) + (unless value-selection ; initialization + (delete-overlay mouse-secondary-overlay) + (setq value-selection (buffer-substring start end)) + (move-overlay mouse-secondary-overlay start end)) ; (deactivate-mark) + (ignore-errors (deactivate-mark) ; care existing region in other window + (mouse-set-point event) + (tooltip-show value-selection))) + (tooltip-hide)) + ;; Do not modify buffer when "event was click", + ;; "drag negligible", or "drag to read-only". + (if (or (mouse-on-region-p (event-end event) start end) + buffer-read-only) + (cond + ;; drag negligible or drag to read-only, restore region + (value-selection + (select-window window) ; case miss drag to other window + (goto-char point) + (setq deactivate-mark nil) + (activate-mark)) + ;; event was click + (t + (deactivate-mark) + (mouse-set-point event))) + ;; insert text + (push-mark) + (insert value-selection) ; revise buffer + (when (not (equal (mark) (point))) ; on success + (setq deactivate-mark nil) + (activate-mark)) ; activate region on new place + ;; take out initial region + (if (equal (current-buffer) buffer) ; same buffer + (let (deactivate-mark) + (kill-region (overlay-start mouse-secondary-overlay) + (overlay-end mouse-secondary-overlay))) + (let ((window1 (selected-window))) ; beyond buffer + (select-window window) + (goto-char point) ; restore point to where it was + (select-window window1)))) + (delete-overlay mouse-secondary-overlay))) + + ;;; Bindings for mouse commands. (global-set-key [down-mouse-1] 'mouse-drag-region) ----Next_Part(Mon_May__1_14_43_08_2017_295)---- From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 May 2017 22:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 26725@debbugs.gnu.org Cc: tkk@misasa.okayama-u.ac.jp X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, 26725@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.149410841420789 (code B ref -1); Sat, 06 May 2017 22:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 May 2017 22:06:54 +0000 Received: from localhost ([127.0.0.1]:58724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d77qo-0005PE-Ey for submit@debbugs.gnu.org; Sat, 06 May 2017 18:06:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40149) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d77qn-0005P1-0G for submit@debbugs.gnu.org; Sat, 06 May 2017 18:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d77qh-0005Cx-AF for submit@debbugs.gnu.org; Sat, 06 May 2017 18:06:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d77qh-0005Ct-7v for submit@debbugs.gnu.org; Sat, 06 May 2017 18:06:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d77qg-0000Vh-AS for bug-gnu-emacs@gnu.org; Sat, 06 May 2017 18:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d77qc-0005BS-D4 for bug-gnu-emacs@gnu.org; Sat, 06 May 2017 18:06:46 -0400 Received: from mxl069v65.mxlogic.net ([208.81.69.65]:57342 helo=s18p02o142.mxlogic.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d77qb-0005BD-Ox for bug-gnu-emacs@gnu.org; Sat, 06 May 2017 18:06:42 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o142.mxlogic.net(mxl_mta-8.5.0-1675) with ESMTP id 1f84e095.7f47e17fb700.573794.00-548.1268293.s18p02o142.mxlogic.net (envelope-from ); Sat, 06 May 2017 16:06:41 -0600 (MDT) X-MXL-Hash: 590e48f106400fc9-4e4cfd6d62b63a174a7700156b38906bff4d30d9 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o142.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 3e84e095.0.573793.00-385.1268290.s18p02o142.mxlogic.net (envelope-from ); Sat, 06 May 2017 16:06:30 -0600 (MDT) X-MXL-Hash: 590e48e661b08895-2b895fbdfb70932cbcbd858356347960c42bd147 Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 314c_0636_dbb090e1_5456_4f20_8751_aaccf9364930; Sun, 07 May 2017 07:06:25 +0900 Received: from localhost (p256188-ipngn200208tottori.tottori.ocn.ne.jp [180.36.253.188]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id B91074C0A38; Sun, 7 May 2017 07:06:25 +0900 (JST) Date: Sun, 07 May 2017 07:06:21 +0900 (JST) Message-Id: <20170507.070621.420975362.tkk@misasa.okayama-u.ac.jp> From: Tak Kunihiro In-Reply-To: References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 5 Rules triggered GEN_SPAM_FEATRE=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_PASS=0, RV6018=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6018> : inlines <5854> : streams <1744364> : uri <2422412> X-AnalysisOut: [v=2.2 cv=Cr/PSjwD c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=tJ8] X-AnalysisOut: [p9aeEuA8A:10 a=sUa_WidWLsJ4zxUbuTcA:9 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5000000000; CM=0.500; MH=0.500(2017050605); S=0.440(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) Is this patch NG? I think `drag-and-drop text' using mouse gives modern flavor to Emacs, and idea should be good. Would you tell me how this patch is NG, if so? From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 May 2017 17:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Tak Kunihiro Cc: 26725@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.14941769169526 (code B ref 26725); Sun, 07 May 2017 17:09:02 +0000 Received: (at 26725) by debbugs.gnu.org; 7 May 2017 17:08:36 +0000 Received: from localhost ([127.0.0.1]:60580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7Pfg-0002Ta-Dc for submit@debbugs.gnu.org; Sun, 07 May 2017 13:08:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7Pff-0002TO-2t for 26725@debbugs.gnu.org; Sun, 07 May 2017 13:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7PfV-0001yn-46 for 26725@debbugs.gnu.org; Sun, 07 May 2017 13:08:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39308) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7PfV-0001ye-0b; Sun, 07 May 2017 13:08:25 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4301 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d7PfU-0003PW-DN; Sun, 07 May 2017 13:08:24 -0400 Date: Sun, 07 May 2017 20:08:03 +0300 Message-Id: <83a86oegss.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <20170507.070621.420975362.tkk@misasa.okayama-u.ac.jp> (message from Tak Kunihiro on Sun, 07 May 2017 07:06:21 +0900 (JST)) References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> <20170507.070621.420975362.tkk@misasa.okayama-u.ac.jp> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Sun, 07 May 2017 07:06:21 +0900 (JST) > From: Tak Kunihiro > Cc: tkk@misasa.okayama-u.ac.jp > > Is this patch NG? > > I think `drag-and-drop text' using mouse gives modern flavor to Emacs, > and idea should be good. > > Would you tell me how this patch is NG, if so? Sorry, I didn't yet have time to look into your patch (and hoped someone else might, meanwhile...) From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 May 2017 22:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: eliz@gnu.org Cc: tkk@misasa.okayama-u.ac.jp, 26725@debbugs.gnu.org Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.149419718028896 (code B ref 26725); Sun, 07 May 2017 22:47:02 +0000 Received: (at 26725) by debbugs.gnu.org; 7 May 2017 22:46:20 +0000 Received: from localhost ([127.0.0.1]:60895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7UwW-0007W0-FB for submit@debbugs.gnu.org; Sun, 07 May 2017 18:46:20 -0400 Received: from mxl065v67.mxlogic.net ([208.81.65.67]:60418 helo=s14p02o144.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7UwT-0007Vq-IC for 26725@debbugs.gnu.org; Sun, 07 May 2017 18:46:19 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s14p02o144.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 2b3af095.0.974874.00-377.2045032.s14p02o144.mxlogic.net (envelope-from ); Sun, 07 May 2017 16:46:11 -0600 (MDT) X-MXL-Hash: 590fa3b3126bea79-f2784afef01321c53764136587e0a9c81ec38891 Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 62a1_8a50_d4149b87_3a08_4ecf_a22e_ce4b4f4fe944; Mon, 08 May 2017 07:46:06 +0900 Received: from localhost (unknown [172.24.1.79]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id 13A384C0AA2; Mon, 8 May 2017 07:46:06 +0900 (JST) Date: Mon, 08 May 2017 07:46:02 +0900 (JST) Message-Id: <20170508.074602.80650334.tkk@misasa.okayama-u.ac.jp> From: Tak Kunihiro In-Reply-To: <83a86oegss.fsf@gnu.org> References: <20170507.070621.420975362.tkk@misasa.okayama-u.ac.jp> <83a86oegss.fsf@gnu.org> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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, RV6018=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6018> : inlines <5854> : streams <1744511> : uri <2422956> X-AnalysisOut: [v=2.2 cv=MPYQoIRl c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=tJ8] X-AnalysisOut: [p9aeEuA8A:10 a=1deIkMMPv3mIgz2xk_cA:9 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5000000000; CM=0.500; MH=0.500(2017050706); S=0.404(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >> Is this patch NG? >> >> I think `drag-and-drop text' using mouse gives modern flavor to Emacs, >> and idea should be good. >> >> Would you tell me how this patch is NG, if so? > > Sorry, I didn't yet have time to look into your patch (and hoped > someone else might, meanwhile...) I see. No problem. Please take you time, and eventually give me response. From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 May 2017 17:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Tak Kunihiro Cc: 26725@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.149469715122923 (code B ref 26725); Sat, 13 May 2017 17:40:02 +0000 Received: (at 26725) by debbugs.gnu.org; 13 May 2017 17:39:11 +0000 Received: from localhost ([127.0.0.1]:43217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9b0Y-0005xe-Sn for submit@debbugs.gnu.org; Sat, 13 May 2017 13:39:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9b0W-0005xS-OT for 26725@debbugs.gnu.org; Sat, 13 May 2017 13:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9b0O-0008Hr-7P for 26725@debbugs.gnu.org; Sat, 13 May 2017 13:39:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9b0O-0008Hg-4L; Sat, 13 May 2017 13:39:00 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1224 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d9b0M-0006yY-LD; Sat, 13 May 2017 13:38:59 -0400 Date: Sat, 13 May 2017 20:38:37 +0300 Message-Id: <83d1bc8xnm.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> (message from Tak Kunihiro on Mon, 01 May 2017 14:43:08 +0900 (JST)) References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Mon, 01 May 2017 14:43:08 +0900 (JST) > From: Tak Kunihiro > Cc: tkk@misasa.okayama-u.ac.jp > > Drag and drop a file is already supported by Emacs. This patch > extends drag and drop to region (text). Thanks. Some comments below. > +When the region already exists and `mouse-drag-and-drop-region' > +is non-nil, this moves text on a region to point where mouse is ^^^^^^^^^^^^^^^^^^^^^^^^^^^ "this moves the entire region of text" > +(defcustom mouse-drag-and-drop-region nil > + "If non-nil, dragging mouse of the region moves text." "If non-nil, dragging the mouse drags the region, when that exists. > +(defun mouse-on-region-p (position &optional start end) > + "Return if POSITION is in between START and END in the current buffer. > +When START and END are nil but there is active region, those of > +active region is fed." > + (when (region-active-p) > + (setq start (or start (region-beginning))) > + (setq end (or end (region-end)))) > + (let ((point (posn-point position))) > + (and > + (numberp start) > + (numberp end) > + (numberp point) > + (<= start point) > + (<= point end)))) This algorithm will fail with bidirectional text, where buffer positions don't increase monotonically with screen coordinates. How about testing the face of the character under mouse instead? > +(defun mouse-drag-region-pasting (event) The function's name is confusing. Why not name it like the defcustom? > + "Move text on a region to point where mouse is dragged over to. ^^ "in" > +The transportation of text is also referred as `drag and drop'. > +When text is dragged over to different buffer, the text is copied ^ "a" is missing here. > +instead of cut. "instead of being cur". > This works similar to > +`mouse-drag-secondary-moving' but expects region on launch and > +specifies point later, by mouse. I'd lose this sentence, it doesn't add anything to the doc string. > +To try this function, evaluate the following line. > + (global-set-key [down-mouse-3] \\='mouse-drag-region-pasting) > +Then have a region and grab-and-drag it by mouse to point to move > +to." I think this is inappropriate for a doc string. Please add a NEWS entry and some minimal documentation in the user manual. From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 May 2017 04:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: eliz@gnu.org Cc: tkk@misasa.okayama-u.ac.jp, 26725@debbugs.gnu.org Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.149482094929942 (code B ref 26725); Mon, 15 May 2017 04:03:01 +0000 Received: (at 26725) by debbugs.gnu.org; 15 May 2017 04:02:29 +0000 Received: from localhost ([127.0.0.1]:45371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dA7DI-0007ms-JY for submit@debbugs.gnu.org; Mon, 15 May 2017 00:02:28 -0400 Received: from mxl065v65.mxlogic.net ([208.81.65.65]:55592 helo=s14p02o142.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dA7Ci-0007le-Vs for 26725@debbugs.gnu.org; Mon, 15 May 2017 00:02:26 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s14p02o142.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 42829195.0.1108713.00-358.2346032.s14p02o142.mxlogic.net (envelope-from ); Sun, 14 May 2017 22:01:42 -0600 (MDT) X-MXL-Hash: 591928267ff83757-0fc4dd9b73a73ad66cf24d6a48db0d816d63b6d0 Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 67ad_2241_08816687_7686_4011_9830_58bd145c0b4f; Mon, 15 May 2017 13:01:35 +0900 Received: from localhost (unknown [172.24.1.79]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id 2A5F64C0BFD; Mon, 15 May 2017 13:01:36 +0900 (JST) Date: Mon, 15 May 2017 13:01:31 +0900 (JST) Message-Id: <20170515.130131.472087335.tkk@misasa.okayama-u.ac.jp> From: Tak Kunihiro In-Reply-To: <83d1bc8xnm.fsf@gnu.org> References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> <83d1bc8xnm.fsf@gnu.org> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_May_15_13_01_31_2017_263)--" Content-Transfer-Encoding: 7bit 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, RV6024=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6024> : inlines <5865> : streams <1745547> : uri <2426850> X-AnalysisOut: [v=2.2 cv=U+7iNaju c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=tJ8p9aeEuA8A:10 a=j_W] X-AnalysisOut: [n4X1uDpjmrvVz3ZsA:9 a=CjuIK1q_8ugA:10 a=hjlGXw3i1xpCsdrjrh] X-AnalysisOut: [UA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017051407); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) ----Next_Part(Mon_May_15_13_01_31_2017_263)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Thank you for the comments. I revised English as suggested. >> +(defun mouse-on-region-p (position &optional start end) >> + "Return if POSITION is in between START and END in the current buffer. >> +When START and END are nil but there is active region, those of >> +active region is fed." >> + (when (region-active-p) >> + (setq start (or start (region-beginning))) >> + (setq end (or end (region-end)))) >> + (let ((point (posn-point position))) >> + (and >> + (numberp start) >> + (numberp end) >> + (numberp point) >> + (<= start point) >> + (<= point end)))) > > This algorithm will fail with bidirectional text, where buffer > positions don't increase monotonically with screen coordinates. How > about testing the face of the character under mouse instead? I revised the code using following statements. Accordingly, `mouse-on-region-p' is not necessary anymore. (equal (mouse-posn-property (event-start start-event) 'face) 'region) (equal (mouse-posn-property (event-start start-event) 'face) 'secondary-selecton) >> +(defun mouse-drag-region-pasting (event) > > The function's name is confusing. Why not name it like the defcustom? I changed the name from `mouse-drag-region-pasting' to `mouse-drag-and-drop-region'. > Please add a NEWS entry and some minimal documentation in the user > manual. I add ChangeLog, NEWS, and Info as shown below. I think that all concerns were resolved for now. # ChangeLog 2017-05-16 Tak Kunihiro Support drag and drop region by the mouse (Bug#26725) * doc/emacs/frames.texi (Drag and Drop): Document support of drag and drop region by the mouse. * lisp/mouse.el (mouse-drag-region): Call mouse-drag-and-drop-region when start-event is against region. (mouse-drag-and-drop-region): Move the region by dragging the mouse. # NEWS ** Support drag and drop text by the mouse. You can start drag-and-drop text by customizing 'mouse-drag-and-drop-region'. # Info diff --git a/site-lisp/frames.252.texi b/site-lisp/frames.texi index 1611bd1..da140a6 100755 --- a/site-lisp/frames.252.texi +++ b/site-lisp/frames.texi @@ -1046,12 +1046,17 @@ Window Dividers, elisp, The Emacs Lisp Reference Manual}. @cindex drag and drop In most graphical desktop environments, Emacs has basic support for -@dfn{drag and drop} operations. For instance, dropping text onto an -Emacs frame inserts the text where it is dropped. Dropping a file -onto an Emacs frame visits that file. As a special case, dropping the -file on a Dired buffer moves or copies the file (according to the -conventions of the application it came from) into the directory -displayed in that buffer. +@dfn{drag and drop} operations. For instance, dragging region can move +the entire region of text to point where mouse is dragged over to. +Dropping text onto an Emacs frame inserts the text where it is dropped. +Dropping a file onto an Emacs frame visits that file. As a special +case, dropping the file on a Dired buffer moves or copies the file +(according to the conventions of the application it came from) into the +directory displayed in that buffer. + +@vindex mouse-drag-and-drop-region + If you prefer to move the entire region of text by mouse, customize +the variable @code{mouse-drag-and-drop-region}. @vindex dnd-open-file-other-window Dropping a file normally visits it in the window you drop it on. If ----Next_Part(Mon_May_15_13_01_31_2017_263)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mouse.el.patch" diff --git a/mouse.252.el b/mouse.el index 3336e2b..b8cc92c 100755 --- a/mouse.252.el +++ b/mouse.el @@ -688,12 +688,19 @@ Upon exit, point is at the far edge of the newly visible text." Highlight the drag area as you move the mouse. This must be bound to a button-down mouse event. In Transient Mark mode, the highlighting remains as long as the mark -remains active. Otherwise, it remains until the next input event." - (interactive "e") - ;; Give temporary modes such as isearch a chance to turn off. - (run-hooks 'mouse-leave-buffer-hook) - (mouse-drag-track start-event)) +remains active. Otherwise, it remains until the next input event. +When the region already exists and `mouse-drag-and-drop-region' +is non-nil, this moves the entire region of text to point where +mouse is dragged over to." + (interactive "e") + (if (and mouse-drag-and-drop-region + (not (member 'triple (event-modifiers start-event))) + (equal (mouse-posn-property (event-start start-event) 'face) 'region)) + (mouse-drag-and-drop-region start-event) + ;; Give temporary modes such as isearch a chance to turn off. + (run-hooks 'mouse-leave-buffer-hook) + (mouse-drag-track start-event))) (defun mouse-posn-property (pos property) "Look for a property at click position. @@ -1911,6 +1918,76 @@ choose a font." t (called-interactively-p 'interactive))))))))) +;; Drag and drop support. +(defcustom mouse-drag-and-drop-region nil + "If non-nil, dragging the mouse drags the region, when that exists." + :type 'boolean + :version "26.1" + :group 'mouse) + +(defun mouse-drag-and-drop-region (event) + "Move text in a region to point where mouse is dragged over to. +The transportation of text is also referred as `drag and drop'. +When text is dragged over to a different buffer, the text is +copied instead of being cut." + (interactive "e") + (require 'tooltip) + (let ((start (region-beginning)) + (end (region-end)) + (point (point)) + (buffer (current-buffer)) + (window (selected-window)) + value-selection + face-under-mouse) + (track-mouse + ;; When event was click instead of drag, skip loop + (while (progn + (setq event (read-event)) + (mouse-movement-p event)) + (unless value-selection ; initialization + (delete-overlay mouse-secondary-overlay) + (setq value-selection (buffer-substring start end)) + (move-overlay mouse-secondary-overlay start end)) ; (deactivate-mark) + (ignore-errors (deactivate-mark) ; care existing region in other window + (mouse-set-point event) + (tooltip-show value-selection))) + (tooltip-hide)) + ;; Do not modify buffer when "event was click", + ;; "drag negligible", or "drag to read-only". + (setq face-under-mouse (mouse-posn-property (event-end event) 'face)) + (if (or (equal face-under-mouse 'region) + (equal face-under-mouse 'secondary-selecton) + buffer-read-only) + ;; Do not modify buffer under mouse + (cond + ;; drag negligible or drag to read-only, restore region + (value-selection + (select-window window) ; case miss drag to other window + (goto-char point) + (setq deactivate-mark nil) + (activate-mark)) + ;; event was click + (t + (deactivate-mark) + (mouse-set-point event))) + ;; Modify buffer under mouse by inserting text + (push-mark) + (insert value-selection) + (when (not (equal (mark) (point))) ; on success + (setq deactivate-mark nil) + (activate-mark)) ; activate region on new place + ;; Take care initial region + (if (equal (current-buffer) buffer) ; same buffer + (let (deactivate-mark) ; remove text + (kill-region (overlay-start mouse-secondary-overlay) + (overlay-end mouse-secondary-overlay))) + (let ((window1 (selected-window))) ; beyond buffer + (select-window window) + (goto-char point) ; restore point to where it was + (select-window window1)))) + (delete-overlay mouse-secondary-overlay))) + + ;;; Bindings for mouse commands. (global-set-key [down-mouse-1] 'mouse-drag-region) ----Next_Part(Mon_May_15_13_01_31_2017_263)---- From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 May 2017 09:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: eliz@gnu.org Cc: Kunihiro Tak , 26725@debbugs.gnu.org Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.149484209028850 (code B ref 26725); Mon, 15 May 2017 09:55:01 +0000 Received: (at 26725) by debbugs.gnu.org; 15 May 2017 09:54:50 +0000 Received: from localhost ([127.0.0.1]:45513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dACiI-0007VF-2K for submit@debbugs.gnu.org; Mon, 15 May 2017 05:54:50 -0400 Received: from mxl069v64.mxlogic.net ([208.81.69.64]:49926 helo=s18p02o141.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dACiF-0007V6-JE for 26725@debbugs.gnu.org; Mon, 15 May 2017 05:54:48 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o141.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 2ea79195.0.693085.00-373.1516281.s18p02o141.mxlogic.net (envelope-from ); Mon, 15 May 2017 03:54:45 -0600 (MDT) X-MXL-Hash: 59197ae52d3a6bff-b00c7c0687543bb9fc7162e10f076be605e79c00 Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 67d5_f24c_92a4e2ae_e4a5_4cf0_86d4_46a8f5f89a91; Mon, 15 May 2017 18:54:35 +0900 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 65B744C0A51; Mon, 15 May 2017 18:54:35 +0900 (JST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) From: Tak Kunihiro In-Reply-To: <83d1bc8xnm.fsf@gnu.org> Date: Mon, 15 May 2017 18:53:03 +0900 Content-Transfer-Encoding: 7bit Message-Id: <257324EC-E9E9-4418-A139-47003CC94C4B@misasa.okayama-u.ac.jp> References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> <83d1bc8xnm.fsf@gnu.org> X-Mailer: Apple Mail (2.1878.6) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 5 Rules triggered GEN_SPAM_FEATRE=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_PASS=0, RV6024=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6024> : inlines <5867> : streams <1745582> : uri <2426981> X-AnalysisOut: [v=2.2 cv=Iev3YSia c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=tJ8] X-AnalysisOut: [p9aeEuA8A:10 a=l6xQG7Va8ygV14up2hkA:9 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5200000000; CM=0.500; MH=0.520(2017051504); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Let me withdraw the last patch. I found a problem with following statement. (equal (mouse-posn-property (event-end event) 'face) 'secondary-selecton) From unknown Sun Aug 17 04:19:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26725: patch for mouse.el Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 May 2017 02:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: eliz@gnu.org Cc: tkk@misasa.okayama-u.ac.jp, 26725@debbugs.gnu.org Received: via spool by 26725-submit@debbugs.gnu.org id=B26725.149515968228064 (code B ref 26725); Fri, 19 May 2017 02:09:02 +0000 Received: (at 26725) by debbugs.gnu.org; 19 May 2017 02:08:02 +0000 Received: from localhost ([127.0.0.1]:54134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBXKj-0007IX-HN for submit@debbugs.gnu.org; Thu, 18 May 2017 22:08:01 -0400 Received: from mxl065v67.mxlogic.net ([208.81.65.67]:50658 helo=s14p02o144.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBXKh-0007IL-15 for 26725@debbugs.gnu.org; Thu, 18 May 2017 22:08:00 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s14p02o144.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 4735e195.0.1214433.00-384.2563317.s14p02o144.mxlogic.net (envelope-from ); Thu, 18 May 2017 20:07:48 -0600 (MDT) X-MXL-Hash: 591e53747f02e15e-89100b3aa96e8ca285104aa95f4c3beca6a64285 Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 19c7_1672_53f5f347_78fd_41db_a12a_0d59e61cd466; Fri, 19 May 2017 11:07:43 +0900 Received: from localhost (unknown [172.24.1.79]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id E99D24C0BFE; Fri, 19 May 2017 11:07:43 +0900 (JST) Date: Fri, 19 May 2017 11:07:43 +0900 (JST) Message-Id: <20170519.110743.171510165.tkk@misasa.okayama-u.ac.jp> From: Tak Kunihiro In-Reply-To: <20170515.130131.472087335.tkk@misasa.okayama-u.ac.jp> References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> <83d1bc8xnm.fsf@gnu.org> <20170515.130131.472087335.tkk@misasa.okayama-u.ac.jp> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_May_19_11_07_43_2017_897)--" Content-Transfer-Encoding: 7bit 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, RV6028=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6028> : inlines <5879> : streams <1746110> : uri <2429009> X-AnalysisOut: [v=2.2 cv=MPYQoIRl c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=tJ8p9aeEuA8A:10 a=j9g] X-AnalysisOut: [ihSJ1NfYLMCF46uAA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=Cj] X-AnalysisOut: [uIK1q_8ugA:10 a=hjlGXw3i1xpCsdrjrhUA:9] X-Spam: [F=0.5299760192; CM=0.500; MH=0.529(2017051808); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) ----Next_Part(Fri_May_19_11_07_43_2017_897)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Thank you for the comments. * English I revised English as suggested. * Algorithm in detection of clicking region >> +(defun mouse-on-region-p (position &optional start end) >> + "Return if POSITION is in between START and END in the current buffer. >> +When START and END are nil but there is active region, those of >> +active region is fed." >> + (when (region-active-p) >> + (setq start (or start (region-beginning))) >> + (setq end (or end (region-end)))) >> + (let ((point (posn-point position))) >> + (and >> + (numberp start) >> + (numberp end) >> + (numberp point) >> + (<= start point) >> + (<= point end)))) > > This algorithm will fail with bidirectional text, where buffer > positions don't increase monotonically with screen coordinates. How > about testing the face of the character under mouse instead? I revised the code using following statements. Accordingly, `mouse-on-region-p' is deleted. (equal (mouse-posn-property (event-end event) 'face) 'region) (member 'secondary-selection(mapcar (lambda (xxx) (overlay-get xxx 'face)) (overlays-at (posn-point (event-end event))))) * Name of function >> +(defun mouse-drag-region-pasting (event) > > The function's name is confusing. Why not name it like the defcustom? I changed the name from `mouse-drag-region-pasting' to `mouse-drag-and-drop-region'. As a consequence, variable and function have the same name. I suppose it is OK. * NEWS, ChangeLog, and Info > Please add a NEWS entry and some minimal documentation in the user > manual. I add ChangeLog, NEWS, and Info as shown below. * Copy on Drag and Drop with meta key pressed I found that sometimes I want to copy on drop (instead of cut) even when source buffer and destination buffer are the same. I added a logic to let me do so. When modifier key is pressed on drop, the function does not delete the original region. The modifier key is specified by the variable `mouse-drag-and-drop-region' that is used as flag. I did not create a new variable. # ChangeLog 2017-05-20 Tak Kunihiro Support drag and drop region by the mouse (Bug#26725) * doc/emacs/frames.texi (Drag and Drop): Document support of drag and drop region by the mouse. * lisp/mouse.el (mouse-drag-region): Call mouse-drag-and-drop-region when start-event is against region. (mouse-drag-and-drop-region): Move the region by dragging the mouse. # NEWS ** Support drag and drop text by the mouse. You can start drag-and-drop text by customizing 'mouse-drag-and-drop-region'. # Info diff --git a/site-lisp/frames.252.texi b/site-lisp/frames.texi index 1611bd1..da140a6 100755 --- a/site-lisp/frames.252.texi +++ b/site-lisp/frames.texi @@ -1046,12 +1046,17 @@ Window Dividers, elisp, The Emacs Lisp Reference Manual}. @cindex drag and drop In most graphical desktop environments, Emacs has basic support for -@dfn{drag and drop} operations. For instance, dropping text onto an -Emacs frame inserts the text where it is dropped. Dropping a file -onto an Emacs frame visits that file. As a special case, dropping the -file on a Dired buffer moves or copies the file (according to the -conventions of the application it came from) into the directory -displayed in that buffer. +@dfn{drag and drop} operations. For instance, dragging region can move +the entire region of text to point where mouse is dragged over to. +Dropping text onto an Emacs frame inserts the text where it is dropped. +Dropping a file onto an Emacs frame visits that file. As a special +case, dropping the file on a Dired buffer moves or copies the file +(according to the conventions of the application it came from) into the +directory displayed in that buffer. + +@vindex mouse-drag-and-drop-region + If you prefer to move the entire region of text by mouse, customize +the variable @code{mouse-drag-and-drop-region}. @vindex dnd-open-file-other-window Dropping a file normally visits it in the window you drop it on. If ----Next_Part(Fri_May_19_11_07_43_2017_897)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mouse.el.patch" diff --git a/mouse.252.el b/mouse.el index 3336e2b..66142f4 100755 --- a/mouse.252.el +++ b/mouse.el @@ -688,12 +688,19 @@ Upon exit, point is at the far edge of the newly visible text." Highlight the drag area as you move the mouse. This must be bound to a button-down mouse event. In Transient Mark mode, the highlighting remains as long as the mark -remains active. Otherwise, it remains until the next input event." - (interactive "e") - ;; Give temporary modes such as isearch a chance to turn off. - (run-hooks 'mouse-leave-buffer-hook) - (mouse-drag-track start-event)) +remains active. Otherwise, it remains until the next input event. +When the region already exists and the variable +`mouse-drag-and-drop-region' is non-nil, this moves the entire +region of text to point where mouse is dragged over to." + (interactive "e") + (if (and mouse-drag-and-drop-region + (not (member 'triple (event-modifiers start-event))) + (equal (mouse-posn-property (event-start start-event) 'face) 'region)) + (mouse-drag-and-drop-region start-event) + ;; Give temporary modes such as isearch a chance to turn off. + (run-hooks 'mouse-leave-buffer-hook) + (mouse-drag-track start-event))) (defun mouse-posn-property (pos property) "Look for a property at click position. @@ -1911,6 +1918,81 @@ choose a font." t (called-interactively-p 'interactive))))))))) +;; Drag and drop support. +(defcustom mouse-drag-and-drop-region nil + "If non-nil, dragging the mouse drags the region, when that exists. +When the modifier key is specified, dropping with the modifier +key pressed copies the text instead of cuts." + :type 'symbol + :version "26.1" + :group 'mouse) + +(defun mouse-drag-and-drop-region (event) + "Move text in a region to point where mouse is dragged over to. +The transportation of text is also referred as `drag and drop'. +When text is dragged over to a different buffer, the text is +copied instead of being cut." + (interactive "e") + (require 'tooltip) + (let ((start (region-beginning)) + (end (region-end)) + (point (point)) + (buffer (current-buffer)) + (window (selected-window)) + value-selection) + (track-mouse + ;; When event was click instead of drag, skip loop + (while (progn + (setq event (read-event)) + (mouse-movement-p event)) + (unless value-selection ; initialization + (delete-overlay mouse-secondary-overlay) + (setq value-selection (buffer-substring start end)) + (move-overlay mouse-secondary-overlay start end)) ; (deactivate-mark) + (ignore-errors (deactivate-mark) ; care existing region in other window + (mouse-set-point event) + (tooltip-show value-selection))) + (tooltip-hide)) + ;; Do not modify buffer under mouse when "event was click", + ;; "drag negligible", or + ;; "drag to read-only". + (if (or (equal (mouse-posn-property (event-end event) 'face) 'region) ; "event was click" + (member 'secondary-selection ; "drag negligible" + (mapcar (lambda (xxx) (overlay-get xxx 'face)) + (overlays-at (posn-point (event-end event))))) + buffer-read-only) + ;; Do not modify buffer under mouse + (cond + ;; "drag negligible" or "drag to read-only", restore region + (value-selection + (select-window window) ; case miss drag to other window + (goto-char point) + (setq deactivate-mark nil) + (activate-mark)) + ;; "event was click" + (t + (deactivate-mark) + (mouse-set-point event))) + ;; Modify buffer under mouse by inserting text + (push-mark) + (insert value-selection) + (when (not (equal (mark) (point))) ; on success insert + (setq deactivate-mark nil) + (activate-mark)) ; have region on destination + ;; Take care initial region on source + (if (equal (current-buffer) buffer) ; when same buffer + (let (deactivate-mark) ; remove text + (unless (member mouse-drag-and-drop-region (event-modifiers event)) + (kill-region (overlay-start mouse-secondary-overlay) + (overlay-end mouse-secondary-overlay)))) + (let ((window1 (selected-window))) ; when beyond buffer + (select-window window) + (goto-char point) ; restore point on source window + (activate-mark) ; restore region + (select-window window1)))) + (delete-overlay mouse-secondary-overlay))) + + ;;; Bindings for mouse commands. (global-set-key [down-mouse-1] 'mouse-drag-region) ----Next_Part(Fri_May_19_11_07_43_2017_897)---- From unknown Sun Aug 17 04:19:08 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Tak Kunihiro Subject: bug#26725: closed (Re: bug#26725: patch for mouse.el) Message-ID: References: <838tliik60.fsf@gnu.org> <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> X-Gnu-PR-Message: they-closed 26725 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 26725@debbugs.gnu.org Date: Sat, 27 May 2017 12:01:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1495886462-4199-1" This is a multi-part message in MIME format... ------------=_1495886462-4199-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #26725: patch for mouse.el which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 26725@debbugs.gnu.org. --=20 26725: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26725 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1495886462-4199-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 26725-done) by debbugs.gnu.org; 27 May 2017 12:00:53 +0000 Received: from localhost ([127.0.0.1]:39981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEaOq-00015H-V0 for submit@debbugs.gnu.org; Sat, 27 May 2017 08:00:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38217) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEaOo-000155-OR for 26725-done@debbugs.gnu.org; Sat, 27 May 2017 08:00:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEaOf-00036m-5j for 26725-done@debbugs.gnu.org; Sat, 27 May 2017 08:00:45 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEaOf-00036f-2R; Sat, 27 May 2017 08:00:41 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2805 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dEaOd-0004rF-Rp; Sat, 27 May 2017 08:00:40 -0400 Date: Sat, 27 May 2017 15:00:39 +0300 Message-Id: <838tliik60.fsf@gnu.org> From: Eli Zaretskii To: Tak Kunihiro In-reply-to: <20170519.110743.171510165.tkk@misasa.okayama-u.ac.jp> (message from Tak Kunihiro on Fri, 19 May 2017 11:07:43 +0900 (JST)) Subject: Re: bug#26725: patch for mouse.el References: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> <83d1bc8xnm.fsf@gnu.org> <20170515.130131.472087335.tkk@misasa.okayama-u.ac.jp> <20170519.110743.171510165.tkk@misasa.okayama-u.ac.jp> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 26725-done Cc: 26725-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Fri, 19 May 2017 11:07:43 +0900 (JST) > Cc: 26725@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp, > tkk@misasa.okayama-u.ac.jp > From: Tak Kunihiro > > Thank you for the comments. > > * English > > I revised English as suggested. > > > * Algorithm in detection of clicking region > > >> +(defun mouse-on-region-p (position &optional start end) > >> + "Return if POSITION is in between START and END in the current buffer. > >> +When START and END are nil but there is active region, those of > >> +active region is fed." > >> + (when (region-active-p) > >> + (setq start (or start (region-beginning))) > >> + (setq end (or end (region-end)))) > >> + (let ((point (posn-point position))) > >> + (and > >> + (numberp start) > >> + (numberp end) > >> + (numberp point) > >> + (<= start point) > >> + (<= point end)))) > > > > This algorithm will fail with bidirectional text, where buffer > > positions don't increase monotonically with screen coordinates. How > > about testing the face of the character under mouse instead? > > I revised the code using following statements. Accordingly, > `mouse-on-region-p' is deleted. > > (equal (mouse-posn-property (event-end event) 'face) 'region) > (member 'secondary-selection(mapcar (lambda (xxx) (overlay-get xxx 'face)) > (overlays-at (posn-point (event-end event))))) > > > * Name of function > > >> +(defun mouse-drag-region-pasting (event) > > > > The function's name is confusing. Why not name it like the defcustom? > > I changed the name from `mouse-drag-region-pasting' to > `mouse-drag-and-drop-region'. As a consequence, variable and function > have the same name. I suppose it is OK. > > > * NEWS, ChangeLog, and Info > > > Please add a NEWS entry and some minimal documentation in the user > > manual. > > I add ChangeLog, NEWS, and Info as shown below. > > > * Copy on Drag and Drop with meta key pressed > > I found that sometimes I want to copy on drop (instead of cut) even > when source buffer and destination buffer are the same. > > I added a logic to let me do so. When modifier key is pressed on > drop, the function does not delete the original region. > > The modifier key is specified by the variable > `mouse-drag-and-drop-region' that is used as flag. I did not create a > new variable. Thanks, pushed to master. ------------=_1495886462-4199-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 1 May 2017 05:43:46 +0000 Received: from localhost ([127.0.0.1]:48411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d547d-0000AS-CJ for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d547b-0000A9-1r for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d547U-00071c-By for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d547U-00071X-86 for submit@debbugs.gnu.org; Mon, 01 May 2017 01:43:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d547S-0003zN-P1 for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d547P-00070l-Lh for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:34 -0400 Received: from mxl069v65.mxlogic.net ([208.81.69.65]:51855 helo=s18p02o142.mxlogic.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d547P-0006zm-2O for bug-gnu-emacs@gnu.org; Mon, 01 May 2017 01:43:31 -0400 Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o142.mxlogic.net(mxl_mta-8.5.0-1675) over TLS secured channel with ESMTP id 7fac6095.0.516819.00-390.1147852.s18p02o142.mxlogic.net (envelope-from ); Sun, 30 Apr 2017 23:43:20 -0600 (MDT) X-MXL-Hash: 5906caf82829eb78-8831da9404eac7781ae2e4e6981c9ad7276fb1ab Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 21f4_101d_0c1853b6_fd63_4103_912e_02e6df966265; Mon, 01 May 2017 14:43:13 +0900 Received: from localhost (unknown [172.24.1.79]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id E2EC64C09C9; Mon, 1 May 2017 14:43:13 +0900 (JST) Date: Mon, 01 May 2017 14:43:08 +0900 (JST) Message-Id: <20170501.144308.327409523.tkk@misasa.okayama-u.ac.jp> To: bug-gnu-emacs@gnu.org Subject: patch for mouse.el From: Tak Kunihiro X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_May__1_14_43_08_2017_295)--" Content-Transfer-Encoding: 7bit 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, RV6012=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6012> : inlines <5828> : streams <1743548> : uri <2419250> X-AnalysisOut: [v=2.2 cv=Cr/PSjwD c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=AzvcPWV-tVgA:10 a=XfO] X-AnalysisOut: [3D5wU82Q9Hj0EyNUA:9 a=CjuIK1q_8ugA:10 a=hjlGXw3i1xpCsdrjrh] X-AnalysisOut: [UA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19] X-Spam: [F=0.5000000000; CM=0.500; MH=0.500(2017043007); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-Debbugs-Envelope-To: submit Cc: tkk@misasa.okayama-u.ac.jp X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) ----Next_Part(Mon_May__1_14_43_08_2017_295)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Drag and drop a file is already supported by Emacs. This patch extends drag and drop to region (text). In other word, this patch lets you `cut and paste' in a buffer only using mouse. When destination is other windows, drag and drop a region will be `copy and paste'. ----Next_Part(Mon_May__1_14_43_08_2017_295)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mouse.el.patch" --- mouse.252.el 2017-05-01 13:45:39.735936700 +0900 +++ mouse.el 2017-05-01 13:59:11.102725500 +0900 @@ -688,12 +688,19 @@ Highlight the drag area as you move the mouse. This must be bound to a button-down mouse event. In Transient Mark mode, the highlighting remains as long as the mark -remains active. Otherwise, it remains until the next input event." - (interactive "e") - ;; Give temporary modes such as isearch a chance to turn off. - (run-hooks 'mouse-leave-buffer-hook) - (mouse-drag-track start-event)) +remains active. Otherwise, it remains until the next input event. +When the region already exists and `mouse-drag-and-drop-region' +is non-nil, this moves text on a region to point where mouse is +dragged over to." + (interactive "e") + (if (and mouse-drag-and-drop-region + (not (member 'triple (event-modifiers start-event))) + (mouse-on-region-p (event-start start-event))) + (mouse-drag-region-pasting start-event) + ;; Give temporary modes such as isearch a chance to turn off. + (run-hooks 'mouse-leave-buffer-hook) + (mouse-drag-track start-event))) (defun mouse-posn-property (pos property) "Look for a property at click position. @@ -1911,6 +1918,94 @@ t (called-interactively-p 'interactive))))))))) +;; Drag and drop support. +(defcustom mouse-drag-and-drop-region nil + "If non-nil, dragging mouse of the region moves text." + :type 'boolean + :version "26.1" + :group 'mouse) + +(defun mouse-on-region-p (position &optional start end) + "Return if POSITION is in between START and END in the current buffer. +When START and END are nil but there is active region, those of +active region is fed." + (when (region-active-p) + (setq start (or start (region-beginning))) + (setq end (or end (region-end)))) + (let ((point (posn-point position))) + (and + (numberp start) + (numberp end) + (numberp point) + (<= start point) + (<= point end)))) + +(defun mouse-drag-region-pasting (event) + "Move text on a region to point where mouse is dragged over to. +The transportation of text is also referred as `drag and drop'. +When text is dragged over to different buffer, the text is copied +instead of cut. This works similar to +`mouse-drag-secondary-moving' but expects region on launch and +specifies point later, by mouse. + +To try this function, evaluate the following line. + (global-set-key [down-mouse-3] \\='mouse-drag-region-pasting) +Then have a region and grab-and-drag it by mouse to point to move +to." + (interactive "e") + (require 'tooltip) + (let ((start (region-beginning)) + (end (region-end)) + (point (point)) + (buffer (current-buffer)) + (window (selected-window)) + value-selection) + (track-mouse + ;; when event was click instead of drag, skip loop + (while (progn + (setq event (read-event)) + (mouse-movement-p event)) + (unless value-selection ; initialization + (delete-overlay mouse-secondary-overlay) + (setq value-selection (buffer-substring start end)) + (move-overlay mouse-secondary-overlay start end)) ; (deactivate-mark) + (ignore-errors (deactivate-mark) ; care existing region in other window + (mouse-set-point event) + (tooltip-show value-selection))) + (tooltip-hide)) + ;; Do not modify buffer when "event was click", + ;; "drag negligible", or "drag to read-only". + (if (or (mouse-on-region-p (event-end event) start end) + buffer-read-only) + (cond + ;; drag negligible or drag to read-only, restore region + (value-selection + (select-window window) ; case miss drag to other window + (goto-char point) + (setq deactivate-mark nil) + (activate-mark)) + ;; event was click + (t + (deactivate-mark) + (mouse-set-point event))) + ;; insert text + (push-mark) + (insert value-selection) ; revise buffer + (when (not (equal (mark) (point))) ; on success + (setq deactivate-mark nil) + (activate-mark)) ; activate region on new place + ;; take out initial region + (if (equal (current-buffer) buffer) ; same buffer + (let (deactivate-mark) + (kill-region (overlay-start mouse-secondary-overlay) + (overlay-end mouse-secondary-overlay))) + (let ((window1 (selected-window))) ; beyond buffer + (select-window window) + (goto-char point) ; restore point to where it was + (select-window window1)))) + (delete-overlay mouse-secondary-overlay))) + + ;;; Bindings for mouse commands. (global-set-key [down-mouse-1] 'mouse-drag-region) ----Next_Part(Mon_May__1_14_43_08_2017_295)---- ------------=_1495886462-4199-1--