+/* Display help echo in the echo area.
+
+ HELP a string means display that string, HELP nil means clear the
+ help echo. If HELP is a function, call it with OBJECT and POS as
+ arguments; the function should return a help string or nil for
+ none. For all other types of HELP evaluate it to obtain a string.
+
+ WINDOW is the window in which the help was generated, if any.
+ It is nil if not in a window.
+
+ If OBJECT is a buffer, POS is the position in the buffer where the
+ `help-echo' text property was found.
+
+ If OBJECT is an overlay, that overlay has a `help-echo' property,
+ and POS is the position in the overlay's buffer under the mouse.
+
+ If OBJECT is a string (an overlay string or a string displayed with
+ the `display' property). POS is the position in that string under
+ the mouse.
+
+ OK_TO_IVERWRITE_KEYSTROKE_ECHO non-zero means it's okay if the help
+ echo overwrites a keystroke echo currently displayed in the echo
+ area.
+
+ Note: this function may only be called with HELP nil or a string
+ from X code running asynchronously. */
+
+void
+show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo)
+ Lisp_Object help, window, object, pos;
+ int ok_to_overwrite_keystroke_echo;
+{
+ if (!NILP (help) && !STRINGP (help))
+ {
+ if (FUNCTIONP (help))
+ {
+ Lisp_Object args[4];
+ args[0] = help;
+ args[1] = window;
+ args[2] = object;
+ args[3] = pos;
+ help = safe_call (4, args);
+ }
+ else
+ help = safe_eval (help);
+
+ if (!STRINGP (help))
+ return;
+ }
+
+ if (STRINGP (help) || NILP (help))
+ {
+ 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_ptr - specpdl;
+ specbind (Qmessage_truncate_lines, Qt);
+ message3_nolog (help, STRING_BYTES (XSTRING (help)),
+ STRING_MULTIBYTE (help));
+ unbind_to (count, Qnil);
+ }
+ else
+ message (0);
+ }
+
+ help_echo_showing_p = STRINGP (help);
+ }
+}
+