From 784a3bde24be0637646ad0bf22f695c84b8e3e05 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 13 May 2022 20:48:46 +0800 Subject: [PATCH] ; Minor improvements to earlier change * etc/NEWS: * lisp/tooltip.el (tooltip-show): Rename `frame-face' to `default-face' and improve doc about system tooltips. --- etc/NEWS | 2 +- lisp/tooltip.el | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a67e136643b..d93a79ed369 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2031,7 +2031,7 @@ Use 'buffer-match-p' to gather a list of buffers that match a condition. --- -** New arguments 'text-face' and 'frame-face' for 'tooltip-show'. +** New arguments 'text-face' and 'default-face' for 'tooltip-show'. They allow changing the faces used for the tooltip text and frame colors of the resulting tooltip frame from the default 'tooltip' face. diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 0e7d333f974..3e9c16a445a 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -230,16 +230,16 @@ change the existing association. Value is the resulting alist." (declare-function x-show-tip "xfns.c" (string &optional frame parms timeout dx dy)) -(defun tooltip-show (text &optional use-echo-area text-face frame-face) +(defun tooltip-show (text &optional use-echo-area text-face default-face) "Show a tooltip window displaying TEXT. Text larger than `x-max-tooltip-size' is clipped. -If the alist in `tooltip-frame-parameters' includes `left' and `top' -parameters, they determine the x and y position where the tooltip -is displayed. Otherwise, the tooltip pops at offsets specified by -`tooltip-x-offset' and `tooltip-y-offset' from the current mouse -position. +If the alist in `tooltip-frame-parameters' includes `left' and +`top' parameters, they determine the x and y position where the +tooltip is displayed. Otherwise, the tooltip pops at offsets +specified by `tooltip-x-offset' and `tooltip-y-offset' from the +current mouse position. The text properties of TEXT are also modified to add the appropriate faces before displaying the tooltip. If your code @@ -249,21 +249,23 @@ passing it to this function. Optional second arg USE-ECHO-AREA non-nil means to show tooltip in echo area. -The third and fourth args TEXT-FACE and FRAME-FACE specify faces -used to display the tooltip, and default to `tooltip' if not -specified. TEXT-FACE specifies a face used to display text in -the tooltip, while FRAME-FACE specifies a face that provides the -background, foreground and border colors of the tooltip frame. +The third and fourth args TEXT-FACE and DEFAULT-FACE specify +faces used to display the tooltip, and default to `tooltip' if +not specified. TEXT-FACE specifies a face used to display text +in the tooltip, while DEFAULT-FACE specifies a face that provides +the background, foreground and border colors of the tooltip +frame. Note that the last two arguments are not respected when `use-system-tooltips' is non-nil and Emacs is built with support -for system tooltips." +for system tooltips, such as on NS, Haiku, and with the GTK +toolkit." (if use-echo-area (tooltip-show-help-non-mode text) (condition-case error (let ((params (copy-sequence tooltip-frame-parameters)) - (fg (face-attribute (or frame-face 'tooltip) :foreground)) - (bg (face-attribute (or frame-face 'tooltip) :background))) + (fg (face-attribute (or default-face 'tooltip) :foreground)) + (bg (face-attribute (or default-face 'tooltip) :background))) (when (stringp fg) (setf (alist-get 'foreground-color params) fg) (setf (alist-get 'border-color params) fg)) -- 2.39.2