From 14c0a34db0216423c493349efd9079e968586ef5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Wed, 9 Apr 2008 09:34:16 +0000 Subject: [PATCH] (tooltip-mode): Set tooltip-show-help-non-mode as show-help-function when turning tooltip off. (tooltip-show): Call tooltip-show-help-non-mode if use-echo-area. (tooltip-trunc-str, tooltip-show-help-non-mode): New. --- lisp/ChangeLog | 7 +++++++ lisp/tooltip.el | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 55bac7a63bf..8a2a05d8cfd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2008-04-09 Jan Djärv + + * tooltip.el (tooltip-mode): Set tooltip-show-help-non-mode as + show-help-function when turning tooltip off. + (tooltip-show): Call tooltip-show-help-non-mode if use-echo-area. + (tooltip-trunc-str, tooltip-show-help-non-mode): New. + 2008-04-09 Alan Mackenzie * font-lock.el (font-lock-extend-after-change-region-function): diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 253ce48e8ec..bfbedcf0c13 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -67,7 +67,7 @@ the help text in the echo area, and does not make a pop-up window." (remove-hook 'pre-command-hook 'tooltip-hide)) (remove-hook 'tooltip-hook 'tooltip-help-tips)) (setq show-help-function - (if tooltip-mode 'tooltip-show-help nil))) + (if tooltip-mode 'tooltip-show-help 'tooltip-show-help-non-mode))) ;;; Customizable settings @@ -228,7 +228,7 @@ position. Optional second arg USE-ECHO-AREA non-nil means to show tooltip in echo area." (if use-echo-area - (message "%s" text) + (tooltip-show-help-non-mode text) (condition-case error (let ((params (copy-sequence tooltip-frame-parameters)) (fg (face-attribute 'tooltip :foreground)) @@ -316,6 +316,22 @@ the buffer of PROCESS." (defvar tooltip-help-message nil "The last help message received via `tooltip-show-help'.") +(defun tooltip-trunc-str (str maxlen pieces) + (let ((s (car pieces))) + (if (and pieces (< (+ (length str) (length s) 2) maxlen)) + (tooltip-trunc-str (concat str + (if (> (length str) 0) ", " "") + s) + maxlen (cdr pieces)) + (if (> (length str) 0) str s)))) + +(defun tooltip-show-help-non-mode (msg) + "Function installed as `show-help-function' when tooltip is off." + (message "%s" (if msg + (tooltip-trunc-str "" (frame-parameter nil 'width) + (split-string msg "\n" t)) + ""))) + (defun tooltip-show-help (msg) "Function installed as `show-help-function'. MSG is either a help string to display, or nil to cancel the display." -- 2.39.5