unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David De La Harpe Golden <david@harpegolden.net>
To: emacs-devel@gnu.org, Chong Yidong <cyd@stupidchicken.com>,
	 Eli Zaretskii <eliz@gnu.org>
Subject: Re: Selection changes
Date: Sun, 25 Jul 2010 17:32:19 +0100	[thread overview]
Message-ID: <4C4C6713.2070608@harpegolden.net> (raw)
In-Reply-To: <4C4B347D.7020608@harpegolden.net>

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

On 24/07/10 19:44, David De La Harpe Golden wrote:

> AFAIK the use of rebinding (mouse-2, menu-bar) rather than rewriting the
> existing functions to which they were bound to honour some additional
> customization booleans (as in some earlier iterations of this...) does
> make it impossible to use pure customization theme functionality to
> encapsulate the changes.
>

Perhaps reverting the rebinding of mouse-2, but then expanding 
mouse-yank-at-click to honour a boolean customization
mouse-yank-selection-only would be best?

This would certainly simplify instructing users on how to switch between 
the old and new behaviours (and I guess we can expect more tickets in 
the tracker in that area): it becomes possible to switch the behaviours 
solely by changing a small set of all-boolean customizations.

Thhis also means other bindings to mouse-yank-at-click (such as in the 
fringes, or done by 3rd party apps or end users) get the behaviour.

(*apart from the menu, though maybe users most likely to want the 
"classic" behaviour are least likely to be heavy menu users)

[-- Attachment #2: mouseyank_selonly.diff --]
[-- Type: text/x-patch, Size: 2763 bytes --]

=== modified file 'lisp/mouse.el'
--- lisp/mouse.el	2010-07-17 20:21:51 +0000
+++ lisp/mouse.el	2010-07-25 16:27:46 +0000
@@ -47,6 +47,16 @@
   :version "24.1"
   :group 'mouse)
 
+(defcustom mouse-yank-selection-only t
+  "If non-nil, mouse yank inserts the current selection only.
+
+If nil, then the text that is inserted is the same as that which
+a keyboard `yank' would insert, which itself varies according to
+`x-select-enable-primary' and `x-select-enable-clipboard'"
+  :type 'boolean
+  :version "24.1"
+  :group 'mouse)
+
 (defcustom mouse-1-click-follows-link 450
   "Non-nil means that clicking Mouse-1 on a link follows the link.
 
@@ -1247,25 +1257,30 @@
 		     (max (point) click-posn)))))
 
 (defun mouse-yank-at-click (click arg)
-  "Insert the last stretch of killed text at the position clicked on.
+  "Insert the last stretch of killed  text at the position clicked on.
 Also move point to one end of the text thus inserted (normally the end),
 and set mark at the beginning.
 Prefix arguments are interpreted as with \\[yank].
+If `mouse-yank-selection-only' is non-nil, delegate click to
+`mouse-yank-primary' (arg ignored in that case).
 If `mouse-yank-at-point' is non-nil, insert at point
 regardless of where you click.
 If `select-active-regions' is non-nil, the mark is deactivated
 before inserting the text."
   (interactive "e\nP")
   ;; Give temporary modes such as isearch a chance to turn off.
-  (run-hooks 'mouse-leave-buffer-hook)
-  (when select-active-regions
-    ;; Without this, confusing things happen upon e.g. inserting into
-    ;; the middle of an active region.
-    (deactivate-mark))
-  (or mouse-yank-at-point (mouse-set-point click))
-  (setq this-command 'yank)
-  (setq mouse-selection-click-count 0)
-  (yank arg))
+  (if mouse-yank-selection-only
+      (mouse-yank-primary click)
+    (progn
+      (run-hooks 'mouse-leave-buffer-hook)
+      (when select-active-regions
+        ;; Without this, confusing things happen upon e.g. inserting into
+        ;; the middle of an active region.
+        (deactivate-mark))
+      (or mouse-yank-at-point (mouse-set-point click))
+      (setq this-command 'yank)
+      (setq mouse-selection-click-count 0)
+      (yank arg))))
 
 (defun mouse-yank-primary (click)
   "Insert the primary selection at the position clicked on.
@@ -2441,7 +2456,7 @@
 (global-set-key [left-fringe mouse-1]	'mouse-set-point)
 (global-set-key [right-fringe mouse-1]	'mouse-set-point)
 
-(global-set-key [mouse-2]	'mouse-yank-primary)
+(global-set-key [mouse-2]	'mouse-yank-at-click)
 ;; Allow yanking also when the corresponding cursor is "in the fringe".
 (global-set-key [right-fringe mouse-2] 'mouse-yank-at-click)
 (global-set-key [left-fringe mouse-2] 'mouse-yank-at-click)


  parent reply	other threads:[~2010-07-25 16:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-14 18:08 Selection changes Chong Yidong
2010-07-14 18:39 ` Jeff Clough
2010-07-14 18:53   ` Chong Yidong
2010-07-14 19:02     ` Jeff Clough
2010-07-14 19:25 ` Yann Hodique
2010-07-14 20:28   ` Chong Yidong
2010-07-14 23:51 ` David De La Harpe Golden
2010-07-16  1:31 ` Richard Stallman
2010-07-16  2:49   ` Miles Bader
2010-07-17  0:44 ` David De La Harpe Golden
2010-07-17  1:02   ` Miles Bader
2010-07-17  2:28     ` David De La Harpe Golden
2010-07-17  2:56       ` Chong Yidong
2010-07-17  3:30         ` Miles Bader
2010-07-17  3:49           ` Chong Yidong
2010-07-22 21:21           ` Drew Adams
2010-07-22 22:05             ` Chong Yidong
2010-07-23 10:32               ` Eli Zaretskii
2010-07-24 18:44                 ` David De La Harpe Golden
2010-07-24 20:28                   ` Eli Zaretskii
2010-07-24 21:48                     ` David De La Harpe Golden
2010-07-25 16:32                   ` David De La Harpe Golden [this message]
2010-07-17  3:50         ` David De La Harpe Golden
2010-07-17  3:55           ` Chong Yidong
2010-07-17  4:13             ` Chong Yidong
2010-07-17 16:55               ` David De La Harpe Golden
2010-07-18 16:24               ` David De La Harpe Golden
2010-07-17 10:50         ` Wojciech Meyer
2010-07-17 11:01           ` Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2010-07-16  1:00 Angelo Graziosi
2010-07-16  9:33 ` David De La Harpe Golden
2010-07-17 23:49   ` Angelo Graziosi
2010-07-18 19:28     ` David De La Harpe Golden
2010-07-18 22:39       ` Angelo Graziosi
2010-07-16 12:14 ` Angelo Graziosi
2011-05-27 16:25 Chong Yidong
2011-05-28  4:13 ` David De La Harpe Golden
2011-05-31  0:59   ` Taylor Venable
2011-05-28 11:16 ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C4C6713.2070608@harpegolden.net \
    --to=david@harpegolden.net \
    --cc=cyd@stupidchicken.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).