diff --git a/doc/racket-mode.org b/doc/racket-mode.org index 35095b67..71e46300 100644 --- a/doc/racket-mode.org +++ b/doc/racket-mode.org @@ -368,15 +368,15 @@ You can customize where the REPL buffer is displayed by adding an item to the Em Various modes add local hooks to ~eldoc-documentation-functions~. -- ~racket-xp-mode~ adds hooks to document the identifier at point, show the help-echo at point, and to document identifier in an apparent s-expression application head position. The identifiers are documented from check-syntax annotations. The customization variable ~racket-xp-eldoc-full-docs~ to choose full documentation or just "bluebox" signatures. +- ~racket-xp-mode~ adds hooks to document the identifiers at point and at an apparent s-expression application head position. The identifiers are documented from check-syntax annotations. The customization variable ~racket-xp-eldoc-full-docs~ to choose full documentation or just "bluebox" signatures. -- ~racket-repl-mode~ adds hooks to describe the namespace identifer at point and in an apparent s-expression application head position. The description is a signature from surface syntax, or a Typed Racket type, or a bluebox for the namespace identifier. +- ~racket-repl-mode~ adds hooks to describe the namespace identifers at point and at an apparent s-expression application head position. The description is a signature from surface syntax, or a Typed Racket type, or a "bluebox" for the namespace identifier. Note: Racket Mode does not support the "old" eldoc API that uses ~eldoc-documentation-function~, singular. Also, ~eldoc-documentation-strategy~ is set to ~racket-eldoc-compose-unique~, which is like ~eldoc-documentation-default~ but filters duplicate values -- useful when point is at an application head position. -Some people use the third-party package ~eldoc-box~ to show information in a child frame (like a "tooltip") instead of the echo area. This is particularly useful when showing full documentation. +Some people use the third-party package ~eldoc-box~ to show information in a child frame instead of the echo area. ** Start faster diff --git a/doc/racket-mode.texi b/doc/racket-mode.texi index ad3048d1..73c83e7b 100644 --- a/doc/racket-mode.texi +++ b/doc/racket-mode.texi @@ -826,16 +826,18 @@ Various modes add local hooks to @code{eldoc-documentation-functions}. @itemize @item -@code{racket-eldoc-app} looks for function/macro application and returns information such as a signature or type. Added by @code{racket-mode}, @code{racket-repl-mode}, and @code{racket-hash-lang-mode} when the hash-lang appears to use s-expressions. Keep in mind that, because Racket is not a ``doc string'' system, these summaries are impoverished compared to the documentation you get from @ref{racket-xp-describe} or @ref{racket-xp-documentation}. +@code{racket-xp-mode} adds hooks to document the identifiers at point and at an apparent s-expression application head position. The identifiers are documented from check-syntax annotations. The customization variable @code{racket-xp-eldoc-full-docs} to choose full documentation or just ``bluebox'' signatures. @item -@code{racket-xp-eldoc-help-echo} returns help-echo information added by @code{racket-xp-mode} from check-syntax annotations. This is lower precedence; @code{eldoc-documentation-strategy} determines whether or not it will be displayed. +@code{racket-repl-mode} adds hooks to describe the namespace identifers at point and at an apparent s-expression application head position. The description is a signature from surface syntax, or a Typed Racket type, or a ``bluebox'' for the namespace identifier. @end itemize -Some people use the third-party package @code{eldoc-box} to show information in a child frame (like a ``tooltip'') instead of the echo area. - Note: Racket Mode does not support the ``old'' eldoc API that uses @code{eldoc-documentation-function}, singular. +Also, @code{eldoc-documentation-strategy} is set to @code{racket-eldoc-compose-unique}, which is like @code{eldoc-documentation-default} but filters duplicate values -- useful when point is at an application head position. + +Some people use the third-party package @code{eldoc-box} to show information in a child frame instead of the echo area. + @node Start faster @section Start faster diff --git a/racket-eldoc.el b/racket-eldoc.el index 2e5c0b8c..65312680 100644 --- a/racket-eldoc.el +++ b/racket-eldoc.el @@ -12,7 +12,7 @@ "Like `eldoc-documentation-compose', but filter redundant results. A value for `eldoc-documentation-strategy', which is more -suitable because supply eldoc info for both point and the +suitable because we supply eldoc info for both point and the application position, so when point is on the latter, they are redundant." (let* ((ord 0) @@ -40,9 +40,7 @@ redundant." (defun racket--eldoc-do-callback (callback thing str) (if str (funcall callback - (concat (when (string-match-p "\n" str) - "\n") - str) + str :thing thing :face 'font-lock-function-name-face) (funcall callback ""))) diff --git a/racket-repl.el b/racket-repl.el index 28f92337..56d359c2 100644 --- a/racket-repl.el +++ b/racket-repl.el @@ -1240,7 +1240,11 @@ the surface syntax, or Typed Racket type information." (racket--repl-session-id) `(type namespace ,thing) (lambda (str) - (racket--eldoc-do-callback callback thing str))) + (racket--eldoc-do-callback callback + thing + (if (and str (string-match-p "\n" str)) + (concat "\n" str) + str)))) t)))) (defun racket-repl-eldoc-function () diff --git a/racket-xp.el b/racket-xp.el index 44a4c520..e38e8082 100644 --- a/racket-xp.el +++ b/racket-xp.el @@ -297,9 +297,6 @@ commands directly to whatever keys you prefer. nil t) (add-hook 'eldoc-documentation-functions #'racket-xp-eldoc-point - nil t) - (add-hook 'eldoc-documentation-functions - #'racket-xp-eldoc-help-echo nil t))) (t (racket-show nil) @@ -322,8 +319,7 @@ commands directly to whatever keys you prefer. #'racket-xp-pre-redisplay t) (when (boundp 'eldoc-documentation-functions) - (dolist (hook (list #'racket-xp-eldoc-help-echo - #'racket-xp-eldoc-sexp-app + (dolist (hook (list #'racket-xp-eldoc-sexp-app #'racket-xp-eldoc-point)) (remove-hook 'eldoc-documentation-functions hook @@ -615,24 +611,6 @@ point." ;; remove only those. 'font-lock-face nil))))) -(defun racket-xp-eldoc-help-echo (callback &rest _more) - "Show help-echo property at point. - -By default this is /appended/ to `eldoc-documentation-functions', -therefore will have an effect only when the variable -`eldoc-documentation-strategy' is a value that composes more than -one function. - -By default `racket-xp-mode' also shows help-echo strings using -the `racket-show-functions' mechanism. You may set that to -`ignore' if you get help-echo strings displayed both ways." - (when-let (str (get-text-property (point) 'help-echo)) - (funcall callback - str - :thing (thing-at-point 'symbol t) - :face 'font-lock-variable-name-face) - t)) - (defun racket-xp-eldoc-point (callback &rest _more) "Call eldoc CALLBACK about the identifier at point. First look for doc text property added by `racket-xp-mode'. @@ -661,20 +639,32 @@ HOW and REPL-SESSION-ID are used." (point) (previous-single-property-change (point) 'racket-xp-doc))) (end (next-single-property-change (point) 'racket-xp-doc)) - (thing (buffer-substring-no-properties beg end))) + (thing (buffer-substring-no-properties beg end)) + (help-echo (if-let (s (get-text-property (point) 'help-echo)) + (concat s "\n") + ""))) (if racket-xp-eldoc-full-docs (racket--eldoc-do-callback callback thing - (with-temp-buffer - (racket--scribble-path+anchor-insert path anchor) - (buffer-string))) + (concat + help-echo + (with-temp-buffer + (racket--scribble-path+anchor-insert path anchor) + (buffer-string)))) (racket--cmd/async nil `(bluebox ,tag) (lambda (str) - (racket--eldoc-do-callback callback thing str)))) - t)))) + (racket--eldoc-do-callback callback + thing + (concat help-echo str))))) + t)) + (_ (when-let (str (get-text-property (point) 'help-echo)) + (racket--eldoc-do-callback callback + (thing-at-point 'symbol t) + str) + t)))) (defun racket-xp-eldoc-function () "A value for the obsolete variable `eldoc-documentation-function'.