# HG changeset patch # User Gerd Moellmann # Date 978640682 0 # Node ID d19eadb47c76159dd40a57d0fd27db804a22be59 # Parent e6fe439553cfa454fa851e1789d5720345044a50 (tooltip-cancel-delayed-tip) (tooltip-start-delayed-tip): Renamed from tooltip-disable-timeout and tooltip-add-timeout. (tooltip-show): Set border color from faces's foreground. (tooltip-show-help-function): If called with the same help string as last time, do nothing. (tooltip-help-tips): Don't set tooltip-help-message to nil. diff -r e6fe439553cf -r d19eadb47c76 lisp/tooltip.el --- a/lisp/tooltip.el Thu Jan 04 20:34:40 2001 +0000 +++ b/lisp/tooltip.el Thu Jan 04 20:38:02 2001 +0000 @@ -1,6 +1,6 @@ ;;; tooltip.el --- Show tooltip windows -;; Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. +;; Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc. ;; Author: Gerd Moellmann ;; Keywords: help c mouse tools @@ -247,14 +247,14 @@ delay)) -(defun tooltip-disable-timeout () +(defun tooltip-cancel-delayed-tip () "Disable the tooltip timeout." (when tooltip-timeout-id (disable-timeout tooltip-timeout-id) (setq tooltip-timeout-id nil))) -(defun tooltip-add-timeout () +(defun tooltip-start-delayed-tip () "Add a one-shot timeout to call function tooltip-timeout." (setq tooltip-timeout-id (add-timeout (tooltip-delay) 'tooltip-timeout nil))) @@ -305,7 +305,7 @@ (tooltip-hide) (when (car (mouse-pixel-position)) (setq tooltip-last-mouse-motion-event (copy-sequence event)) - (tooltip-add-timeout))) + (tooltip-start-delayed-tip))) @@ -330,11 +330,11 @@ (let ((params (copy-sequence tooltip-frame-parameters)) (fg (face-attribute 'tooltip :foreground)) (bg (face-attribute 'tooltip :background))) - (unless (eq 'unspecified fg) - (setq params (tooltip-set-param params 'foreground-color fg))) - (unless (eq 'unspecified bg) - (setq params (tooltip-set-param params 'background-color bg)) - (setq params (tooltip-set-param params 'border-color bg))) + (when (stringp fg) + (setq params (tooltip-set-param params 'foreground-color fg)) + (setq params (tooltip-set-param params 'border-color fg))) + (when (stringp bg) + (setq params (tooltip-set-param params 'background-color bg))) (x-show-tip (propertize text 'face 'tooltip) (selected-frame) params @@ -350,7 +350,7 @@ (defun tooltip-hide (&optional ignored-arg) "Hide a tooltip, if one is displayed. Value is non-nil if tooltip was open." - (tooltip-disable-timeout) + (tooltip-cancel-delayed-tip) (when (x-hide-tip) (setq tooltip-hide-time (float-time)))) @@ -502,22 +502,27 @@ (let ((previous-help tooltip-help-message)) (setq tooltip-help-message msg) (cond ((null msg) + ;; Cancel display. This also cancels a delayed tip, if + ;; there is one. (tooltip-hide)) - ((or (not (stringp previous-help)) - (not (string= msg previous-help))) + ((equal previous-help msg) + ;; Same help as before (but possibly the mouse has moved). + ;; Keep what we have. + ) + (t + ;; A different help. Remove a previous tooltip, and + ;; display a new one, with some delay. (tooltip-hide) - (tooltip-add-timeout)) - (t - (tooltip-disable-timeout) - (tooltip-add-timeout))))) + (tooltip-start-delayed-tip))))) (defun tooltip-help-tips (event) "Hook function to display a help tooltip. +This is installed on the hook `tooltip-hook', which is run when +the the timer with ID `tooltip-timeout-id' fires. Value is non-nil if this function handled the tip." (when (stringp tooltip-help-message) (tooltip-show tooltip-help-message) - (setq tooltip-help-message nil) t))