emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f372afef20 2/2: Tweak how use-region-p works with `use-empty-acti


From: Lars Ingebrigtsen
Subject: master f372afef20 2/2: Tweak how use-region-p works with `use-empty-active-region'
Date: Tue, 20 Sep 2022 11:12:39 -0400 (EDT)

branch: master
commit f372afef20eaa0ba139f378a6481b147d93c060d
Author: Drew Adams <drew.adams@oracle.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Tweak how use-region-p works with `use-empty-active-region'
    
    * lisp/simple.el (use-region-p): Don't report non-nil if the user
    has just clicked mouse-1 without extending the region (bug#51874).
---
 lisp/simple.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 1b9bf9fa6d..aed1547b15 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6887,6 +6887,11 @@ The return value is t if Transient Mark mode is enabled 
and the
 mark is active; furthermore, if `use-empty-active-region' is nil,
 the region must not be empty.  Otherwise, the return value is nil.
 
+If `use-empty-active-region' is non-nil, there is one further
+caveat: If the user has used `mouse-1' to set point, but used the
+mouse to move point to a different character yet, this function
+returns nil.
+
 For some commands, it may be appropriate to ignore the value of
 `use-empty-active-region'; in that case, use `region-active-p'.
 
@@ -6894,8 +6899,10 @@ Also see the convenience functions 
`use-region-beginning' and
 `use-region-end', which may be handy when writing `interactive'
 specs."
   (and (region-active-p)
-       (or use-empty-active-region (> (region-end) (region-beginning)))
-       t))
+       (or (> (region-end) (region-beginning))
+           (and use-empty-active-region
+                (not (eq (car-safe last-input-event) 'down-mouse-1))
+                (not (mouse-movement-p last-input-event))))))
 
 (defun region-active-p ()
   "Return t if Transient Mark mode is enabled and the mark is active.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]