branch: externals/embark
commit 69139c07cb92f5b51f0c36b569ec00ea4bcbed32
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Add embark-eldoc-function (Fix #599)
---
 embark.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/embark.el b/embark.el
index f9c8165b91..456079e3f6 100644
--- a/embark.el
+++ b/embark.el
@@ -992,6 +992,15 @@ If CYCLE is non-nil bind `embark-cycle'."
       (concat (car (split-string target "\n" 'omit-nulls "\\s-*")) "…")
     target))
 
+(defun embark-eldoc-function (report &rest _)
+  "Eldoc function reporting the target at point via the REPORT callback.
+This function can be added to `eldoc-documentation-functions'."
+  (when-let ((target (car (embark--targets))))
+    (funcall report
+             (format "Embark on %s ‘%s’"
+                     (plist-get target :type)
+                     (embark--truncate-target (plist-get target :target))))))
+
 (defun embark--format-targets (target shadowed-targets rep)
   "Return a formatted string indicating the TARGET of an action.
 
@@ -1022,7 +1031,7 @@ a repeating sequence of actions."
               (plist-get target :multi)
               (plist-get target :type)))
      (t (format
-         "%s on %s%s '%s'"
+         "%s on %s%s ‘%s’"
          act
          (plist-get target :type)
          (if shadowed-targets
@@ -2427,6 +2436,7 @@ point."
          (command-execute command))))))
 
 (defmacro embark-define-keymap (&rest _)
+  "Obsolete macro, use `defvar-keymap' instead."
   (error "`embark-define-keymap' has been deprecated in Embark 0.21.
 Use standard methods for defining keymaps, such as `defvar-keymap'.
 Remember to make `embark-general-map' the parent if appropriate"))

Reply via email to