Path: blob/master/elisp/slime/contrib/swank-indentation.lisp
1490 views
(in-package :swank)12(defvar *application-hints-tables* '()3"A list of hash tables mapping symbols to indentation hints (lists4of symbols and numbers as per cl-indent.el). Applications can add hash5tables to the list to change the auto indentation slime sends to6emacs.")78(defun has-application-indentation-hint-p (symbol)9(let ((default (load-time-value (gensym))))10(dolist (table *application-hints-tables*)11(let ((indentation (gethash symbol table default)))12(unless (eq default indentation)13(return-from has-application-indentation-hint-p14(values indentation t))))))15(values nil nil))1617(defun application-indentation-hint (symbol)18(let ((indentation (has-application-indentation-hint-p symbol)))19(labels ((walk (indentation-spec)20(etypecase indentation-spec21(null nil)22(number indentation-spec)23(symbol (symbol-name indentation-spec))24(cons (cons (walk (car indentation-spec))25(walk (cdr indentation-spec)))))))26(walk indentation))))2728;;; override swank version of this function29(defun symbol-indentation (symbol)30"Return a form describing the indentation of SYMBOL.3132The form is to be used as the `common-lisp-indent-function' property33in Emacs."34(cond35((has-application-indentation-hint-p symbol)36(application-indentation-hint symbol))37((and (macro-function symbol)38(not (known-to-emacs-p symbol)))39(let ((arglist (arglist symbol)))40(etypecase arglist41((member :not-available)42nil)43(list44(macro-indentation arglist)))))45(t nil)))464748