xref-find-by-kind 96ac91f6276: xref-backend-xrefs-by-kind: Cleanup the intermediate buffer
Dmitry Gutov <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: xref-find-by-kind commit 96ac91f6276c9d6f7464078ec890f6f1c5716372 Author: Dmitry Gutov <[email protected]> Commit: Dmitry Gutov <[email protected]> xref-backend-xrefs-by-kind: Cleanup the intermediate buffer * lisp/progmodes/eglot.el (xref-backend-xrefs-by-kind): Cleanup the intermediate buffer if previously non-existent. --- lisp/progmodes/eglot.el | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 94546d729a2..0e526631697 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3854,20 +3854,23 @@ If BUFFER, switch to it before." (get-text-property 0 'eglot--lsp-workspaceSymbol probe) (eglot--dbind ((Location) uri range) location (let* ((match (eglot--xref-make-match name uri range)) - (loc (xref-match-item-location match))) + (loc (xref-match-item-location match)) + (bl (buffer-list))) (save-current-buffer - ;; TODO: Clean up the buffer afterwards if it didn't exist - ;; before this lookup. - (xref--goto-location loc) - (when (eglot-current-server) - ;; Only works if the definition buffer is "managed", - ;; unfortunately. Querying non-expecting server is - ;; likely to error with something like - ;; "trying to get AST for non-added document" - ;; But `eglot-extend-to-xref' can help. - (xref-backend-xrefs-by-kind 'eglot - "LSP identifier at point" - kind))))))))) + (unwind-protect + (progn + (xref--goto-location loc) + (when (eglot-current-server) + ;; Only works if the definition buffer is "managed", + ;; unfortunately. Querying non-expecting server is + ;; likely to error with something like + ;; "trying to get AST for non-added document" + ;; But `eglot-extend-to-xref' can help. + (xref-backend-xrefs-by-kind 'eglot + "LSP identifier at point" + kind))) + (unless (memq (current-buffer) bl) + (kill-buffer)))))))))) ;;; Eglot interactive commands and helpers