]> git.eshelyaron.com Git - emacs.git/commitdiff
Use bounds of thing at point when asking for code actions
authorJoão Távora <joaotavora@gmail.com>
Thu, 24 Mar 2022 16:06:08 +0000 (16:06 +0000)
committerJoão Távora <joaotavora@gmail.com>
Thu, 24 Mar 2022 16:06:08 +0000 (16:06 +0000)
* eglot.el (eglot--region-bounds): Consider bounds of things at
point.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/895

lisp/progmodes/eglot.el

index daf6c3e23769148fbe87f94f967158fff4812d71..83a29455147eeef9052a4ded8ab898422fe4c2f2 100644 (file)
@@ -2838,8 +2838,11 @@ is not active."
                                            :newName ,newname))
    current-prefix-arg))
 
-(defun eglot--region-bounds () "Region bounds if active, else point and nil."
-  (if (use-region-p) `(,(region-beginning) ,(region-end)) `(,(point) nil)))
+(defun eglot--region-bounds ()
+  "Region bounds if active, else bounds of things at point."
+  (if (use-region-p) `(,(region-beginning) ,(region-end))
+    (let ((boftap (bounds-of-thing-at-point 'sexp)))
+      (list (car boftap) (cdr boftap)))))
 
 (defun eglot-code-actions (beg &optional end action-kind)
   "Offer to execute actions of ACTION-KIND between BEG and END.