From: João Távora Date: Sat, 1 Jul 2023 21:46:43 +0000 (+0100) Subject: Eglot: improve heuristic to highlight function names in signatures X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=03d4ca6f6ba39389e5742e392dc557220d330e0e;p=emacs.git Eglot: improve heuristic to highlight function names in signatures * lisp/progmodes/eglot.el (eglot--sig-info): Rework. See https://github.com/joaotavora/eglot/discussions/1251. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e2478f2dde3..94ca5c94245 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3196,11 +3196,8 @@ for which LSP on-type-formatting should be requested." ((:documentation sigdoc)) parameters activeParameter) sig (with-temp-buffer - (save-excursion (insert siglabel)) - ;; Ad-hoc attempt to parse label as () - (when (looking-at "\\([^(]*\\)(\\([^)]+\\))") - (add-face-text-property (match-beginning 1) (match-end 1) - 'font-lock-function-name-face)) + (insert siglabel) + ;; Ad-hoc attempt to parse label as () ;; Add documentation, indented so we can distinguish multiple signatures (when-let (doc (and (not briefp) sigdoc (eglot--format-markup sigdoc))) (goto-char (point-max)) @@ -3213,8 +3210,13 @@ for which LSP on-type-formatting should be requested." ((:label parlabel)) ((:documentation pardoc))) parameter + (when (zerop i) + (goto-char (elt parlabel 0)) + (search-backward "(" nil t) + (add-face-text-property (point-min) (point) + 'font-lock-function-name-face)) ;; ...perhaps highlight it in the formals list - (when (and (eq i active-param)) + (when (= i active-param) (save-excursion (goto-char (point-min)) (pcase-let