From 96d5d6a7454f4e35860dc3d93cb3a447263859d7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 May 2026 17:17:53 -0500 Subject: refactor(prog-lsp): replace obsolete lsp-eldoc-hook lsp-mode 9.0.0 made `lsp-eldoc-hook' an obsolete alias for Emacs's `eldoc-documentation-functions', and `lsp-managed-mode' already adds `lsp-eldoc-function' to that buffer-local hook. Dropped the obsolete `(setq lsp-eldoc-hook nil)'. `cj/lsp--disable-eldoc-hover' now removes `lsp-eldoc-function' from the buffer-local `eldoc-documentation-functions' via `lsp-managed-mode-hook', which clears the obsolete-variable byte-compile warning. Tests cover the hook removal, leaving the default `eldoc-documentation-functions' value alone, and the module no longer naming `lsp-eldoc-hook'. --- ...test-prog-lsp--add-file-watch-ignored-extras.el | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/test-prog-lsp--add-file-watch-ignored-extras.el b/tests/test-prog-lsp--add-file-watch-ignored-extras.el index 255832e4..6213b58c 100644 --- a/tests/test-prog-lsp--add-file-watch-ignored-extras.el +++ b/tests/test-prog-lsp--add-file-watch-ignored-extras.el @@ -16,6 +16,10 @@ ;; activates lsp-mode. In the test environment, this stub provides the value ;; cell `add-to-list' needs. (defvar lsp-file-watch-ignored-directories nil) +(defvar eldoc-documentation-functions nil) + +(defun lsp-eldoc-function (&rest _args) + "Stub lsp-mode Eldoc function for tests.") (require 'prog-lsp) @@ -83,5 +87,29 @@ (should-error (cj/lsp--add-file-watch-ignored-extras) :type 'wrong-type-argument))) +(ert-deftest test-prog-lsp--disable-eldoc-hover-removes-lsp-provider-locally () + "Normal: remove lsp-mode's Eldoc provider from the buffer-local hook." + (with-temp-buffer + (setq-local eldoc-documentation-functions + '(lsp-eldoc-function eldoc-documentation-default)) + (cj/lsp--disable-eldoc-hover) + (should-not (memq #'lsp-eldoc-function eldoc-documentation-functions)) + (should (memq 'eldoc-documentation-default eldoc-documentation-functions)))) + +(ert-deftest test-prog-lsp--disable-eldoc-hover-does-not-touch-default-value () + "Boundary: disabling LSP Eldoc in one buffer leaves the default hook alone." + (let ((eldoc-documentation-functions '(lsp-eldoc-function))) + (with-temp-buffer + (setq-local eldoc-documentation-functions '(lsp-eldoc-function)) + (cj/lsp--disable-eldoc-hover) + (should-not (memq #'lsp-eldoc-function eldoc-documentation-functions))) + (should (memq #'lsp-eldoc-function eldoc-documentation-functions)))) + +(ert-deftest test-prog-lsp--module-no-obsolete-lsp-eldoc-hook-reference () + "Regression: prog-lsp should not reference obsolete `lsp-eldoc-hook'." + (with-temp-buffer + (insert-file-contents (expand-file-name "modules/prog-lsp.el" user-emacs-directory)) + (should-not (re-search-forward "\\_" nil t)))) + (provide 'test-prog-lsp--add-file-watch-ignored-extras) ;;; test-prog-lsp--add-file-watch-ignored-extras.el ends here -- cgit v1.2.3