summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-04-19 19:30:53 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-04-19 19:30:53 +0000
commitece5f84750f297572c9ecacc0d09bd9418017b2c (patch)
treecac489f8c4ae280cd1cecfb95a75932ac16c992e
parent59ae30492b4fe8a7245061b580b7092ce22eb77f (diff)
downloademacs-ece5f84750f297572c9ecacc0d09bd9418017b2c.tar.gz
* tooltip.el (tooltip-previous-message): New var.
(tooltip-show-help-non-mode): Rewrite to better follow the behavior of the C code (avoid overwriting a minibuffer, restore previous echo message, ...). (tooltip-delay, tooltip-process-prompt-regexp, tooltip-strip-prompt): Simplify. * keyboard.c (Vpre_help_message): Remove. (show_help_echo): Remove default C code.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/tooltip.el66
-rw-r--r--src/ChangeLog3
-rw-r--r--src/keyboard.c39
4 files changed, 52 insertions, 65 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c100c0b52c5..0cf25aca213 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2008-04-19 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * tooltip.el (tooltip-previous-message): New var.
+ (tooltip-show-help-non-mode): Rewrite to better follow the behavior of
+ the C code (avoid overwriting a minibuffer, restore previous echo
+ message, ...).
+ (tooltip-delay, tooltip-process-prompt-regexp, tooltip-strip-prompt):
+ Simplify.
+
2008-04-19 Nick Roberts <nickrob@snap.net.nz>
* progmodes/gdb-ui.el (gdb-thread-indicator): New variable.
diff --git a/lisp/tooltip.el b/lisp/tooltip.el
index 469a1584221..a9ac027e1b3 100644
--- a/lisp/tooltip.el
+++ b/lisp/tooltip.el
@@ -178,12 +178,10 @@ This might return nil if the event did not occur over a buffer."
(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."
@@ -280,8 +278,7 @@ is based on the current syntax table."
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)))
@@ -292,23 +289,22 @@ where the mouse is."
"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)))
;;; Tooltip help.
@@ -316,12 +312,30 @@ the buffer of PROCESS."
(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'.
diff --git a/src/ChangeLog b/src/ChangeLog
index 2afb3a412b3..b23dd2ecea2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,8 @@
2008-04-19 Stefan Monnier <monnier@iro.umontreal.ca>
+ * keyboard.c (Vpre_help_message): Remove.
+ (show_help_echo): Remove default C code.
+
* dired.c (directory_files_internal, file_name_completion):
Only call ENCODE_FILE if the string is indeed decoded.
diff --git a/src/keyboard.c b/src/keyboard.c
index 64427992a83..6e7bcca3ca3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -157,11 +157,6 @@ extern int message_enable_multibyte;
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;
@@ -2458,37 +2453,6 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo)
{
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);
}
}
@@ -11753,9 +11717,6 @@ syms_of_keyboard ()
{
pending_funcalls = Qnil;
- Vpre_help_message = Qnil;
- staticpro (&Vpre_help_message);
-
Vlispy_mouse_stem = build_string ("mouse");
staticpro (&Vlispy_mouse_stem);