I like to font-lock lambda
into λ
in my lisp buffers.
I do this with:
(defvar keyword-lambda
'(("(\\(lambda\\)\\>"
(0 (prog1 () (compose-region
(match-beginning 1)
(match-end 1) ?λ))))))
(font-lock-add-keywords 'emacs-lisp-mode keyword-lambda)
The character width of the symbol lambda
becomes 1, and indent-sexp
respects it,
however not in temp buffers it seems. Verify with C-u C-x C-e in an elisp buffer:
(insert
"\n"
(with-temp-buffer
(emacs-lisp-mode)
(insert "(lambda () (interactive)\n (foo))")
(goto-char (point-min))
(indent-sexp)
(buffer-substring-no-properties
(point-min)
(point-max))))
The code indentation is:
(λ () (interactive)
(foo))
which is the indentation as if λ
was 5 chars wide.
Is there a way around this?