emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tooltips on w32 slow and strange


From: Stefan Monnier
Subject: Re: Tooltips on w32 slow and strange
Date: Mon, 14 Feb 2005 13:29:19 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

> I think this is the reason:

> ,----[ startup.el ]
> | (defun command-line ()
> | [...]
> |   (unless (or noninteractive
> |           emacs-quick-startup
> |               (not (display-graphic-p))
> |               (not (fboundp 'x-show-tip)))
> |     (setq-default tooltip-mode t)
> |     (tooltip-mode 1))
> `----

Yes I think this is wrong.
Instead, the defcustom of tooltip-mode should set the default value to

        (and (not noninteractive)
             (not emacs-quick-startup)
             (display-graphic-p)
             (fboundp 'x-show-tip))

and then command-line should only do something like
(custom-reeval 'tooltip-mode) where custom-reeval is a new function that
re-sets the value of a custom var by re-evaluating the expression that
describes its default (or saved, or whatever) value,
i.e. something typically used when the value of the expression can change.


        Stefan


--- orig/lisp/tooltip.el
+++ mod/lisp/tooltip.el
@@ -187,25 +187,25 @@
 ;; would be accompanied by a full redisplay.
 
 ;;;###autoload
-(defun tooltip-mode (&optional arg)
+(define-minor-mode tooltip-mode
   "Mode for tooltip display.
 With ARG, turn tooltip mode on if and only if ARG is positive."
-  (interactive "P")
-  (unless (fboundp 'x-show-tip)
+  :init (and (not noninteractive)
+            (not emacs-quick-startup)
+            (display-graphic-p)
+            (fboundp 'x-show-tip))
+  (unless (or (null tooltip-mode) (fboundp 'x-show-tip))
     (error "Sorry, tooltips are not yet available on this system"))
-  (let* ((on (if arg
-                (> (prefix-numeric-value arg) 0)
-              (not tooltip-mode)))
-        (hook-fn (if on 'add-hook 'remove-hook)))
-    (setq tooltip-mode on)
+  (let ((hook-fn (if tooltip-mode 'add-hook 'remove-hook)))
     (funcall hook-fn 'change-major-mode-hook 'tooltip-change-major-mode)
     (tooltip-activate-mouse-motions-if-enabled)
     (funcall hook-fn 'pre-command-hook 'tooltip-hide)
     (funcall hook-fn 'tooltip-hook 'tooltip-gud-tips)
     (funcall hook-fn 'tooltip-hook 'tooltip-help-tips)
     (setq show-help-function (if on 'tooltip-show-help-function nil))
-    ;; `ignore' is the default binding for mouse movements.
+    ;; FIXME: why not use a minor mode map?
     (define-key global-map [mouse-movement]
+      ;; `ignore' is the default binding for mouse movements.
       (if on 'tooltip-mouse-motion 'ignore))))
 
 
@@ -521,22 +521,6 @@
     t))
 
 
-;;; Do this after all functions have been defined that are called from
-;;; `tooltip-mode'.  The actual default value of `tooltip-mode' is set
-;;; in startup.el.
-
-;;;###autoload
-(defcustom tooltip-mode nil
-  "Non-nil if Tooltip mode is enabled.
-Setting this variable directly does not take effect;
-use either \\[customize] or the function `tooltip-mode'."
-  :set (lambda (symbol value)
-        (tooltip-mode (or value 0)))
-  :initialize 'custom-initialize-default
-  :type 'boolean
-  :require 'tooltip
-  :group 'tooltip)
-
 (provide 'tooltip)
 
 ;; arch-tag: 3d61135e-4618-4a78-af28-183f6df5636f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]