I'd like to change use-package
's indentation style to look more distinguishable, (more or less) similar like the following indentation style:
(use-package foo
:commands (gah)
:init (setq f 1)
(blubb g 2)
:config
(blah h 3)
(moo i 4))
This means, keywords should be indented normal but all following options to such a keyword, should be indented a bit more and should align vertically.
I already know, that it is possible to define a function to calculate the current indentation column. Per default it is set to standard defun
indentation:
(get 'use-package 'lisp-indent-function)
; → defun
The following function definition and set up of property, changes that, but I struggle with the implementation details of function my-use-package-indent-function
.
(defun my-use-package-indent-function (indent-point state)
(let* ((normal-indent (current-column))
(indent-offset (progn (back-to-indentation)
(current-column))))
(goto-char indent-point)
(back-to-indentation)
(if (eq ?: (char-after))
(+ indent-offset 2)
(+ indent-offset 5))))
(put 'use-package 'lisp-indent-function #'my-use-package-indent-function)
Above is a naive, incomplete version, but how to calculate the indentation value properly?