Last edit
Summary: move indentation comment to appropriate section
Deleted:
< == Newline-and-indent ==
< In python.el you can get this with this in your InitFile:
< (add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-m" 'newline-and-indent)))
Added:
> === Newline-and-indent ===
> In python.el you can get this with this in your InitFile:
> (add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-m" 'newline-and-indent)))
There are two major variants of python.el
see this post
‘python-describe-symbol’ tries to get doc in the context of what the source file imports (be sure to first run the Python interpreter [C-c !]).
CEDET is now part of emacs (but I still recommend getting the latest version). It includes things like completion and folding, so that some things here may not be required.
python.el includes a regexp for outliner-mode, and hs-mode too.
Since indentation is significant in python, correct indent functions are vital, thought these might overload the tab key.
See SmartTabs (toc5) or TabCompletion (tabkey2 stuff)
In python.el you can get this with this in your InitFile:
(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-m" 'newline-and-indent)))
python-end-of-block instead of py-next-block?
The following will integrate python.el completions with auto-complete. You need to have installed and loaded auto-complete.el first:
(defvar ac-source-python '((candidates . (lambda () (mapcar '(lambda (completion) (first (last (split-string completion "\\." t)))) (python-symbol-completions (python-partial-symbol)))))))
(add-hook 'python-mode-hook
(lambda() (setq ac-sources '(ac-source-python))))
It seems like point has to be at the very bottom, with a clear prompt, for python-send-region to work. Here’s a quick hack that does that before calling the function, and puts it back the way it was afterwards:
(defadvice python-send-region (around advice-python-send-region-goto-end) "Fix a little bug if the point is not at the prompt when you do C-c C-[rc]" (let ((oldpoint (with-current-buffer (process-buffer (python-proc)) (point))) (oldinput (with-current-buffer (process-buffer (python-proc)) (goto-char (point-max)) ;; Do C-c C-u, but without modifying the kill ring: (let ((pmark (process-mark (get-buffer-process (current-buffer))))) (when (> (point) (marker-position pmark)) (let ((ret (buffer-substring pmark (point)))) (delete-region pmark (point)) ret)))))) ad-do-it (with-current-buffer (process-buffer (python-proc)) (when oldinput (insert oldinput)) (goto-char oldpoint)))) (ad-enable-advice 'python-send-region 'around 'advice-python-send-region-goto-end) (ad-activate 'python-send-region)
Using python-complete-symbol in the inferior python buffer causes an infinite loop in python.el as of 080117, changing python-imports from the default nil to ‘None’ solves this. 2008-01-17, patch submitted.
:I’m a little confused - It appears when I set flymake-mode to be automatically on for python mode, py-help-at-point doesn’tt work. I tried switching from python-mode.el to python.el, but this doesn’t seem to solve it; However, there is no advice here on how to use python.el, so I’m not entirely sure I’m doing it right…