diff options
author | Daniel Mendler <mail@daniel-mendler.de> | 2022-04-02 02:19:54 +0200 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-04-23 16:01:15 +0100 |
commit | 18faa0ba32c9ce751c16960b2a39b3880b523272 (patch) | |
tree | de834f9eccbe390421c495844b48af9ba8565a2d /elisp/geiser-completion.el | |
parent | 77adf19d3812ecfd821d250f8bc1eb821a88ee92 (diff) | |
download | geiser-18faa0ba32c9ce751c16960b2a39b3880b523272.tar.gz geiser-18faa0ba32c9ce751c16960b2a39b3880b523272.tar.bz2 |
Suggestive patch for simplified completion
NOTE: The patch is largely untested.
Modifications:
- Update readme.org
- Remove geiser-company
- Move Company extensions to geiser-completion
Omissions:
- geiser-company--inhibit-autodoc has been removed. Eldoc handling
should be implemented in the frontend, not in the backend.
See for example:
https://github.com/minad/corfu/blob/04fbfce3d7e9c125a7fd22a34455a508247a522b/corfu.el#L1212
- The quickhelp-string action and geiser-company--docstring have been
removed. company-quickhelp can use `:company-doc-buffer` instead with
minimal overhead.
See:
https://github.com/company-mode/company-quickhelp/blob/3ca2708b4e5190205aca01d65fe1b391963a53f9/company-quickhelp.el#L138
- The automatic Company setup has been removed. Personally I am not a
fan of such auto configuration. It is better if completion is
configured consistently in the user configuration. You may want to
restore the auto configuration for backward compatibility. It depends
on your backward compatibility story. I am fine with rare breaking
changes from time to time.
- There is a cyclic dependency between geiser-edit/geiser-doc and
geiser-completion, which should be untangled.
Diffstat (limited to 'elisp/geiser-completion.el')
-rw-r--r-- | elisp/geiser-completion.el | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el index 9943030..7696ec5 100644 --- a/elisp/geiser-completion.el +++ b/elisp/geiser-completion.el @@ -17,6 +17,8 @@ (require 'geiser-log) (require 'geiser-syntax) (require 'geiser-base) +;; (require 'geiser-edit) TODO untangle cyclic dependency +;; (require 'geiser-doc) TODO untangle cyclic dependency (require 'comint) (require 'minibuffer) @@ -132,6 +134,30 @@ we're looking for a module name.") (point))) (scan-error pos))))) +(defun geiser-completion--company-docsig (id) + (ignore-errors + (when (not (geiser-autodoc--inhibit)) + (let ((help (geiser-autodoc--autodoc `((,id 0))))) + (and help (substring-no-properties help)))))) + +(defun geiser-completion--company-doc-buffer (id) + (let* ((impl geiser-impl--implementation) + (module (geiser-eval--get-module)) + (symbol (make-symbol id)) + (ds (geiser-doc--get-docstring symbol module))) + (when (consp ds) + (with-current-buffer (get-buffer-create "*company-documentation*") + (geiser-doc--render-docstring ds symbol module impl) + (current-buffer))))) + +(defun geiser-completion--company-location (id) + (ignore-errors + (when (not (geiser-autodoc--inhibit)) + (let ((id (make-symbol id))) + (condition-case nil + (geiser-edit-module id 'noselect) + (error (geiser-edit-symbol id 'noselect))))))) + (defun geiser-completion--thing-at-point (module &optional predicate) (with-syntax-table scheme-mode-syntax-table (let* ((beg (geiser-completion--symbol-begin module)) @@ -142,7 +168,11 @@ we're looking for a module name.") (match-string 1 prefix) prefix))) (cmps (and prefix (geiser-completion--complete prefix module)))) - (and cmps (list beg end cmps))))) + (when cmps + (list beg end cmps + :company-docsig #'geiser-completion--company-docsig + :company-doc-buffer #'geiser-completion--company-doc-buffer + :company-location #'geiser-completion--company-location))))) (defun geiser-completion--for-symbol (&optional predicate) (geiser-completion--thing-at-point nil predicate)) |