emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 65ea742ed5e: Eglot: try even harder to avoid other completion sty


From: João Távora
Subject: master 65ea742ed5e: Eglot: try even harder to avoid other completion styles (bug#68699)
Date: Wed, 24 Jan 2024 20:38:18 -0500 (EST)

branch: master
commit 65ea742ed5ec505837706d64690e3cc2073825c7
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Eglot: try even harder to avoid other completion styles (bug#68699)
    
    Any completion style except for eglot--dumb-flex spells trouble for
    Eglot, for the well known reason that LSP is geared towards completion
    tooltips and none of Emacs' partial-completion shenanigans.
    
    This commit puts a "try-completion" function that doesn't return nil
    in the eglot--dumb-flex completion style so that other styles aren't
    tried (partial-completion, in particular, errors out).
    
    The function often doesn't do anything very useful, but at least it
    doesn't stop the more usual *Completions* buffer from appearing.
    
    * lisp/progmodes/eglot.el (eglot--dumb-tryc): New helper.
    (completion-styles-alist): Add it to the dumb-flex style.
---
 lisp/progmodes/eglot.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 511000927cf..c5fbf5eb9d5 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3060,9 +3060,13 @@ for which LSP on-type-formatting should be requested."
            finally (cl-return comp)))
 
 (defun eglot--dumb-allc (pat table pred _point) (funcall table pat pred t))
+(defun eglot--dumb-tryc (pat table pred point)
+  (if-let ((probe (funcall table pat pred nil)))
+      (cons probe (length probe))
+    (cons pat point)))
 
 (add-to-list 'completion-category-defaults '(eglot-capf (styles 
eglot--dumb-flex)))
-(add-to-list 'completion-styles-alist '(eglot--dumb-flex ignore 
eglot--dumb-allc))
+(add-to-list 'completion-styles-alist '(eglot--dumb-flex eglot--dumb-tryc 
eglot--dumb-allc))
 
 (defun eglot-completion-at-point ()
   "Eglot's `completion-at-point' function."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]