Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/slime/contrib/swank-indentation.lisp
990 views
1
(in-package :swank)
2
3
(defvar *application-hints-tables* '()
4
"A list of hash tables mapping symbols to indentation hints (lists
5
of symbols and numbers as per cl-indent.el). Applications can add hash
6
tables to the list to change the auto indentation slime sends to
7
emacs.")
8
9
(defun has-application-indentation-hint-p (symbol)
10
(let ((default (load-time-value (gensym))))
11
(dolist (table *application-hints-tables*)
12
(let ((indentation (gethash symbol table default)))
13
(unless (eq default indentation)
14
(return-from has-application-indentation-hint-p
15
(values indentation t))))))
16
(values nil nil))
17
18
(defun application-indentation-hint (symbol)
19
(let ((indentation (has-application-indentation-hint-p symbol)))
20
(labels ((walk (indentation-spec)
21
(etypecase indentation-spec
22
(null nil)
23
(number indentation-spec)
24
(symbol (symbol-name indentation-spec))
25
(cons (cons (walk (car indentation-spec))
26
(walk (cdr indentation-spec)))))))
27
(walk indentation))))
28
29
;;; override swank version of this function
30
(defun symbol-indentation (symbol)
31
"Return a form describing the indentation of SYMBOL.
32
33
The form is to be used as the `common-lisp-indent-function' property
34
in Emacs."
35
(cond
36
((has-application-indentation-hint-p symbol)
37
(application-indentation-hint symbol))
38
((and (macro-function symbol)
39
(not (known-to-emacs-p symbol)))
40
(let ((arglist (arglist symbol)))
41
(etypecase arglist
42
((member :not-available)
43
nil)
44
(list
45
(macro-indentation arglist)))))
46
(t nil)))
47
48