unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "João Távora" <joaotavora@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: scratch/backend-completion c807121fbd 1/2: Add lisp/backend-completion.el
Date: Tue, 29 Nov 2022 18:44:47 -0500	[thread overview]
Message-ID: <jwv1qplpc28.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87a649qsef.fsf@gmail.com> ("João Távora"'s message of "Tue, 29 Nov 2022 22:59:04 +0000")

> OK great.  But where do you plug the current eglot functions into it.

Something like the patch below?

> Maybe.  As I've often told you, all this completion code is hard to
> grasp.  I do "get" it somewhat, and I've been working with it intensely
> for a long time.  But also, I don't really get it :-) For example, I
> have no solid concept of what a category or a style is, so everything
> just reads like "an indirection from this thing to that other thing".

Some sets of identifiers are designed to play well with prefix
completion, while others are a very poor fit.

The "category" is a loose way to describe to users what kind of "sets of
identifiers" this is completing so users can customize the behavior for
specific cases.

> So I named this thing 'eglot-indirection' . 'eglot-code' may be logical
> for someone who knows what a category means, now but sounds something
> that will make absolutely no sense to me 2 weeks from now.

The `category` should be a name that describe the "kind of thing this
inserts/selects by completion".


        Stefan


diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e1041666754..d88c6b78dc7 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2571,7 +2571,7 @@ eglot--workspace-symbols
                   (let ((probe (gethash pat cache :missing)))
                     (if (eq probe :missing) (puthash pat (refresh pat) cache)
                       probe)))
-                (lookup (pat)
+                (lookup (pat _point)
                   (let ((res (lookup-1 pat))
                         (def (and (string= pat "") (gethash :default cache))))
                     (append def res nil)))
@@ -2579,16 +2579,13 @@ eglot--workspace-symbols
                   (cl-getf (get-text-property
                             0 'eglot--lsp-workspaceSymbol c)
                            :score 0)))
-      (lambda (string _pred action)
-        (pcase action
-          (`metadata `(metadata
-                       (cycle-sort-function
+      (backend-completion-table
+       (lambda (string point) `(,string . ,point))
+       #'lookup
+       'eglot-indirection-joy
+       `((cycle-sort-function
                         . ,(lambda (completions)
-                             (cl-sort completions #'> :key #'score)))
-                       (category . eglot-indirection-joy)))
-          (`(eglot--lsp-tryc . ,point) `(eglot--lsp-tryc . (,string . ,point)))
-          (`(eglot--lsp-allc . ,_point) `(eglot--lsp-allc . ,(lookup string)))
-          (_ nil))))))
+                             (cl-sort completions #'> :key #'score))))))))
 
 (defun eglot--recover-workspace-symbol-meta (string)
   "Search `eglot--workspace-symbols-cache' for rich entry of STRING."
@@ -2600,7 +2597,7 @@ eglot--recover-workspace-symbol-meta
                  (setq v (cdr v))))
              eglot--workspace-symbols-cache)))
 
-(add-to-list 'completion-category-overrides
+(add-to-list 'completion-category-defaults
              '(eglot-indirection-joy (styles . (eglot--lsp-backend-style))))
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql eglot)))




  reply	other threads:[~2022-11-29 23:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <166938157708.15020.14294469350904271113@vcs2.savannah.gnu.org>
     [not found] ` <20221125130621.A3C14C0E4C1@vcs2.savannah.gnu.org>
2022-11-25 15:50   ` scratch/backend-completion c807121fbd 1/2: Add lisp/backend-completion.el Stefan Monnier
2022-11-25 16:28     ` João Távora
2022-11-29 21:18       ` Stefan Monnier
2022-11-29 22:59         ` João Távora
2022-11-29 23:44           ` Stefan Monnier [this message]
2022-12-03 13:21             ` João Távora
2022-12-03 14:04               ` Stefan Monnier
2022-12-03 23:22                 ` João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1qplpc28.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).