0

Sometimes I see people talking about enabling python-mode and so on. Is that only necessary for older emacs versions? I thought, the respective mode is enabled automatically when opening a corresponding file...

Please clarify

edit: According to this topic they can work in combination. This leaves me wondering, what the python-mode package additionally brings to the table that is not already provided by the build-in python.el

Drew
  • 75,699
  • 9
  • 109
  • 225
CD86
  • 543
  • 2
  • 9

1 Answers1

5

python-mode.el (from https://gitlab.com/python-mode-devs/python-mode) has more "bells-and-whistles" than python.el (included with Emacs). Things like better integration with IPython and auto-completers, integration with Pymacs (python<->elisp bindings), filling, etc. You can read for yourself its features at its gitlab.

When it's said that they work together, it's meant that they don't interfere with each other. Not that they complement each other. They're two different packages that do the same task; helping to write and work with python code.

The Emacs Wiki has an extensive page on Programming Python in Emacs that describes the two modes and other Python related packages.

As far as enabling python-mode... if you want to use python-mode.el then yes, you need to install and enable it. Otherwise you'll use the included python.el. I think @Drew intended to show you how you can see which one is currently active in your Emacs. By inspecting the variable auto-mode-alist with C-h v RET auto-mode-alist you can see what mode is associated with your *.py files. Unfortunately, it's always going to show python-mode whether you're using python-mode.el or python.el.

A better way to find out which version you're using is to open a python file, and in that buffer do C-h m RET. This will give you a help window describing the major and minor modes active in the buffer. First will be a list of minor modes, then the major mode. Since you did this from a python buffer, you'll see something like:

Python mode defined in 'python.el':
Major mode for editing Python files.

The filename (in this example 'python.el') will be a link. Mouse click, or move the cursor over it and hit RET. That will load the source file in another buffer that you can inspect at will.

nega
  • 3,091
  • 15
  • 21
  • Fun fact, the Emacs included with macOS (GNU Emacs 22.1.1) has a third (older) `python-mode` also in the file `python.el` – nega Mar 04 '19 at 22:50
  • Fun fact #2, `python-mode.el` used to be distributed by XEmacs and Python. I think it's now long out of Python, and XEmacs is now, well..., :( – nega Mar 04 '19 at 22:53