📜 ⬆️ ⬇️

Set up emacs for python development or search for the “perfect” editor

The purpose of the article is to tell about my search for the “ideal” editor for python code, about why I chose emacs and briefly how I (emacs) set it up to work with python.

A small prehistory: I have been working on python for more than two years and all this time I tried to find the optimal editor. What I just did not use during this time is mcedit, nano, gedit, netbeans, eclipse, and also some other paid options (demo version). But there is always something missing, somewhere autocomplete, somewhere backlight, somewhere banal inconvenient. What a period (about 10 months) used Eclipse, but its gluttony in resources, hangs brought it to a white heat. When I finally got bored with eclipse errors, I began searching for such an editor that would be an excellent assistant in my work.
Armed with google, I started searching for the “perfect” editor.

Note! Further in the text is the personal opinion of the author.
An “ideal” editor should be:

I also wanted to note the desired functionality and features of use:

Python-specific functionality:


Candidate # 1 - Gedit :
Regular editor of the graphical shell Gnome.
What is good:

What is bad:

Bottom line: It is quite suitable for editing small scripts, it is practically unsuitable for larger projects.
')
Candidate # 2 - Eric :
The Eric Python IDE
What is good:

What is bad:

Bottom line: At first glance, a full-fledged IDE. With a thoughtful interface. If you get used probably will be convenient.

Candidate # 3 - Emacs
Austere editor with a lot of customizable features
What is good:

What is bad:

Bottom line: This editor is used at this time. It is difficult to set up, it is not easy to get used to use, it is very difficult then to use another editor (even briefly)

Why choose emacs? I watched for a long time, but like many developers tried to use a ready-made solution without complex gestures. Yes, and probably did not want to mess around for a long time with the setting. But only when I was tired of all sorts of ruches and buttons I wanted to just work and not be distracted by anything. In general, installing emacs and spending several sleepless days on the setup, and after working in it for a while, I realized that this editor would linger with me for a long time.

How to set up. Many novice emacs users inflate their "~ / .emacs" with unstructured plugins and hooks. In the beginning I did the same, but looking at the organization of the settings for gabrielelanaro , I made the following structure.
Used configuration:
.
.. dist - distributions of extensions
... autocomplete - autocompletion in emacs, used version from gabrielelanaro repository, original version
... python-mode - python support in emacs from the python community version <a ref= pas launchpad.net/python-mode »> 6.0.2
... yasnippet - support for snippets in emacs, used version from gabrielelanaro repository, original version
... pymacs - python binding to emacs, project site
.. doc - extension documentation
.. exten - extensions to be initialized
... autocomplete
... color-theme.el - connection of additional themes
... highlight-indentation.el - highlight indents
... open-next-line.el
... python-mode.el - actually python-mode
... python-pylint.el - pylint support (pylint must be installed on the system)
... snippet-helpers.el - addition to yasnippet
... yasnippet
... autopair.el - closing pair symbols
... fill-column-indicator.el - line indicator
... lambda-mode.el - replacing lambda with a mapping symbol
... pymacs.el
... python-pep8.el - support for pep8 (pep8 must be installed on the system)
... smart-operator.el
... themes - additional themes
.. init - component initialization files
.. init.el - directly initialize the configuration
.. python-dist - distributions of python packages necessary for work
... Pymacs
... rope
... ropemacs
... ropemode
The complete configuration can be taken from my repository on GitHub , the configuration is not final. Future plans to integrate ECB. In the wiki repository add a description of what key-binding is used.

Interesting additions integrated into this configuration:
Switching between buffers:
\ C +. - next buffer
\ C +, - prev buffer

Switch between windows:
\ M + up
\ M + down
\ M + left
\ M + right

Autocompletion by pressing \ TAB

In order for the addition of python classes and methods to work correctly, you need to activate the rope project:
By default, if the project is not created, rope offers to create it.

Some screenshots:


Syntax synopsis, vertical blue bar, 80th character indicator


Autocompletion in work


iBuffer - shows a list of all open buffers


Integrated ido with fuzzy search support

I would like to hear from experienced emacs users about this method of organizing emacs configuration and about this configuration in particular. Examples and suggestions for improving this configuration are welcome.

The platform on which this configuration works:
Linux ppc 3.1.5-gentooppc # 1 SMP Wed Jan 4 00:01:44 EET 2012 i686 Intel Pentium CPU P6200 @ 2.13GHz GenuineIntel GNU / Linux

Source: https://habr.com/ru/post/136668/


All Articles