(defun tooltip-delay ()
"Return the delay in seconds for the next tooltip."
- (let ((delay tooltip-delay)
- (now (float-time)))
- (when (and tooltip-hide-time
- (< (- now tooltip-hide-time) tooltip-recent-seconds))
- (setq delay tooltip-short-delay))
- delay))
+ (if (and tooltip-hide-time
+ (< (- (float-time) tooltip-hide-time) tooltip-recent-seconds))
+ tooltip-short-delay
+ tooltip-delay))
(defun tooltip-cancel-delayed-tip ()
"Disable the tooltip timeout."
If a region is active and the mouse is inside the region, print
the region. Otherwise, figure out the identifier around the point
where the mouse is."
- (save-excursion
- (set-buffer (tooltip-event-buffer event))
+ (with-current-buffer (tooltip-event-buffer event)
(let ((point (posn-point (event-end event))))
(if (tooltip-region-active-p)
(when (and (<= (region-beginning) point) (<= point (region-end)))
"Return regexp matching the prompt of PROCESS at the end of a string.
The prompt is taken from the value of `comint-prompt-regexp' in
the buffer of PROCESS."
- (let ((prompt-regexp (save-excursion
- (set-buffer (process-buffer process))
+ (let ((prompt-regexp (with-current-buffer (process-buffer process)
comint-prompt-regexp)))
- ;; Most start with `^' but the one for `sdb' cannot be easily
- ;; stripped. Code the prompt for `sdb' fixed here.
- (if (= (aref prompt-regexp 0) ?^)
- (setq prompt-regexp (substring prompt-regexp 1))
- (setq prompt-regexp "\\*"))
- (concat "\n*" prompt-regexp "$")))
+ (concat "\n*"
+ ;; Most start with `^' but the one for `sdb' cannot be easily
+ ;; stripped. Code the prompt for `sdb' fixed here.
+ (if (= (aref prompt-regexp 0) ?^)
+ (substring prompt-regexp 1)
+ "\\*")
+ "$")))
(defun tooltip-strip-prompt (process output)
"Return OUTPUT with any prompt of PROCESS stripped from its end."
- (let ((prompt-regexp (tooltip-process-prompt-regexp process)))
- (save-match-data
- (when (string-match prompt-regexp output)
- (setq output (substring output 0 (match-beginning 0)))))
- output))
+ (save-match-data
+ (if (string-match (tooltip-process-prompt-regexp process) output)
+ (substring output 0 (match-beginning 0))
+ output)))
\f
;;; Tooltip help.
(defvar tooltip-help-message nil
"The last help message received via `tooltip-show-help'.")
-(defun tooltip-show-help-non-mode (msg)
+(defvar tooltip-previous-message nil
+ "The previous content of the echo area.")
+
+(defun tooltip-show-help-non-mode (help)
"Function installed as `show-help-function' when tooltip is off."
- (let ((message-truncate-lines t))
- (message "%s" (if msg
- (replace-regexp-in-string "\n" ", " msg)
- ""))))
+ (when (and (not (window-minibuffer-p)) ;Don't overwrite minibuffer contents.
+ ;; Don't know how to reproduce it in Elisp:
+ ;; Don't overwrite a keystroke echo.
+ ;; (NILP (echo_message_buffer) || ok_to_overwrite_keystroke_echo)
+ (not cursor-in-echo-area)) ;Don't overwrite a prompt.
+ (cond
+ ((stringp help)
+ (unless tooltip-previous-message
+ (setq tooltip-previous-message (current-message)))
+ (let ((message-truncate-lines t)
+ (message-log-max nil))
+ (message "%s" (replace-regexp-in-string "\n" ", " help))))
+ ((stringp tooltip-previous-message)
+ (let ((message-log-max nil))
+ (message "%s" tooltip-previous-message)
+ (setq tooltip-previous-message nil)))
+ (t
+ (message nil)))))
+
(defun tooltip-show-help (msg)
"Function installed as `show-help-function'.
Lisp_Object Vshow_help_function;
-/* If a string, the message displayed before displaying a help-echo
- in the echo area. */
-
-Lisp_Object Vpre_help_message;
-
/* Nonzero means do menu prompting. */
static int menu_prompting;
{
if (!NILP (Vshow_help_function))
call1 (Vshow_help_function, help);
- else if (/* Don't overwrite minibuffer contents. */
- !MINI_WINDOW_P (XWINDOW (selected_window))
- /* Don't overwrite a keystroke echo. */
- && (NILP (echo_message_buffer)
- || ok_to_overwrite_keystroke_echo)
- /* Don't overwrite a prompt. */
- && !cursor_in_echo_area)
- {
- if (STRINGP (help))
- {
- int count = SPECPDL_INDEX ();
-
- if (!help_echo_showing_p)
- Vpre_help_message = current_message ();
-
- specbind (Qmessage_truncate_lines, Qt);
- message3_nolog (help, SBYTES (help),
- STRING_MULTIBYTE (help));
- unbind_to (count, Qnil);
- }
- else if (STRINGP (Vpre_help_message))
- {
- message3_nolog (Vpre_help_message,
- SBYTES (Vpre_help_message),
- STRING_MULTIBYTE (Vpre_help_message));
- Vpre_help_message = Qnil;
- }
- else
- message (0);
- }
-
help_echo_showing_p = STRINGP (help);
}
}
{
pending_funcalls = Qnil;
- Vpre_help_message = Qnil;
- staticpro (&Vpre_help_message);
-
Vlispy_mouse_stem = build_string ("mouse");
staticpro (&Vlispy_mouse_stem);