https://wikemacs.org/api.php?action=feedcontributions&user=Ruishi&feedformat=atomWikEmacs - User contributions [en]2024-03-28T12:31:03ZUser contributionsMediaWiki 1.35.14https://wikemacs.org/index.php?title=Python&diff=46619Python2014-04-14T22:21:12Z<p>Ruishi: /* cscope */ grammar</p>
<hr />
<div>= Default modes =<br />
<br />
There are a number of python modes for Emacs.<br />
fgallina's [https://github.com/fgallina/python.el python.el] is the python.el included in Emacs 24.2 and onwards.<br />
<br />
= All-in-one solutions =<br />
<br />
== emacs-for-python ==<br />
<br />
'''emacs-for-python''' is a bundle of the above modes (and more), and it's an easy way to turn Emacs into a Python IDE.<br />
<br />
[https://github.com/gabrielelanaro/emacs-for-python/ emacs-for-python at github]<br />
<br />
== Elpy ==<br />
<br />
'''Elpy''' is a collection of elisp packages for Python too.<br />
<br />
https://github.com/jorgenschaefer/elpy/wiki/Features<br />
<br />
<br />
= Auto-Completion =<br />
<br />
== rope & ropemacs ==<br />
<br />
'''rope''' is a library for refactoring and manipulating Python code. '''{{ModeLink|ropemacs}}''' is an Emacs interface to the rope library.<br />
<br />
[http://rope.sourceforge.net/ rope homepage]<br />
<br />
[http://rope.sourceforge.net/ropemacs.html ropemacs homepage]<br />
<br />
== Jedi ==<br />
<br />
Jedi.el is a Python auto-completion package for Emacs. It aims at helping your Python coding in a non-destructive way. It also helps you to find information about Python objects, such as docstring, function arguments and code location.<br />
<br />
Jedi is simple to install and it just works.<br />
<br />
See screenshots and get the full documentation : http://tkf.github.io/emacs-jedi/released/<br />
<br />
Jedi's official page: http://jedi.jedidjah.ch/en/latest/<br />
<br />
=== Installation ===<br />
<br />
Install Jedi.el via el-get, Marmalade or MELPA (see install for more info) and add this to your Emacs configuration:<br />
(add-hook 'python-mode-hook 'jedi:setup)<br />
(setq jedi:setup-keys t) ; optional<br />
(setq jedi:complete-on-dot t) ; optional<br />
<br />
or call M-x jedi:setup<br />
<br />
= Code Checker =<br />
<br />
== Flymake ==<br />
<br />
[[Flymake|flymake]] is a on-the-fly syntax checker for Emacs. <br />
We can use it alongside with [[flyspell|flyspell]].<br />
<br />
To run pep8, pylint, pyflakes and unit-tests (with nose), you can be interested in using [https://github.com/akaihola/flymake-python flymake-python].<br />
<br />
Don't forget about '''pylint''' too.<br />
<br />
= Indexing sources: ctags, cscope, pycscope = <br />
<br />
== etags, ctags ==<br />
<br />
'''Etags''' (Exuberant Ctags) generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object). Etags is a multilingual implementation of '''ctags'''.<br />
<br />
The primary use for the tags files is looking up class/method/function/constant/etc declaration/definitions. Cscope is more powerful (see below).<br />
<br />
=== usage ===<br />
<br />
Generate the tags with this command at the root of your project:<br />
<br />
find . -name "*.py" -print | etags -<br />
<br />
it creates the file TAGS.<br />
<br />
Note that projects like [[Projectile]] or [[Helm]] provide an integrated use of etags (finding one, re-generating the index, etc).<br />
<br />
== cscope ==<br />
<br />
'''cscope''' is a much more powerful beast. While it operates on more or less the same principle (generating a file of useful metadata) it allows you do some fancier things like find all references to a symbol, see where a function is being invoked, etc.+ (you can find definitions as well). <br />
<br />
It was originally designed for C and C++, but thanks to version 0.3 of '''pycscope''', pythonistas can make use of it.<br />
<br />
=== usage ===<br />
<br />
The following commands should get you running: <br />
<br />
apt-get install cscope<br />
pip install pycscope<br />
# in project base dir:<br />
find . -name '*.py' > cscope.files<br />
cscope -R <br />
<br />
now install the '''xcscope''' emacs package with [[ELPA]] and require it: <br />
(require 'xcscope)<br />
<br />
When done, you can either enable the mode with '''cscope-minor-mode''' (which will add a menu you are free to explore) or call some functions like {{Command|cscope-find-global-definition}}, {{Command|cscope-find-functions-calling-this-function}}, etc.<br />
<br />
= Debugging =<br />
<br />
== Ipdb, ipython debugger ==<br />
<br />
If you call ipdb, the execution will stop and give a nice ipython-looking prompt.<br />
Just add `import ipdb; ipdb.set_trace()`<br />
<br />
You can use the following to highlight this line, and not forget it :<br />
<source lang="scheme"><br />
; Highlight the call to ipdb<br />
; src http://pedrokroger.com/2010/07/configuring-emacs-as-a-python-ide-2/<br />
(defun annotate-pdb ()<br />
(interactive)<br />
(highlight-lines-matching-regexp "import ipdb")<br />
(highlight-lines-matching-regexp "ipdb.set_trace()"))<br />
(add-hook 'python-mode-hook 'annotate-pdb)<br />
</source><br />
<br />
== pdb track ==<br />
<br />
If you use emacs-for-python given above, you can track your source code while debugging with pdbtrack.<br />
<br />
A tool to use in a non-emacs terminal would be [https://pypi.python.org/pypi/pdbpp/ pdbpp]<br />
<br />
= Other tools =<br />
<br />
== Pymacs ==<br />
<br />
'''{{ModeLink|Pymacs}}''' is an Emacs extension that enables the use of Python alongside with Emacs Lisp.<br />
<br />
[http://pymacs.progiciels-bpi.ca/index.html Pymacs homepage]<br />
<br />
<br />
<br />
= See also =<br />
<br />
You'll be certainly interested in the following packages (that you will find on [[ELPA]] or MELPA):<br />
<br />
* '''Magit''', a git interface. Emacs + git is magic : see [[magit]]<br />
<br />
* '''Yasnippet''', a template system: [[yasnippet]]<br />
<br />
* '''virtualenvwrapper''', to load a virtualenv (so than you can use it with M-x compile) (available through ELPA)<br />
<br />
* '''helm-pydoc''' to browse the documentation of installed packages and import one<br />
<br />
* '''py-isort''' to sort import statements<br />
<br />
* '''pungi''' to integrate jedi, virtualenv and buildout.<br />
<br />
* other '''ELPA packages'''<br />
<br />
If you're running Emacs 24, check out what is available in [[ELPA]]:<br />
; {{Command | list-packages}} : and see flymake-pyhon-pyflakes, flymake-shell, abl-mode (a python TDD minor-mode), nose (easy python test-running in emacs), pyregexp, python-magic and more.<br />
<br />
[[Category:Programming languages]]<br />
[[Category:Programming]]</div>Ruishihttps://wikemacs.org/index.php?title=Talk:Emacs-nav&diff=46618Talk:Emacs-nav2014-04-14T22:15:40Z<p>Ruishi: remove spam</p>
<hr />
<div></div>Ruishihttps://wikemacs.org/index.php?title=Talk:Ido&diff=46617Talk:Ido2014-04-14T22:15:21Z<p>Ruishi: </p>
<hr />
<div>remove spam</div>Ruishihttps://wikemacs.org/index.php?title=Talk:Python&diff=46616Talk:Python2014-04-14T22:15:07Z<p>Ruishi: remove spam</p>
<hr />
<div></div>Ruishihttps://wikemacs.org/index.php?title=Talk:Ace-jump&diff=46615Talk:Ace-jump2014-04-14T22:14:48Z<p>Ruishi: remove spam</p>
<hr />
<div></div>Ruishihttps://wikemacs.org/index.php?title=Talk:Evil&diff=46614Talk:Evil2014-04-14T22:14:32Z<p>Ruishi: remove spam</p>
<hr />
<div></div>Ruishihttps://wikemacs.org/index.php?title=Built-in_help&diff=46580Built-in help2014-03-30T19:34:32Z<p>Ruishi: /* Basic Commands */</p>
<hr />
<div>Emacs provides many help features, all of which are helpfully bound to a prefix key, C-h.<br />
<br />
== Basic Commands ==<br />
; {{Keys|C-h C-h}} (help-for-help)<br />
: Provides a list of all help options and prompts you to enter one of the options.<br />
<br />
; {{Keys|C-h k}} (describe-key)<br />
: Prompts you to enter a key sequence and then provides information about what it does.<br />
<br />
; {{Keys|C-h c}} (describe-key-briefly)<br />
: Prompts you to enter a key sequence and then displays command that key sequence runs.<br />
<br />
; {{Keys|C-h w}} (where-is)<br />
: Given a command name, it displays a list of key sequences that could be used to invoke that command.<br />
<br />
; {{Keys|C-h v}} (describe-variable)<br />
: Prompts you to enter a variable name and then provides full documentation of that variable, including the current value of the variable.<br />
<br />
; {{Keys|C-h f}} (describe-function)<br />
: Prompts you to enter a function name and then provides full documentation for that function.<br />
<br />
; {{Keys|C-h d}} (apropos-documentation)<br />
: Prompts you for a list of words or a regexp and then returns a list of functions, variables, etc. that match.<br />
<br />
; {{Keys|C-h b}} (describe-bindings)<br />
: Displays all key bindings<br />
<br />
There are many more help commands available. Enter C-h C-h in emacs for a full listing.</div>Ruishihttps://wikemacs.org/index.php?title=Built-in_help&diff=46579Built-in help2014-03-30T19:27:32Z<p>Ruishi: fix typo</p>
<hr />
<div>Emacs provides many help features, all of which are helpfully bound to a prefix key, C-h.<br />
<br />
== Basic Commands ==<br />
; {{Keys|C-h C-h}} (help-for-help)<br />
: Provides a list of all help options and prompts you to enter one of the options.<br />
<br />
; {{Keys|C-h k}} (describe-key)<br />
: Prompts you to enter a key sequence and then provides information about what it does.<br />
<br />
; {{Keys|C-h c}} (describe-key-briefly)<br />
: Prompts you to enter a key sequence and then displays command that key sequence runs.<br />
<br />
; {{Keys|C-h w}} (where-is)<br />
: Given a command name, it displays a list of key sequences that could be used to invoke that command.<br />
<br />
; {{Keys|C-h v}} (describe-variable)<br />
: Prompts you to enter a variable name and then provides full documentation of that variable, including the current value of the variable.<br />
<br />
; {{Keys|C-h f}} (describe-function)<br />
: Prompts you to enter a function name and then provides full documentation for that function.<br />
<br />
; {{Keys|C-h b}} (describe-bindings)<br />
: Displays all key bindings<br />
<br />
There are many more help commands available. Enter C-h C-h in emacs for a full listing.</div>Ruishihttps://wikemacs.org/index.php?title=Built-in_help&diff=46578Built-in help2014-03-30T19:27:08Z<p>Ruishi: add page</p>
<hr />
<div>Emacs provides many help features, all of which are helpfully bound to a prefix key, C-h.<br />
<br />
== Basic Commands ==<br />
; {{Keys|C-h C-h}} (help-for-help)<br />
: Provides a list of all help options and prompts you to enter one of the options.<br />
<br />
; {{Keys|C-h k}} (describe-key)<br />
: Prompts you to enter a key sequence and then provides information about what it does.<br />
<br />
; {{Keys|C-h c}} (describe-key-briefly)<br />
: Prompts you to enter a key sequence and then displays command that key sequence runs.<br />
<br />
; {Keys|C-h w}} (where-is)<br />
: Given a command name, it displays a list of key sequences that could be used to invoke that command.<br />
<br />
; {{Keys|C-h v}} (describe-variable)<br />
: Prompts you to enter a variable name and then provides full documentation of that variable, including the current value of the variable.<br />
<br />
; {{Keys|C-h f}} (describe-function)<br />
: Prompts you to enter a function name and then provides full documentation for that function.<br />
<br />
; {{Keys|C-h b}} (describe-bindings)<br />
: Displays all key bindings<br />
<br />
There are many more help commands available. Enter C-h C-h in emacs for a full listing.</div>Ruishihttps://wikemacs.org/index.php?title=Windows_within_a_frame&diff=46577Windows within a frame2014-03-30T19:08:39Z<p>Ruishi: add page</p>
<hr />
<div>In emacs, you can have multiple windows within a frame. You can split frames vertically or horizontally. The newly created window will contain the buffer that you were in when you split the frame and your point will remain in the original window.<br />
<br />
== Basic Commands ==<br />
; {{Keys|C-x 2}} (split-window-below)<br />
: Split frame vertically<br />
<br />
; {{Keys|C-x 3}} (split-window-right)<br />
: Split frame horizontally<br />
<br />
; {{Keys|C-x o}} (other-window)<br />
: Switch focus to next window<br />
<br />
; {{Keys|C-x 0}} (delete-window)<br />
: Close current window.<br />
<br />
; {{Keys|C-x 1}} (delete-other-windows)<br />
: Close every window except the one currently in focus.</div>Ruishi