Search code examples
pythonemacspython-mode

Understanding which python mode is loaded by emacs / Aquamacs and why


I have emacs 24.1.1, which comes with GNU's python.el in byte-compiled form at emacs/24.1/lisp/progmodes.

I downloaded Fabian Gallina's python.el (note the same name) and placed it at emacs/site-lisp, which is part of emacs' load-path.

When I edit a Python file, it is Gallina's mode which is loaded, NOT GNU's. However, I have not put (require 'python) in my .emacs file, despite what Gallina's documentation suggests.

Why is this? Why does Gallina's python.el take precedence over GNU's? Why does it get loaded without (require 'python)?


Solution

  • Most libraries you use in Emacs aren't loaded when you start Emacs. They are autoloaded see manual.

    If you look at your load-path variable, you'll see that site-lisp comes before Emacs' own libraries. So when Emacs goes to load "python.el" it finds your version first.

    Note that when you do C-h f python-mode before running the command, you'll actually see the description of Emacs's version of the command. This is an unfortunate side-effect of the author's choosing the same filename.

    Once you've run python-mode once, the help text will change to show your version.