Emacs' indentation of Emacs lisp code is really great, except for one thing:

(defconst one-to-ten '(one two three
                           four five six seven
                           eight nine ten))

Is this actually the preferred way to indent this block? As opposed to

(defconst one-to-ten '(one two three
                       four five six seven
                       eight nine ten))

I find it especially confusing when compared to the default for alists:

(defconst one-to-ten '((one . 1) (two . 2) (three . 3)
                       (four . 4) (five . 5) (six . 6) (seven . 7)
                       (eight . 8) (nine . 9) (ten . 10)))

Is there a reason for this behaviour? I could possibly understand it for back-quoted lists, as it would yield better indentation for macros, but what about lists?

  • The coding conventions section of the manual is pretty explicit about this, btw: Indent the file using the default indentation parameters.
    – Clément
    Sep 26, 2015 at 23:41
  • 3
    The coding conventions might say that by convention we respect the default indentation, but that does not provide a reason why the default indentation is what it is. There is nothing in the coding conventions that says why a constant list is indented as it is. (This is akin to an overtired parent replying, in response to the 99th "Why?", "Just because".)
    – Drew
    Sep 27, 2015 at 0:18
  • 4
    @EmacsUser: Of course. What's your point? The question asked was "Is there a reason for this behaviour?" Why this indentation convention? Conventions don't fall out of the sky. And sometimes they are changed. If the only answer given to Why? is "That's the convention", that's no answer at all.
    – Drew
    Sep 27, 2015 at 1:44
  • 3
    @EmacsUser: No one has argued against your "point". The question is a good one. There may be good reasons for having picked this default. Or not. There might be reasons for an alternative indentation. Nothing wrong with asking the question.
    – Drew
    Sep 27, 2015 at 3:53
  • 3
    @Clément: FWIW, I personally think this is a bug and there's been changes around this part of Elisp-mode "recently", so you might like to M-x report-emacs-bug.
    – Stefan
    Sep 28, 2015 at 2:26

1 Answer 1


Here are the settings I'm using to fix the indentation:

(setq lisp-indent-function 'common-lisp-indent-function)
(eval-after-load 'cl-indent
     (put 'cl-flet 'common-lisp-indent-function
          (get 'flet 'common-lisp-indent-function))
     (put 'cl-labels 'common-lisp-indent-function
          (get 'labels 'common-lisp-indent-function))
     (put 'if 'common-lisp-indent-function 2)))

I tried to fix the Elisp indentation at one point, but it was too convoluted and I gave up. But the settings above have worked fine for years.

  • Can you please briefly explain what those put and get forms do? Does it replace the cl-flet function instances with flet and cl-labels instances with labels only in the common-lisp-indent-function? If so, why is that done? Also what does the third put do? I read the put documentation but still did not make sense. It would translate to "set the value of common-lisp-indent-function property of if symbol to 2" but that didn't make sense to me. Sep 27, 2015 at 13:46
  • In these 3 cases, 'lisp-indent-function (i.e. the default one) is actually better than 'common-lisp-indent-function. Those settings make the indentation carry over from one to the other.
    – abo-abo
    Sep 27, 2015 at 15:15
  • 1
    Note: It is only the first line that answers this question -- i.e., (setq lisp-indent-function 'common-lisp-indent-function). The rest has nothing to do with the indentation to use for a constant list.
    – Drew
    Sep 27, 2015 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.