Show More
@@ -116,3 +116,111 b' To configure your default pager to allow these:' | |||||
116 | you always want to pass to less by default). This tells less to |
|
116 | you always want to pass to less by default). This tells less to | |
117 | properly interpret control sequences, which is how color |
|
117 | properly interpret control sequences, which is how color | |
118 | information is given to your terminal. |
|
118 | information is given to your terminal. | |
|
119 | ||||
|
120 | .. _editors: | |||
|
121 | ||||
|
122 | Editor configuration | |||
|
123 | ==================== | |||
|
124 | ||||
|
125 | IPython can integrate with text editors in a number of different ways: | |||
|
126 | ||||
|
127 | * Editors (such as `(X)Emacs`_, vim_ and TextMate_) can | |||
|
128 | send code to IPython for execution. | |||
|
129 | ||||
|
130 | * IPython's ``%edit`` magic command can open an editor of choice to edit | |||
|
131 | a code block. | |||
|
132 | ||||
|
133 | The %edit command (and its alias %ed) will invoke the editor set in your | |||
|
134 | environment as :envvar:`EDITOR`. If this variable is not set, it will default | |||
|
135 | to vi under Linux/Unix and to notepad under Windows. You may want to set this | |||
|
136 | variable properly and to a lightweight editor which doesn't take too long to | |||
|
137 | start (that is, something other than a new instance of Emacs). This way you | |||
|
138 | can edit multi-line code quickly and with the power of a real editor right | |||
|
139 | inside IPython. | |||
|
140 | ||||
|
141 | You can also control the editor by setting :attr:`TerminalInteractiveShell.editor` | |||
|
142 | in :file:`ipython_config.py`. | |||
|
143 | ||||
|
144 | Vim | |||
|
145 | --- | |||
|
146 | ||||
|
147 | Paul Ivanov's `vim-ipython <https://github.com/ivanov/vim-ipython>`_ provides | |||
|
148 | powerful IPython integration for vim. | |||
|
149 | ||||
|
150 | .. _emacs: | |||
|
151 | ||||
|
152 | (X)Emacs | |||
|
153 | -------- | |||
|
154 | ||||
|
155 | If you are a dedicated Emacs user, and want to use Emacs when IPython's | |||
|
156 | ``%edit`` magic command is called you should set up the Emacs server so that | |||
|
157 | new requests are handled by the original process. This means that almost no | |||
|
158 | time is spent in handling the request (assuming an Emacs process is already | |||
|
159 | running). For this to work, you need to set your EDITOR environment variable | |||
|
160 | to 'emacsclient'. The code below, supplied by Francois Pinard, can then be | |||
|
161 | used in your :file:`.emacs` file to enable the server:: | |||
|
162 | ||||
|
163 | (defvar server-buffer-clients) | |||
|
164 | (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm)) | |||
|
165 | (server-start) | |||
|
166 | (defun fp-kill-server-with-buffer-routine () | |||
|
167 | (and server-buffer-clients (server-done))) | |||
|
168 | (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine)) | |||
|
169 | ||||
|
170 | Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, | |||
|
171 | currently (X)Emacs and IPython get along very well in other ways. | |||
|
172 | ||||
|
173 | .. note:: | |||
|
174 | ||||
|
175 | You will need to use a recent enough version of :file:`python-mode.el`, | |||
|
176 | along with the file :file:`ipython.el`. You can check that the version you | |||
|
177 | have of :file:`python-mode.el` is new enough by either looking at the | |||
|
178 | revision number in the file itself, or asking for it in (X)Emacs via ``M-x | |||
|
179 | py-version``. Versions 4.68 and newer contain the necessary fixes for | |||
|
180 | proper IPython support. | |||
|
181 | ||||
|
182 | The file :file:`ipython.el` is included with the IPython distribution, in the | |||
|
183 | directory :file:`docs/emacs`. Once you put these files in your Emacs path, all | |||
|
184 | you need in your :file:`.emacs` file is:: | |||
|
185 | ||||
|
186 | (require 'ipython) | |||
|
187 | ||||
|
188 | This should give you full support for executing code snippets via | |||
|
189 | IPython, opening IPython as your Python shell via ``C-c !``, etc. | |||
|
190 | ||||
|
191 | You can customize the arguments passed to the IPython instance at startup by | |||
|
192 | setting the ``py-python-command-args`` variable. For example, to start always | |||
|
193 | with ``matplotlib`` integration and hardcoded light-background colors, you can use:: | |||
|
194 | ||||
|
195 | (setq py-python-command-args '("--matplotlib" "--colors" "LightBG")) | |||
|
196 | ||||
|
197 | If you happen to get garbage instead of colored prompts as described in | |||
|
198 | the previous section, you may need to set also in your :file:`.emacs` file:: | |||
|
199 | ||||
|
200 | (setq ansi-color-for-comint-mode t) | |||
|
201 | ||||
|
202 | Notes on emacs support: | |||
|
203 | ||||
|
204 | .. This looks hopelessly out of date - can someone update it? | |||
|
205 | ||||
|
206 | * There is one caveat you should be aware of: you must start the IPython shell | |||
|
207 | before attempting to execute any code regions via ``C-c |``. Simply type | |||
|
208 | ``C-c !`` to start IPython before passing any code regions to the | |||
|
209 | interpreter, and you shouldn't experience any problems. This is due to a bug | |||
|
210 | in Python itself, which has been fixed for Python 2.3, but exists as of | |||
|
211 | Python 2.2.2 (reported as SF bug [ 737947 ]). | |||
|
212 | ||||
|
213 | * The (X)Emacs support is maintained by Alexander Schmolck, so all | |||
|
214 | comments/requests should be directed to him through the IPython mailing | |||
|
215 | lists. | |||
|
216 | ||||
|
217 | * This code is still somewhat experimental so it's a bit rough around the | |||
|
218 | edges (although in practice, it works quite well). | |||
|
219 | ||||
|
220 | * Be aware that if you customized ``py-python-command`` previously, this value | |||
|
221 | will override what :file:`ipython.el` does (because loading the customization | |||
|
222 | variables comes later). | |||
|
223 | ||||
|
224 | .. _`(X)Emacs`: http://www.gnu.org/software/emacs/ | |||
|
225 | .. _TextMate: http://macromates.com/ | |||
|
226 | .. _vim: http://www.vim.org/ |
@@ -10,6 +10,5 b' Configuration and customization' | |||||
10 | intro |
|
10 | intro | |
11 | extensions/index |
|
11 | extensions/index | |
12 | integrating |
|
12 | integrating | |
13 | editors |
|
|||
14 | inputtransforms |
|
13 | inputtransforms | |
15 | details |
|
14 | details |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now