summaryrefslogtreecommitdiff
path: root/elisp/geiser-company.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-04-02 02:19:54 +0200
committerjao <jao@gnu.org>2022-04-23 16:01:15 +0100
commit18faa0ba32c9ce751c16960b2a39b3880b523272 (patch)
treede834f9eccbe390421c495844b48af9ba8565a2d /elisp/geiser-company.el
parent77adf19d3812ecfd821d250f8bc1eb821a88ee92 (diff)
downloadgeiser-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-company.el')
-rw-r--r--elisp/geiser-company.el148
1 files changed, 0 insertions, 148 deletions
diff --git a/elisp/geiser-company.el b/elisp/geiser-company.el
deleted file mode 100644
index adc3654..0000000
--- a/elisp/geiser-company.el
+++ /dev/null
@@ -1,148 +0,0 @@
-;;; geiser-company.el -- integration with company-mode
-
-;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016 Jose Antonio Ortega Ruiz
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the Modified BSD License. You should
-;; have received a copy of the license along with this program. If
-;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>.
-
-;; Start date: Mon Aug 24, 2009 12:44
-
-
-;;; Code:
-
-(require 'geiser-autodoc)
-(require 'geiser-completion)
-(require 'geiser-edit)
-(require 'geiser-base)
-(require 'geiser-doc)
-
-(eval-when-compile (require 'cl-lib))
-
-
-;;; Helpers:
-
-(defvar-local geiser-company--enabled-flag nil)
-
-(defvar-local geiser-company--autodoc-flag nil)
-
-(defvar-local geiser-company--completions nil)
-
-(defun geiser-company--candidates (prefix)
- (and (equal prefix (car geiser-company--completions))
- (cdr geiser-company--completions)))
-
-(defun geiser-company--doc (id)
- (ignore-errors
- (when (not (geiser-autodoc--inhibit))
- (let ((help (geiser-autodoc--autodoc `((,id 0)) nil)))
- (and help (substring-no-properties help))))))
-
-(defun geiser-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)))
- (if (or (not ds) (not (listp ds)))
- (progn
- (message "No documentation available for '%s'" symbol)
- nil)
- (with-current-buffer (get-buffer-create "*company-documentation*")
- (geiser-doc--render-docstring ds symbol module impl)
- (current-buffer)))))
-
-(defun geiser-company--docstring (id)
- (let* ((module (geiser-eval--get-module))
- (symbol (make-symbol id))
- (ds (geiser-doc--get-docstring symbol module)))
- (and ds
- (listp ds)
- (concat (geiser-autodoc--str* (cdr (assoc "signature" ds)))
- "\n\n"
- (cdr (assoc "docstring" ds))))))
-
-(defun geiser-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-company--prefix-at-point ()
- (ignore-errors
- (when (and (not (geiser-autodoc--inhibit)) geiser-company--enabled-flag)
- (if (nth 8 (syntax-ppss)) 'stop
- (let* ((prefix (and (looking-at-p "\\_>")
- (geiser-completion--prefix nil)))
- (cmps1 (and prefix
- (geiser-completion--complete prefix nil)))
- (cmps2 (and prefix
- (geiser-completion--complete prefix t)))
- (mprefix (and (not cmps1) (not cmps2)
- (geiser-completion--prefix t)))
- (cmps3 (and mprefix (geiser-completion--complete mprefix t)))
- (cmps (or cmps3 (append cmps1 cmps2)))
- (prefix (or mprefix prefix)))
- (setq geiser-company--completions (cons prefix cmps))
- prefix)))))
-
-
-;;; Activation
-
-(defun geiser-company--setup (enable)
- (setq geiser-company--enabled-flag enable)
- (when (fboundp 'geiser-company--setup-company)
- (geiser-company--setup-company enable)))
-
-(defun geiser-company--inhibit-autodoc (ignored)
- (when (setq geiser-company--autodoc-flag geiser-autodoc-mode)
- (geiser-autodoc-mode -1)))
-
-(defun geiser-company--restore-autodoc (&optional ignored)
- (when geiser-company--autodoc-flag
- (geiser-autodoc-mode 1)))
-
-
-;;; Company activation
-
-(declare-function company-begin-backend "ext:company")
-(declare-function company-cancel "ext:company")
-(declare-function company-mode "ext:company")
-(defvar company-backends)
-(defvar company-active-map)
-(eval-after-load "company"
- '(progn
- (defun geiser-company-backend (command &optional arg &rest ignored)
- "A `company-mode' completion back-end for `geiser-mode'."
- (interactive (list 'interactive))
- (cl-case command
- ('interactive (company-begin-backend 'geiser-company-backend))
- ('prefix (geiser-company--prefix-at-point))
- ('candidates (geiser-company--candidates arg))
- ('meta (geiser-company--doc arg))
- ('doc-buffer (geiser-company--doc-buffer arg))
- ('quickhelp-string (geiser-company--docstring arg))
- ('location (geiser-company--location arg))
- ('sorted t)))
- (defun geiser-company--setup-company (enable)
- (when enable
- (set (make-local-variable 'company-backends)
- (add-to-list 'company-backends 'geiser-company-backend)))
- (company-mode (if enable 1 -1)))
- (add-hook 'company-completion-finished-hook
- 'geiser-company--restore-autodoc)
- (add-hook 'company-completion-cancelled-hook
- 'geiser-company--restore-autodoc)
- (add-hook 'company-completion-started-hook
- 'geiser-company--inhibit-autodoc)
- (define-key company-active-map (kbd "M-`")
- (lambda ()
- (interactive)
- (company-cancel)
- (call-interactively 'geiser-completion--complete-module)))))
-
-
-
-(provide 'geiser-company)