[slime-devel] semantic indentation

Helmut Eller heller at common-lisp.net
Wed Aug 1 17:53:07 UTC 2012

On Wed, Aug 01 2012, Evrim Ulu wrote:

> Hello,
> Ok, no problem, let's assume the symbol is interned on only a single package.
> I've modified symbol-indentation (symbol) function to return something
> else on some specific symbols.
> Yet, i cannot make the indentation work.
> My answer is probably there, yet I dont know which value to set:
> (put 'my-symbol 'common-lisp-indent-function ..??)
> http://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html#Indenting-Macros

It seems that you want to indent like so

(html :attr1 val1 
      :attr2 val2
  (body  ...))

I'm not aware of a standard indentation function that does that, but you
can write your own.  E.g.:

(put 'html 'common-lisp-indent-function 'my-html-indent)

(defun my-html-indent (path state indent-point sexp-column normal-indent)
  (let* ((pos (car path))
	 (start (elt state 1))
	 (attrs (my-html-indent-count-attributes start (point))))
    (cond ((> pos attrs)
	   (+ sexp-column 1))

(defun my-html-indent-count-attributes (start end)
    (goto-char start)
      (narrow-to-region (point) end)
      (forward-sexp 1)
      (let ((count 0))
	(while (progn
		 (skip-chars-forward " \t\n")
		 (looking-at "[^() \n]"))
	  (incf count)
	  (forward-sexp 1))

More information about the slime-devel mailing list