diff options
| author | Nick Roberts | 2005-03-09 23:19:00 +0000 |
|---|---|---|
| committer | Nick Roberts | 2005-03-09 23:19:00 +0000 |
| commit | 8bc973e9719fa8e1e39d1ca9ad76835b3febcfcb (patch) | |
| tree | d4acd74da49c6bd7d2dc07ab388ce34fb60c8e05 | |
| parent | 33c76f5a4e0b858f076bcb45faf95d2bb7782199 (diff) | |
| download | emacs-8bc973e9719fa8e1e39d1ca9ad76835b3febcfcb.tar.gz emacs-8bc973e9719fa8e1e39d1ca9ad76835b3febcfcb.zip | |
(tooltip-mode): Use define-minor-mode and simplify.
(tooltip-activate-mouse-motions-if-enabled): Use dolist.
(tooltip-gud-tips): Simplify.
(tooltip-gud-tips-p): Remove superflouous :set.
(tooltip-gud-modes): Add fortran-mode.
(gdb-tooltip-print): Remove newline for tooltip-use-echo-area.
| -rw-r--r-- | lisp/tooltip.el | 69 |
1 files changed, 22 insertions, 47 deletions
diff --git a/lisp/tooltip.el b/lisp/tooltip.el index c4ac57eac95..6d81ee39d7f 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; tooltip.el --- show tooltip windows | 1 | ;;; tooltip.el --- show tooltip windows |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 | 3 | ;; Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005 |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Author: Gerd Moellmann <gerd@acm.org> | 6 | ;; Author: Gerd Moellmann <gerd@acm.org> |
| @@ -41,8 +41,6 @@ | |||
| 41 | :version "21.1" | 41 | :version "21.1" |
| 42 | :tag "Tool Tips") | 42 | :tag "Tool Tips") |
| 43 | 43 | ||
| 44 | (defvar tooltip-mode) | ||
| 45 | |||
| 46 | (defcustom tooltip-delay 0.7 | 44 | (defcustom tooltip-delay 0.7 |
| 47 | "Seconds to wait before displaying a tooltip the first time." | 45 | "Seconds to wait before displaying a tooltip the first time." |
| 48 | :tag "Delay" | 46 | :tag "Delay" |
| @@ -122,11 +120,9 @@ position to pop up the tooltip." | |||
| 122 | "*Non-nil means show tooltips in GUD sessions." | 120 | "*Non-nil means show tooltips in GUD sessions." |
| 123 | :type 'boolean | 121 | :type 'boolean |
| 124 | :tag "GUD" | 122 | :tag "GUD" |
| 125 | :set #'(lambda (symbol on) | ||
| 126 | (setq tooltip-gud-tips-p on)) | ||
| 127 | :group 'tooltip) | 123 | :group 'tooltip) |
| 128 | 124 | ||
| 129 | (defcustom tooltip-gud-modes '(gud-mode c-mode c++-mode) | 125 | (defcustom tooltip-gud-modes '(gud-mode c-mode c++-mode fortran-mode) |
| 130 | "List of modes for which to enable GUD tips." | 126 | "List of modes for which to enable GUD tips." |
| 131 | :type 'sexp | 127 | :type 'sexp |
| 132 | :tag "GUD modes" | 128 | :tag "GUD modes" |
| @@ -187,26 +183,23 @@ This might return nil if the event did not occur over a buffer." | |||
| 187 | ;; would be accompanied by a full redisplay. | 183 | ;; would be accompanied by a full redisplay. |
| 188 | 184 | ||
| 189 | ;;;###autoload | 185 | ;;;###autoload |
| 190 | (defun tooltip-mode (&optional arg) | 186 | (define-minor-mode tooltip-mode |
| 191 | "Mode for tooltip display. | 187 | "Toggle Tooltip display. |
| 192 | With ARG, turn tooltip mode on if and only if ARG is positive." | 188 | With ARG, turn tooltip mode on if and only if ARG is positive." |
| 193 | (interactive "P") | 189 | :global t |
| 190 | :group 'tooltip | ||
| 194 | (unless (fboundp 'x-show-tip) | 191 | (unless (fboundp 'x-show-tip) |
| 195 | (error "Sorry, tooltips are not yet available on this system")) | 192 | (error "Sorry, tooltips are not yet available on this system")) |
| 196 | (let* ((on (if arg | 193 | (let ((hook-fn (if tooltip-mode 'add-hook 'remove-hook))) |
| 197 | (> (prefix-numeric-value arg) 0) | ||
| 198 | (not tooltip-mode))) | ||
| 199 | (hook-fn (if on 'add-hook 'remove-hook))) | ||
| 200 | (setq tooltip-mode on) | ||
| 201 | (funcall hook-fn 'change-major-mode-hook 'tooltip-change-major-mode) | 194 | (funcall hook-fn 'change-major-mode-hook 'tooltip-change-major-mode) |
| 202 | (tooltip-activate-mouse-motions-if-enabled) | 195 | (tooltip-activate-mouse-motions-if-enabled) |
| 203 | (funcall hook-fn 'pre-command-hook 'tooltip-hide) | 196 | (funcall hook-fn 'pre-command-hook 'tooltip-hide) |
| 204 | (funcall hook-fn 'tooltip-hook 'tooltip-gud-tips) | 197 | (funcall hook-fn 'tooltip-hook 'tooltip-gud-tips) |
| 205 | (funcall hook-fn 'tooltip-hook 'tooltip-help-tips) | 198 | (funcall hook-fn 'tooltip-hook 'tooltip-help-tips) |
| 206 | (setq show-help-function (if on 'tooltip-show-help-function nil)) | 199 | (setq show-help-function (if tooltip-mode 'tooltip-show-help-function nil)) |
| 207 | ;; `ignore' is the default binding for mouse movements. | 200 | ;; `ignore' is the default binding for mouse movements. |
| 208 | (define-key global-map [mouse-movement] | 201 | (define-key global-map [mouse-movement] |
| 209 | (if on 'tooltip-mouse-motion 'ignore)))) | 202 | (if tooltip-mode 'tooltip-mouse-motion 'ignore)))) |
| 210 | 203 | ||
| 211 | 204 | ||
| 212 | ;;; Timeout for tooltip display | 205 | ;;; Timeout for tooltip display |
| @@ -246,16 +239,14 @@ With ARG, turn tooltip mode on if and only if ARG is positive." | |||
| 246 | (defun tooltip-activate-mouse-motions-if-enabled () | 239 | (defun tooltip-activate-mouse-motions-if-enabled () |
| 247 | "Reconsider for all buffers whether mouse motion events are desired." | 240 | "Reconsider for all buffers whether mouse motion events are desired." |
| 248 | (remove-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled) | 241 | (remove-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled) |
| 249 | (let ((buffers (buffer-list))) | 242 | (dolist (buffer (buffer-list)) |
| 250 | (save-excursion | 243 | (save-excursion |
| 251 | (while buffers | 244 | (set-buffer buffer) |
| 252 | (set-buffer (car buffers)) | 245 | (if (and tooltip-mode |
| 253 | (if (and tooltip-mode | 246 | tooltip-gud-tips-p |
| 254 | tooltip-gud-tips-p | 247 | (memq major-mode tooltip-gud-modes)) |
| 255 | (memq major-mode tooltip-gud-modes)) | 248 | (tooltip-activate-mouse-motions t) |
| 256 | (tooltip-activate-mouse-motions t) | 249 | (tooltip-activate-mouse-motions nil))))) |
| 257 | (tooltip-activate-mouse-motions nil)) | ||
| 258 | (setq buffers (cdr buffers)))))) | ||
| 259 | 250 | ||
| 260 | (defvar tooltip-mouse-motions-active nil | 251 | (defvar tooltip-mouse-motions-active nil |
| 261 | "Locally t in a buffer if tooltip processing of mouse motion is enabled.") | 252 | "Locally t in a buffer if tooltip processing of mouse motion is enabled.") |
| @@ -441,12 +432,11 @@ region for the tip window to be shown. If tooltip-gud-dereference is t, | |||
| 441 | add a `*' in front of the printed expression. | 432 | add a `*' in front of the printed expression. |
| 442 | 433 | ||
| 443 | This function must return nil if it doesn't handle EVENT." | 434 | This function must return nil if it doesn't handle EVENT." |
| 444 | (let (gud-buffer process) | 435 | (let (process) |
| 445 | (when (and (eventp event) | 436 | (when (and (eventp event) |
| 446 | tooltip-gud-tips-p | 437 | tooltip-gud-tips-p |
| 447 | (boundp 'gud-comint-buffer) | 438 | (boundp 'gud-comint-buffer) |
| 448 | (setq gud-buffer gud-comint-buffer) | 439 | (setq process (get-buffer-process gud-comint-buffer)) |
| 449 | (setq process (get-buffer-process gud-buffer)) | ||
| 450 | (posn-point (event-end event)) | 440 | (posn-point (event-end event)) |
| 451 | (progn (setq tooltip-gud-event event) | 441 | (progn (setq tooltip-gud-event event) |
| 452 | (eval (cons 'and tooltip-gud-display)))) | 442 | (eval (cons 'and tooltip-gud-display)))) |
| @@ -464,9 +454,11 @@ This function must return nil if it doesn't handle EVENT." | |||
| 464 | expr))))))) | 454 | expr))))))) |
| 465 | 455 | ||
| 466 | (defun gdb-tooltip-print () | 456 | (defun gdb-tooltip-print () |
| 467 | (tooltip-show | 457 | (tooltip-show |
| 468 | (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) | 458 | (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) |
| 469 | (buffer-string)))) | 459 | (let ((string (buffer-string))) |
| 460 | ;; remove newline for tooltip-use-echo-area | ||
| 461 | (substring string 0 (- (length string) 1)))))) | ||
| 470 | 462 | ||
| 471 | 463 | ||
| 472 | ;;; Tooltip help. | 464 | ;;; Tooltip help. |
| @@ -520,23 +512,6 @@ Value is non-nil if this function handled the tip." | |||
| 520 | (tooltip-show tooltip-help-message) | 512 | (tooltip-show tooltip-help-message) |
| 521 | t)) | 513 | t)) |
| 522 | 514 | ||
| 523 | |||
| 524 | ;;; Do this after all functions have been defined that are called from | ||
| 525 | ;;; `tooltip-mode'. The actual default value of `tooltip-mode' is set | ||
| 526 | ;;; in startup.el. | ||
| 527 | |||
| 528 | ;;;###autoload | ||
| 529 | (defcustom tooltip-mode nil | ||
| 530 | "Non-nil if Tooltip mode is enabled. | ||
| 531 | Setting this variable directly does not take effect; | ||
| 532 | use either \\[customize] or the function `tooltip-mode'." | ||
| 533 | :set (lambda (symbol value) | ||
| 534 | (tooltip-mode (or value 0))) | ||
| 535 | :initialize 'custom-initialize-default | ||
| 536 | :type 'boolean | ||
| 537 | :require 'tooltip | ||
| 538 | :group 'tooltip) | ||
| 539 | |||
| 540 | (provide 'tooltip) | 515 | (provide 'tooltip) |
| 541 | 516 | ||
| 542 | ;; arch-tag: 3d61135e-4618-4a78-af28-183f6df5636f | 517 | ;; arch-tag: 3d61135e-4618-4a78-af28-183f6df5636f |