From: João Távora Date: Sun, 3 May 2020 20:10:05 +0000 (+0100) Subject: Remap display-local-help (c-h .) to eglot-help-at-point X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~227 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a2af2e126817cff818d8d56ceb6c689cd7fb025d;p=emacs.git Remap display-local-help (c-h .) to eglot-help-at-point * eglot.el (eglot-help-at-point): Fallback to display-local-help if no hover doc (eglot-mode-map): Remap display-local-help to eglot-help-at-point.. GitHub-reference: per https://github.com/joaotavora/eglot/issues/437 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 09be1f8dc61..8fadd5f7ab3 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1238,7 +1238,10 @@ and just return it. PROMPT shouldn't end with a question mark." ;;; Minor modes ;;; -(defvar eglot-mode-map (make-sparse-keymap)) +(defvar eglot-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [remap display-local-help] 'eglot-help-at-point) + map)) (defvar-local eglot--current-flymake-report-fn nil "Current flymake report function for this buffer") @@ -2247,19 +2250,20 @@ is not active." (setq eglot--help-buffer (generate-new-buffer "*eglot-help*")))) (defun eglot-help-at-point () - "Request \"hover\" information for the thing at point." + "Request documentation for the thing at point." (interactive) (eglot--dbind ((Hover) contents range) (jsonrpc-request (eglot--current-server-or-lose) :textDocument/hover (eglot--TextDocumentPositionParams)) - (when (seq-empty-p contents) (eglot--error "No hover info here")) - (let ((blurb (eglot--hover-info contents range)) - (sym (thing-at-point 'symbol))) - (with-current-buffer (eglot--help-buffer) - (with-help-window (current-buffer) - (rename-buffer (format "*eglot-help for %s*" sym)) - (with-current-buffer standard-output (insert blurb)) - (setq-local nobreak-char-display nil)))))) + (if (seq-empty-p contents) + (display-local-help) + (let ((blurb (eglot--hover-info contents range)) + (sym (thing-at-point 'symbol))) + (with-current-buffer (eglot--help-buffer) + (with-help-window (current-buffer) + (rename-buffer (format "*eglot-help for %s*" sym)) + (with-current-buffer standard-output (insert blurb)) + (setq-local nobreak-char-display nil))))))) (defun eglot-doc-too-large-for-echo-area (string) "Return non-nil if STRING won't fit in echo area.