emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elpa ac9239b 46/71: Fix small problems around Eglot's h


From: João Távora
Subject: [elpa] externals/elpa ac9239b 46/71: Fix small problems around Eglot's help buffer
Date: Wed, 16 Dec 2020 11:42:23 -0500 (EST)

branch: externals/elpa
commit ac9239bed5e3bfbf057382d1a75cdfa23f2caddd
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Fix small problems around Eglot's help buffer
    
    Specifically:
    
    - correctly format the message shown to the user about doc being truncated
    - don't show message if the buffer is showing in some frame's window
    - correctly name the help buffer switched to with `C-h .'.
    
    This is still not ideal:
    
    - When the `C-h .' suggestion is shown to the user, typing that keybinding
      shouldn't result in a new LSP request to fetch probably the same info;
    - All this functionality belongs in eldoc.el.
    
    * eglot.el (eglot-help-at-point): Fix buffer name.
    (eglot--update-doc): Provide more help.
---
 eglot.el | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/eglot.el b/eglot.el
index 4b25368..733b69c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2270,12 +2270,12 @@ is not active."
       (jsonrpc-request (eglot--current-server-or-lose) :textDocument/hover
                        (eglot--TextDocumentPositionParams))
     (let ((blurb (and (not (seq-empty-p contents))
-                      (eglot--hover-info contents range))))
+                      (eglot--hover-info contents range)))
+          (hint (thing-at-point 'symbol)))
       (if blurb
           (with-current-buffer (eglot--help-buffer)
             (with-help-window (current-buffer)
-              (rename-buffer (format "*eglot-help for %s*"
-                                     (thing-at-point 'symbol)))
+              (rename-buffer (format "*eglot-help for %s*" hint))
               (with-current-buffer standard-output (insert blurb))
               (setq-local nobreak-char-display nil)))
         (display-local-help)))))
@@ -2350,16 +2350,18 @@ documentation.  Honour `eglot-put-doc-in-help-buffer',
                (erase-buffer)
                (insert string)
                (goto-char (point-min)))
-             (if eglot-auto-display-help-buffer
-                 (display-buffer (current-buffer))
-               (unless (get-buffer-window (current-buffer))
-                 ;; This prints two lines.  Should it print 1?  Or
-                 ;; honour max-mini-window-height?
-                 (eglot--message
-                  "%s\n(...truncated. Full help is in `%s')"
-                  (eglot--truncate-string string 1 (- (frame-width) 8))
-                  (buffer-name eglot--help-buffer))))
-             (help-mode))))
+             (help-mode)))
+         (if eglot-auto-display-help-buffer
+             (display-buffer eglot--help-buffer)
+           (unless (get-buffer-window eglot--help-buffer t)
+             ;; Hand-tweaked to print two lines.  Should it print
+             ;; 1?  Or honour max-mini-window-height?
+             (eglot--message
+              "%s\n(Truncated, %sfull help in buffer %s)"
+              (eglot--truncate-string string 1 (- (frame-width) 9))
+              (if-let (key (car (where-is-internal 'eglot-help-at-point)))
+                  (format "use %s to see " (key-description key)) "")
+              (buffer-name eglot--help-buffer)))))
         ((eq eldoc-echo-area-use-multiline-p t)
          (if-let ((available (eglot-doc-too-large-for-echo-area string)))
              (eldoc-message (eglot--truncate-string string available))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]