Subject: [PATCH] New Eldoc function `help-at-pt-eldoc-function'

From: Daniel Mendler <[email-masked]>
Date: Sat, 22 Mar 2025 10:40:18 +0100

Tags: patch

This patch proposes the addition of a new Eldoc function
`help-at-pt-eldoc-function'.

Show help-at-pt string via Eldoc as an alternative to the
`help-at-pt-display-when-idle' timer.  The help-at-pt timer competes
with Eldoc for the echo area, such that using both does not work well.
The new `help-at-pt-eldoc-function' is meant to be added to
`eldoc-documentation-functions'.

>From d3d2717d98e82ec2ac80054a08d8e7b5d215f0e4 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <[email-masked]>
Date: Sat, 22 Mar 2025 10:29:45 +0100
Subject: [PATCH] New Eldoc function `help-at-pt-eldoc-function'

Show help-at-pt string via Eldoc as an alternative to the
`help-at-pt-display-when-idle' timer.  The help-at-pt timer competes
with Eldoc for the echo area, such that using both does not work well.

The new `help-at-pt-eldoc-function' is meant to be added to
`eldoc-documentation-functions':

(add-to-list 'eldoc-documentation-functions 'help-at-pt-eldoc-function)

* lisp/help-at-pt.el (help-at-pt-eldoc-function): New Eldoc function.

* TODO: Should the new function be added to
`eldoc-documentation-functions' by default, such that tooltip messages
are automatically shown in the echo area when moving point over text
with the `help-echo' property or overlay?
* TODO: Should the `help-at-pt-timer' mechanism be deprecated in favor
of Eldoc?
---
 lisp/help-at-pt.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/help-at-pt.el b/lisp/help-at-pt.el
index 68054016dc5..6a266114610 100644
--- a/lisp/help-at-pt.el
+++ b/lisp/help-at-pt.el
@@ -81,6 +81,13 @@ help-at-pt-kbd-string
 	(echo (help-at-pt-string)))
     (if (and kbd (not (eq kbd t))) kbd echo)))
 
+;;;###autoload
+(defun help-at-pt-eldoc-function (&rest _)
+  "Show help at point via Eldoc.
+Intended for `eldoc-documentation-functions' (which see)."
+  (when-let* ((help (help-at-pt-kbd-string)))
+    (format "Help: %s" (substitute-command-keys help))))
+
 (declare-function widget-describe "wid-edit" (&optional widget-or-pos))
 (declare-function widget-at "wid-edit" (&optional pos))
 
-- 
2.47.2