forked from cxxxr/cl-lsp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswank.lisp
65 lines (55 loc) · 2 KB
/
swank.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(defpackage :cl-lsp/swank
(:use :cl)
(:export :swank-init
:fuzzy-completions
:describe-symbol
:xrefs
:operator-arglist
:find-definitions
:swank-apropos-list
:swank-compile-file))
(in-package :cl-lsp/swank)
(defvar *fuzzy-completions* nil)
(defmacro with-swank ((&key (package (find-package "CL-USER"))
(readtable '*readtable*))
&body body)
`(let ((swank::*buffer-package* ,package)
(swank::*buffer-readtable* ,readtable))
,@body))
(defun swank-init ()
(swank:swank-require '("SWANK-TRACE-DIALOG"
"SWANK-PACKAGE-FU"
"SWANK-PRESENTATIONS"
"SWANK-FUZZY"
"SWANK-FANCY-INSPECTOR"
"SWANK-C-P-C"
"SWANK-ARGLISTS"
"SWANK-REPL"))
(setf *fuzzy-completions* (intern "FUZZY-COMPLETIONS" :SWANK))
(values))
(defun fuzzy-completions (string package)
(with-swank ()
(funcall *fuzzy-completions*
string package)))
(defun describe-symbol (symbol-name package)
(ignore-errors
(with-swank (:package package)
(swank:describe-symbol symbol-name))))
(defun xrefs (name package)
(with-swank (:package package)
(swank:xrefs '(:calls :macroexpands :binds :references :sets :specializes)
name)))
(defun operator-arglist (symbol-string package)
(swank:operator-arglist symbol-string package))
(defun find-definitions (name package)
(multiple-value-bind (symbol found)
(with-swank (:package package)
(swank::find-definitions-find-symbol-or-package name))
(when found
(ignore-errors (swank::find-definitions symbol)))))
(defun swank-apropos-list (name package)
(with-swank (:package package)
(mapcar #'cadr (swank:apropos-list-for-emacs name))))
(defun swank-compile-file (filename loadp)
(with-swank ()
(swank:compile-file-for-emacs filename loadp)))