Bug in tooltip handling

关于 Emacs 的 Tooltip 功能的讨论,是 bug 还是刻意的改变?或者大家的使 用方法本来就不对?见 nabble

Bug in tooltip handling - Tassilo Horn-2 2006-06-30 16:11

Hi all,

I'm not quite sure if this is a bug or a intended change in tooltip
handling, but here I go.

Supporting own tooltips in Emacs 21 was basically a matter of:

,----
| (defun my-tooltip-mode (&optional arg)
|     ;; [snip]
|     (tooltip-mode 1)
|     (add-hook 'tooltip-hook 'my-tooltip-function)
|     (make-local-variable 'track-mouse)
|     (setq track-mouse on))
|
| (defun my-tooltip-function (event)
|     (interactive "e")
|     ;; process event...
|     (tooltip-show "Huzzah!"))
`----

This convenient approach (used for example by dictionary-el) doesn't
work anymore in Emacs 22. If I set `track-mouse' to a non-nil value,
even the standard tooltips which worked before (e.g. the modeline help
tooltips) don't work anymore.

I use the CVS HEAD of yesterday.

Bye,
Tassilo
--
[Emacs] is written in Lisp, which is the only computer language that is
beautiful.  -- Neal Stephenson, _In the Beginning was the Command Line_

Re: Bug in tooltip handling - Nick Roberts 2006-07-02 12:12

 > I'm not quite sure if this is a bug or a intended change in tooltip
 > handling, but here I go.
 >
 > Supporting own tooltips in Emacs 21 was basically a matter of:
 >
 > ,----
 > | (defun my-tooltip-mode (&optional arg)
 > |     ;; [snip]
 > |     (tooltip-mode 1)
 > |     (add-hook 'tooltip-hook 'my-tooltip-function)
 > |     (make-local-variable 'track-mouse)
 > |     (setq track-mouse on))
                           ^^^  t?

I don't think this is the right way to use track-mouse anyway
.
 > | (defun my-tooltip-function (event)
 > |     (interactive "e")
 > |     ;; process event...
 > |     (tooltip-show "Huzzah!"))
 > `----

This didn't seem to work very well on Emacs 21 when I tried it.  Also there's
no mechanism to remove my-tooltip-function from tooltip-hook.

You can get it to work as before by using:

  (defun my-tooltip-mode (&optional arg)
       ;; [snip]
       (gud-tooltip-mode 1)
        ^^^

 > This convenient approach (used for example by dictionary-el) doesn't
 > work anymore in Emacs 22.

dictionary-el isn't part of Emacs 22.  I have split GUD tooltips (which use
track-mouse from ordinary ones (which don't).  This means that they can
be toggled independently.  At some stage, if other packages want to use
tooltips in the way GUD does, that part could be split out of gud.el.
It would need to be documented so that they could be used in a way that
doesn't interfere with existing use, as your example does.

 >                             If I set `track-mouse' to a non-nil value,
 > even the standard tooltips which worked before (e.g. the modeline help
 > tooltips) don't work anymore.

track-mouse is a variable, not a user uption for tooltips.

--
Nick                                           http://www.inet.net.nz/~nickrob

Re: Bug in tooltip handling - leon-9 2006-07-02 18:47

> You can get it to work as before by using:
>
>   (defun my-tooltip-mode (&optional arg)
>        ;; [snip]
>        (gud-tooltip-mode 1)
>         ^^^

Simply change (tooltip-mode 1) to (gud-tooltip-mode 1) seems work
well. Hope someone can make a proper patch for dictionary-el. It's a
nice feature.

--
Leon