summaryrefslogtreecommitdiff
path: root/lisp/mouse.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2022-05-02 12:03:08 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-02 12:03:08 +0200
commit2fba71cf1fadc9d681e6be250d152cc156bf6a00 (patch)
tree8a5d496f98bfb0c79095c3ae19a919be1b275c0b /lisp/mouse.el
parentf7a6dd4fcc54230630fcba73ca6bda2a413eff24 (diff)
downloademacs-2fba71cf1fadc9d681e6be250d152cc156bf6a00.tar.gz
Fix handling double-click-time nil or t
* lisp/mouse.el (mouse-double-click-time): New function to always return a number for `double-click-time'. * lisp/emulation/viper-mous.el (viper-multiclick-timeout): * lisp/foldout.el (foldout-mouse-swallow-events): * lisp/help.el (help--read-key-sequence): * lisp/org/org-mouse.el (org-mouse-show-context-menu): Use 'mouse-double-click-time' instead of 'double-click-time'. * src/keyboard.c (syms_of_keyboard): Mention 'mouse-double-click-time' in doc string of 'double-click-time'. * test/lisp/mouse-tests.el (mouse-test-mouse-double-click-time): New test.
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r--lisp/mouse.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index c08ecaf3347..0446bc6dd87 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -167,6 +167,17 @@ Expects to be bound to `(double-)mouse-1' in `key-translation-map'."
(define-key key-translation-map [double-mouse-1]
#'mouse--click-1-maybe-follows-link)
+(defun mouse-double-click-time ()
+ "Return a number for `double-click-time'.
+In contrast to using the `double-click-time' variable directly,
+which could be set to nil or t, this function is guaranteed to
+always return a positive integer or zero."
+ (let ((ct double-click-time))
+ (cond ((eq ct t) 10000) ; arbitrary number useful for sit-for
+ ((eq ct nil) 0)
+ ((and (numberp ct) (> ct 0)) ct)
+ (t 0))))
+
;; Provide a mode-specific menu on a mouse button.