Subject: Re: bug#41351: 28.0.50; Cannot customize mouse-drag-and-drop-region-show-tooltip

From: Stefan Kangas <[email-masked]>
Date: Sun, 17 May 2020 06:09:09 -0700

Hi David,

David Ponce <[email-masked]> writes:

> diff --git a/installs/emacs/lisp/mouse.el b/home/dponce/emacs.d/mouse.el
> index 795b4da..47a7f20 100644
> --- a/installs/emacs/lisp/mouse.el
> +++ b/home/dponce/emacs.d/mouse.el
> @@ -2577,7 +2577,10 @@ tooltips.  If this is t, it shows the entire text dragged in a
>   tooltip.  If this is an integer (as with the default value of
>   256), it will show that many characters of the dragged text in
>   a tooltip."
> -  :type 'integer
> +  :type '(choice
> +          (const :tag "Do not show tooltips" nil)
> +          (const :tag "Show the entire text dragged" t)
> +          (integer :tag "Show that many characters of the dragged text" 256))

Thanks for the bug report.

I think these should be made shorter to better fit in the customize
buffer.

I also found a bug where if you set this option to 0, the text is
incorrectly shown in full.

How about the below patch?

Best regards,
Stefan Kangas
From e632fd4cf42ea697906adf8e08c9b9851d2bdfb5 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Sun, 17 May 2020 14:59:10 +0200
Subject: [PATCH] Fix minor issues with mouse-drag-and-drop-region-show-tooltip

* lisp/mouse.el (mouse-drag-and-drop-region-show-tooltip): Fix
defcustom type to allow all valid values.  Suggested by David
Ponce.  (Bug#41351)
(mouse-drag-and-drop-region): Fix bug where setting
`drag-and-drop-region-show-tooltip' to 0 would still show a
tooltip.
---
 lisp/mouse.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 795b4da19e..f045e5bdce 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -2575,9 +2575,12 @@ mouse-drag-and-drop-region-show-tooltip
 If this option is nil, `mouse-drag-and-drop-region' does not show
 tooltips.  If this is t, it shows the entire text dragged in a
 tooltip.  If this is an integer (as with the default value of
-256), it will show that many characters of the dragged text in
-a tooltip."
-  :type 'integer
+256), it will show up to that many characters of the dragged text
+in a tooltip."
+  :type '(choice
+          (const :tag "Do not show tooltips" nil)
+          (const :tag "Show all text" t)
+          (integer :tag "Show characters (max)" 256))
   :version "26.1")
 
 (defcustom mouse-drag-and-drop-region-show-cursor t
@@ -2611,6 +2614,7 @@ mouse-drag-and-drop-region
   (let* ((mouse-button (event-basic-type last-input-event))
          (mouse-drag-and-drop-region-show-tooltip
           (when (and mouse-drag-and-drop-region-show-tooltip
+                     (> mouse-drag-and-drop-region-show-tooltip 0)
                      (display-multi-frame-p)
                      (require 'tooltip))
             mouse-drag-and-drop-region-show-tooltip))
-- 
2.26.2