0

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)?

Dan
  • 763
  • 3
  • 8
  • 13

2 Answers2

2

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.

event_jr
  • 17,467
  • 4
  • 47
  • 62
  • Thank you! So, to clarify: internally emacs autoloaded a function python-mode, defined in python.el, and set up a hook such that the function is called for files ending in .py. But, since I put a different python.el (defining the same function) in my load-path such that it comes before the internal lisp directory, it is loaded first. – Dan Jul 09 '12 at 22:57
0

To load an already loaded library from new place, write in your Emacs init-file something like

(unload-feature...

(load FROM-NEW-PLACE...

Andreas Röhler
  • 4,804
  • 14
  • 18