In https://www.emacswiki.org/emacs/AutoModeAlist one needs to use this command in order to add .py for python-mode (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
Why do we need the . between '"\\.py\\'" and the python-mode ?


This is lisp syntax for a dotted pair:

(cons 'a 'b) -> (a . b)

Here's a link.

Briefly, dotted pairs are the fundamental building blocks for lists: lists are special dotted pairs, defined recursively. Most of the time, you work with lists so the dotted pairs are hidden in the background, but once in a while (as in this case), they poke through.


That's because auto-mode-alist is an "association list" (a list of pairs).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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