annotate lisp/tooltip.el @ 40217:a1a8276c8da5

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Tue, 23 Oct 2001 15:50:29 +0000
parents 1dab42ecd751
children 4139a35c785c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; tooltip.el --- Show tooltip windows
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
3 ;; Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Gerd Moellmann <gerd@acm.org>
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Keywords: help c mouse tools
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; Put into your `.emacs'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; (require 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; (tooltip-mode 1)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;; Code:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 (eval-when-compile
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 (require 'cl)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 (require 'comint)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 (require 'gud))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 (provide 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;;; Customizable settings
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (defgroup tooltip nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 "Customization group for the `tooltip' package."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 :group 'help
37755
cf803b8f08ad (tooltip) <defgroup>: Put it in `gud' group instead
Gerd Moellmann <gerd@gnu.org>
parents: 35401
diff changeset
49 :group 'gud
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 :group 'mouse
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 :group 'tools
25332
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
52 :version "21.1"
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 :tag "Tool Tips")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
25332
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
55 (defvar tooltip-mode)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 (defcustom tooltip-delay 1.0
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 "Seconds to wait before displaying a tooltip the first time."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 :tag "Delay"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 :type 'number
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (defcustom tooltip-short-delay 0.1
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 "Seconds to wait between subsequent tooltips on different items."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 :tag "Short delay"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 :type 'number
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 (defcustom tooltip-recent-seconds 1
25332
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
72 "Display tooltips if changing tip items within this many seconds.
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
73 Do so after `tooltip-short-delay'."
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 :tag "Recent seconds"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 :type 'number
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
35401
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
79 (defcustom tooltip-hide-delay 5
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
80 "Hide tooltips automatically after this many seconds."
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
81 :tag "Hide delay"
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
82 :type 'number
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
83 :group 'tooltip)
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
84
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
85
33587
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
86 (defcustom tooltip-x-offset nil
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
87 "Specify an X offset, in pixels, for the display of tooltips.
33587
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
88 The offset is relative to the position of the mouse. It must
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
89 be chosen so that the tooltip window doesn't contain the mouse
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
90 when it pops up. If the value is nil, the default offset is 5
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
91 pixels.
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
92
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
93 If `tooltip-frame-parameters' includes the `left' parameter,
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
94 the value of `tooltip-x-offset' is ignored."
33587
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
95 :tag "X offset"
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
96 :type '(choice (const :tag "Default" nil)
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
97 (integer :tag "Offset" :value 1))
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
98 :group 'tooltip)
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
99
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
100
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
101 (defcustom tooltip-y-offset nil
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
102 "Specify a Y offset, in pixels, for the display of tooltips.
33587
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
103 The offset is relative to the position of the mouse. It must
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
104 be chosen so that the tooltip window doesn't contain the mouse
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
105 when it pops up. If the value is nil, the default offset is -10
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
106 pixels.
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
107
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
108 If `tooltip-frame-parameters' includes the `top' parameter,
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
109 the value of `tooltip-y-offset' is ignored."
33587
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
110 :tag "Y offset"
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
111 :type '(choice (const :tag "Default" nil)
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
112 (integer :tag "Offset" :value 1))
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
113 :group 'tooltip)
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
114
7d4c3fcd3421 (tooltip-x-offset, tooltip-y-offset): New user-options.
Gerd Moellmann <gerd@gnu.org>
parents: 33356
diff changeset
115
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (defcustom tooltip-frame-parameters
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 '((name . "tooltip")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (internal-border-width . 5)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (border-width . 1))
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
120 "Frame parameters used for tooltips.
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
121
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
122 If `left' or `top' parameters are included, they specify the absolute
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
123 position to pop up the tooltip."
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 :type 'sexp
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 :tag "Frame Parameters"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
129 (defface tooltip
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
130 '((((class color))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
131 (:background "lightyellow" :foreground "black"))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
132 (t ()))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
133 "Face for tooltips."
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
134 :group 'tooltip)
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
135
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
136
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (defcustom tooltip-gud-tips-p nil
27582
42b52d8b6703 (tooltip-gud-tips-p, tooltip-gud-toggle-dereference):
Dave Love <fx@gnu.org>
parents: 25332
diff changeset
138 "*Non-nil means show tooltips in GUD sessions."
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :type 'boolean
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 :tag "GUD"
33140
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
141 :set #'(lambda (symbol on)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
142 (setq tooltip-gud-tips-p on)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
143 (if on (tooltip-gud-tips-setup)))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (defcustom tooltip-gud-modes '(gud-mode c-mode c++-mode)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 "List of modes for which to enable GUD tips."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 :type 'sexp
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 :tag "GUD modes"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
30481
b603c68fff56 use float-time
Sam Steingold <sds@gnu.org>
parents: 27582
diff changeset
153
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (defcustom tooltip-gud-display
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 '((eq (tooltip-event-buffer tooltip-gud-event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (marker-buffer overlay-arrow-position)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 "List of forms determining where GUD tooltips are displayed.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 Forms in the list are combined with AND. The default is to display
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 only tooltips in the buffer containing the overlay arrow."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 :type 'sexp
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 :tag "GUD buffers predicate"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165
32431
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
166 (defcustom tooltip-use-echo-area nil
33923
44a439ef63c0 (tooltip-use-echo-area): Doc fix.
Dave Love <fx@gnu.org>
parents: 33587
diff changeset
167 "Use the echo area instead of tooltip frames.
44a439ef63c0 (tooltip-use-echo-area): Doc fix.
Dave Love <fx@gnu.org>
parents: 33587
diff changeset
168 This is only relevant GUD display, since otherwise it is equivalent to
44a439ef63c0 (tooltip-use-echo-area): Doc fix.
Dave Love <fx@gnu.org>
parents: 33587
diff changeset
169 turning off Tooltip mode."
32431
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
170 :type 'boolean
33925
9d6fdd64a809 *** empty log message ***
Dave Love <fx@gnu.org>
parents: 33923
diff changeset
171 :tag "Use echo area"
32431
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
172 :group 'tooltip)
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
173
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ;;; Variables that are not customizable.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 (defvar tooltip-hook nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 "Functions to call to display tooltips.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 Each function is called with one argument EVENT which is a copy of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 the last mouse movement event that occurred.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defvar tooltip-timeout-id nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 "The id of the timeout started when Emacs becomes idle.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 (defvar tooltip-last-mouse-motion-event nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 "A copy of the last mouse motion event seen.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (defvar tooltip-hide-time nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 "Time when the last tooltip was hidden.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (defvar tooltip-gud-debugger nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 "The debugger for which we show tooltips.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 ;;; Event accessors
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (defun tooltip-event-buffer (event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 "Return the buffer over which event EVENT occurred.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 This might return nil if the event did not occur over a buffer."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (let ((window (posn-window (event-end event))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (and window (window-buffer window))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 ;;; Switching tooltips on/off
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 ;; We don't set track-mouse globally because this is a big redisplay
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 ;; problem in buffers having a pre-command-hook or such installed,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 ;; which does a set-buffer, like the summary buffer of Gnus. Calling
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 ;; set-buffer prevents redisplay optimizations, so every mouse motion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 ;; would be accompanied by a full redisplay.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 ;;;###autoload
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (defun tooltip-mode (&optional arg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 "Mode for tooltip display.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 With ARG, turn tooltip mode on if and only if ARG is positive."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (interactive "P")
34689
e045e0e60223 (tooltip-mode): Signal an error if x-show-tip
Gerd Moellmann <gerd@gnu.org>
parents: 34540
diff changeset
223 (unless (fboundp 'x-show-tip)
e045e0e60223 (tooltip-mode): Signal an error if x-show-tip
Gerd Moellmann <gerd@gnu.org>
parents: 34540
diff changeset
224 (error "Sorry, tooltips are not yet available on this system"))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (let* ((on (if arg
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (> (prefix-numeric-value arg) 0)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (not tooltip-mode)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (hook-fn (if on 'add-hook 'remove-hook)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (setq tooltip-mode on)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (funcall hook-fn 'change-major-mode-hook 'tooltip-change-major-mode)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (tooltip-activate-mouse-motions-if-enabled)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (funcall hook-fn 'pre-command-hook 'tooltip-hide)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (funcall hook-fn 'tooltip-hook 'tooltip-gud-tips)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (funcall hook-fn 'tooltip-hook 'tooltip-help-tips)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (setq show-help-function (if on 'tooltip-show-help-function nil))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 ;; `ignore' is the default binding for mouse movements.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (define-key global-map [mouse-movement]
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (if on 'tooltip-mouse-motion 'ignore))
33140
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
239 (tooltip-gud-tips-setup)))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240
33140
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
241 (defun tooltip-gud-tips-setup ()
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
242 "Setup debugger mode-hooks for tooltips."
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
243 (when (and tooltip-mode tooltip-gud-tips-p)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
244 (global-set-key [S-mouse-3] 'tooltip-gud-toggle-dereference)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
245 (add-hook 'gdb-mode-hook
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
246 #'(lambda () (setq tooltip-gud-debugger 'gdb)))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
247 (add-hook 'sdb-mode-hook
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
248 #'(lambda () (setq tooltip-gud-debugger 'sdb)))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
249 (add-hook 'dbx-mode-hook
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
250 #'(lambda () (setq tooltip-gud-debugger 'dbx)))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
251 (add-hook 'xdb-mode-hook
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
252 #'(lambda () (setq tooltip-gud-debugger 'xdb)))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
253 (add-hook 'perldb-mode-hook
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
254 #'(lambda () (setq tooltip-gud-debugger 'perldb)))))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 ;;; Timeout for tooltip display
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (defun tooltip-delay ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 "Return the delay in seconds for the next tooltip."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (let ((delay tooltip-delay)
30481
b603c68fff56 use float-time
Sam Steingold <sds@gnu.org>
parents: 27582
diff changeset
261 (now (float-time)))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (when (and tooltip-hide-time
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (< (- now tooltip-hide-time) tooltip-recent-seconds))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (setq delay tooltip-short-delay))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 delay))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
268 (defun tooltip-cancel-delayed-tip ()
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 "Disable the tooltip timeout."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (when tooltip-timeout-id
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (disable-timeout tooltip-timeout-id)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (setq tooltip-timeout-id nil)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
275 (defun tooltip-start-delayed-tip ()
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 "Add a one-shot timeout to call function tooltip-timeout."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (setq tooltip-timeout-id
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (add-timeout (tooltip-delay) 'tooltip-timeout nil)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 (defun tooltip-timeout (object)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 "Function called when timer with id tooltip-timeout-id fires."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (run-hook-with-args-until-success 'tooltip-hook
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 tooltip-last-mouse-motion-event))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 ;;; Reacting on mouse movements
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (defun tooltip-change-major-mode ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 "Function added to `change-major-mode-hook' when tooltip mode is on."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (add-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (defun tooltip-activate-mouse-motions-if-enabled ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 "Reconsider for all buffers whether mouse motion events are desired."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (remove-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (let ((buffers (buffer-list)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (save-excursion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (while buffers
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (set-buffer (car buffers))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (if (and tooltip-mode
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 tooltip-gud-tips-p
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (memq major-mode tooltip-gud-modes))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (tooltip-activate-mouse-motions t)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (tooltip-activate-mouse-motions nil))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (setq buffers (cdr buffers))))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (defun tooltip-activate-mouse-motions (activatep)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 "Activate/deactivate mouse motion events for the current buffer.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 ACTIVATEP non-nil means activate mouse motion events."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (if activatep
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (progn
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (make-local-variable 'track-mouse)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (setq track-mouse t))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (kill-local-variable 'track-mouse)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (defun tooltip-mouse-motion (event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 "Command handler for mouse movement events in `global-map'."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (interactive "e")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (tooltip-hide)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (when (car (mouse-pixel-position))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (setq tooltip-last-mouse-motion-event (copy-sequence event))
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
326 (tooltip-start-delayed-tip)))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 ;;; Displaying tips
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
332 (defun tooltip-set-param (alist key value)
40178
1dab42ecd751 (tooltip-set-param): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 40173
diff changeset
333 "Change the value of KEY in alist ALIST to VALUE.
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
334 If there's no association for KEY in ALIST, add one, otherwise
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
335 change the existing association. Value is the resulting alist."
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
336 (let ((param (assq key alist)))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
337 (if (consp param)
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
338 (setcdr param value)
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
339 (push (cons key value) alist))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
340 alist))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
341
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
342
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (defun tooltip-show (text)
40173
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
344 "Show a tooltip window displaying TEXT.
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
345
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
346 Text larger than `x-max-tooltip-size' (which see) is clipped.
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
347
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
348 If the alist in `tooltip-frame-parameters' includes `left' and `top'
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
349 parameters, they determine the x and y position where the tooltip
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
350 is displayed. Otherwise, the tooltip pops at offsets specified by
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
351 `tooltip-x-offset' and `tooltip-y-offset' from the current mouse
c4955867228d (tooltip-x-offset, tooltip-y-offset): Mention in the
Eli Zaretskii <eliz@gnu.org>
parents: 37755
diff changeset
352 position."
32431
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
353 (if tooltip-use-echo-area
a35cc9700ff7 * tooltip.el (tooltip-use-echo-area): New user variable.
Sam Steingold <sds@gnu.org>
parents: 30481
diff changeset
354 (message "%s" text)
34540
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
355 (condition-case error
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
356 (let ((params (copy-sequence tooltip-frame-parameters))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
357 (fg (face-attribute 'tooltip :foreground))
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
358 (bg (face-attribute 'tooltip :background)))
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
359 (when (stringp fg)
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
360 (setq params (tooltip-set-param params 'foreground-color fg))
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
361 (setq params (tooltip-set-param params 'border-color fg)))
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
362 (when (stringp bg)
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
363 (setq params (tooltip-set-param params 'background-color bg)))
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
364 (x-show-tip (propertize text 'face 'tooltip)
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
365 (selected-frame)
35044
bb5e7a8b6f4c Fix last change.
Gerd Moellmann <gerd@gnu.org>
parents: 35043
diff changeset
366 params
35401
c00e94a506a2 (tooltip-hide-delay): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 35069
diff changeset
367 tooltip-hide-delay
35043
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
368 tooltip-x-offset
f7ca93e40e16 (tooltip-frame-parameters): Remove colors.
Gerd Moellmann <gerd@gnu.org>
parents: 34689
diff changeset
369 tooltip-y-offset))
34540
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
370 (error
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
371 (message "Error while displaying tooltip: %s" error)
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
372 (sit-for 1)
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
373 (message "%s" text)))))
e1e4704de6ed (tooltip-show): If an error is signaled in
Gerd Moellmann <gerd@gnu.org>
parents: 33925
diff changeset
374
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (defun tooltip-hide (&optional ignored-arg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 "Hide a tooltip, if one is displayed.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 Value is non-nil if tooltip was open."
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
379 (tooltip-cancel-delayed-tip)
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (when (x-hide-tip)
30481
b603c68fff56 use float-time
Sam Steingold <sds@gnu.org>
parents: 27582
diff changeset
381 (setq tooltip-hide-time (float-time))))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 ;;; Debugger-related functions
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (defun tooltip-identifier-from-point (point)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 "Extract the identifier at POINT, if any.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 Value is nil if no identifier exists at point. Identifier extraction
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 is based on the current syntax table."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (save-excursion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (goto-char point)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (let ((start (progn (skip-syntax-backward "w_") (point))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (unless (looking-at "[0-9]")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (skip-syntax-forward "w_")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (when (> (point) start)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (buffer-substring start (point)))))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (defmacro tooltip-region-active-p ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 "Value is non-nil if the region is currently active."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (if (string-match "^GNU" (emacs-version))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 `(and transient-mark-mode mark-active)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 `(region-active-p)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (defun tooltip-expr-to-print (event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 "Return an expression that should be printed for EVENT.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 If a region is active and the mouse is inside the region, print
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 the region. Otherwise, figure out the identifier around the point
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 where the mouse is."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (save-excursion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (set-buffer (tooltip-event-buffer event))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (let ((point (posn-point (event-end event))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (if (tooltip-region-active-p)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (when (and (<= (region-beginning) point) (<= point (region-end)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (buffer-substring (region-beginning) (region-end)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (tooltip-identifier-from-point point)))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (defun tooltip-process-prompt-regexp (process)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 "Return regexp matching the prompt of PROCESS at the end of a string.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 The prompt is taken from the value of COMINT-PROMPT-REGEXP in the buffer
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 of PROCESS."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (let ((prompt-regexp (save-excursion
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (set-buffer (process-buffer process))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 comint-prompt-regexp)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 ;; Most start with `^' but the one for `sdb' cannot be easily
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 ;; stripped. Code the prompt for `sdb' fixed here.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (if (= (aref prompt-regexp 0) ?^)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (setq prompt-regexp (substring prompt-regexp 1))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (setq prompt-regexp "\\*"))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (concat "\n*" prompt-regexp "$")))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (defun tooltip-strip-prompt (process output)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 "Return OUTPUT with any prompt of PROCESS stripped from its end."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (let ((prompt-regexp (tooltip-process-prompt-regexp process)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (save-match-data
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (when (string-match prompt-regexp output)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (setq output (substring output 0 (match-beginning 0)))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 output))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 ;;; Tips for `gud'
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (defvar tooltip-gud-original-filter nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 "Process filter to restore after GUD output has been received.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (defvar tooltip-gud-dereference nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 "Non-nil means print expressions with a `*' in front of them.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 For C this would dereference a pointer expression.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (defvar tooltip-gud-event nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 "The mouse movement event that led to a tooltip display.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 This event can be examined by forms in TOOLTIP-GUD-DISPLAY.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (defvar tooltip-gud-debugger nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 "A symbol describing the debugger running under GUD.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (defun tooltip-gud-toggle-dereference ()
27582
42b52d8b6703 (tooltip-gud-tips-p, tooltip-gud-toggle-dereference):
Dave Love <fx@gnu.org>
parents: 25332
diff changeset
467 "Toggle whether tooltips should show `* expr' or `expr'."
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (interactive)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (setq tooltip-gud-dereference (not tooltip-gud-dereference))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (when (interactive-p)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (message "Dereferencing is now %s."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (if tooltip-gud-dereference "on" "off"))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (defun tooltip-gud-process-output (process output)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 "Process debugger output and show it in a tooltip window."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (set-process-filter process tooltip-gud-original-filter)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (tooltip-show (tooltip-strip-prompt process output)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (defun tooltip-gud-print-command (expr)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 "Return a suitable command to print the expression EXPR.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (when tooltip-gud-dereference
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (setq expr (concat "*" expr)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (case tooltip-gud-debugger
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 ((gdb dbx) (concat "print " expr))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (xdb (concat "p " expr))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (sdb (concat expr "/"))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (perldb expr)))
30481
b603c68fff56 use float-time
Sam Steingold <sds@gnu.org>
parents: 27582
diff changeset
491
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (defun tooltip-gud-tips (event)
25332
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
494 "Show tip for identifier or selection under the mouse.
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
495 The mouse must either point at an identifier or inside a selected
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
496 region for the tip window to be shown. If tooltip-gud-dereference is t,
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
497 add a `*' in front of the printed expression.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 This function must return nil if it doesn't handle EVENT."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (let (gud-buffer process)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (when (and (eventp event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 tooltip-gud-tips-p
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (boundp 'gud-comint-buffer)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (setq gud-buffer gud-comint-buffer)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (setq process (get-buffer-process gud-buffer))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (posn-point (event-end event))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (progn (setq tooltip-gud-event event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (eval (cons 'and tooltip-gud-display))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (let ((expr (tooltip-expr-to-print event)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (when expr
33140
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
511 (let ((cmd (tooltip-gud-print-command expr)))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
512 (unless (null cmd) ; CMD can be nil if unknown debugger
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
513 (setq tooltip-gud-original-filter (process-filter process))
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
514 (set-process-filter process 'tooltip-gud-process-output)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
515 (gud-basic-call cmd)
61f4c87b845c (tooltip-gud-tips-setup): New function.
Miles Bader <miles@gnu.org>
parents: 32431
diff changeset
516 expr)))))))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 ;;; Tooltip help.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (defvar tooltip-help-message nil
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 "The last help message received via `tooltip-show-help-function'.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (defun tooltip-show-help-function (msg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 "Function installed as `show-help-function'.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 MSG is either a help string to display, or nil to cancel the display."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (let ((previous-help tooltip-help-message))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (setq tooltip-help-message msg)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (cond ((null msg)
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
531 ;; Cancel display. This also cancels a delayed tip, if
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
532 ;; there is one.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (tooltip-hide))
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
534 ((equal previous-help msg)
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
535 ;; Same help as before (but possibly the mouse has moved).
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
536 ;; Keep what we have.
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
537 )
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
538 (t
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
539 ;; A different help. Remove a previous tooltip, and
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
540 ;; display a new one, with some delay.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (tooltip-hide)
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
542 (tooltip-start-delayed-tip)))))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (defun tooltip-help-tips (event)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 "Hook function to display a help tooltip.
35069
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
547 This is installed on the hook `tooltip-hook', which is run when
d19eadb47c76 (tooltip-cancel-delayed-tip)
Gerd Moellmann <gerd@gnu.org>
parents: 35044
diff changeset
548 the the timer with ID `tooltip-timeout-id' fires.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 Value is non-nil if this function handled the tip."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (when (stringp tooltip-help-message)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (tooltip-show tooltip-help-message)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 t))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555
33356
73a360d50e18 (tooltip-mode): Add a comment about startup.el
Gerd Moellmann <gerd@gnu.org>
parents: 33140
diff changeset
556 ;;; Do this after all functions have been defined that are called from
73a360d50e18 (tooltip-mode): Add a comment about startup.el
Gerd Moellmann <gerd@gnu.org>
parents: 33140
diff changeset
557 ;;; `tooltip-mode'. The actual default value of `tooltip-mode' is set
73a360d50e18 (tooltip-mode): Add a comment about startup.el
Gerd Moellmann <gerd@gnu.org>
parents: 33140
diff changeset
558 ;;; in startup.el.
25332
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
559
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
560 ;;;###autoload
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
561 (defcustom tooltip-mode nil
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
562 "Toggle tooltip-mode.
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
563 Setting this variable directly does not take effect;
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
564 use either \\[customize] or the function `tooltip-mode'."
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
565 :set (lambda (symbol value)
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
566 (tooltip-mode (or value 0)))
c09e05be2f4b (tooltip-mode): Customize this, per convention.
Dave Love <fx@gnu.org>
parents: 25003
diff changeset
567 :initialize 'custom-initialize-default
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 :type 'boolean
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 :require 'tooltip
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 :group 'tooltip)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 ;;; tooltip.el ends here