Commit graph

655 commits

Author SHA1 Message Date
Fabián Ezequiel Gallina
92f58578cc Fixes: debbugs:18432
* lisp/progmodes/python.el (python-indent-calculate-levels): Fix
indentation behavior multiline dedenter statement.

* test/automated/python-tests.el (python-indent-dedenters-8): New test
for Bug#18432.
2014-11-15 19:02:52 -03:00
Fabián Ezequiel Gallina
89ebffc1f6 Fix region indentation
Fixes: debbugs:18843

* lisp/progmodes/python.el (python-indent-region): Use
python-indent-line and skip special cases.

* test/automated/python-tests.el (python-indent-region-1)
(python-indent-region-2, python-indent-region-3)
(python-indent-region-4, python-indent-region-5): New tests.
2014-11-15 18:10:58 -03:00
Fabián Ezequiel Gallina
9ae5396b8f Eldoc setup code enhancements
Fixes: debbugs:18962

* lisp/progmodes/python.el (python-eldoc-setup-code): Enhance string
type checks, simplify printing.
2014-11-15 15:50:30 -03:00
Ivan Andrus
15ec2d7cff Backport Use derived-mode-p in python.el instead of equality test with major-mode
Fixes: debbugs:18854

* progmodes/python.el (python-ffap-module-path): Use
`derived-mode-p' instead of equality test on `major-mode'.
2014-11-14 21:56:11 -07:00
Ivan Andrus
f20a19df87 Use derived-mode-p in python.el instead of equality test on major-mode
* progmodes/python.el (python-shell-font-lock-kill-buffer):
(python-shell-font-lock-with-font-lock-buffer)
(python-shell-get-buffer, python-ffap-module-path): Use
`derived-mode-p' instead of equality test on `major-mode'.
2014-11-14 13:54:10 -07:00
Fabián Ezequiel Gallina
eb97699236 Rename python-shell-virtualenv-path to fit GNU conventions
* lisp/progmodes/python.el (python-shell-virtualenv-root): Rename from
python-shell-virtualenv-path.
(python-shell-internal-get-process-name)
(python-shell-calculate-process-environment)
(python-shell-calculate-exec-path): Use it.
2014-11-14 03:26:08 -03:00
Fabián Ezequiel Gallina
5d977b968c * lisp/progmodes/python.el (python-shell-completion-get-completions):
Fix previous merge.
2014-11-14 02:29:40 -03:00
Stefan Monnier
c9f7e33c60 * lisp/progmodes/python.el (inferior-python-mode): Use add-hook. 2014-10-20 18:37:04 -04:00
Glenn Morris
b1d5ab0352 Merge from emacs-24; up to 2014-07-26T11:58:24Z!schwab@linux-m68k.org 2014-10-12 15:56:45 -07:00
Fabián Ezequiel Gallina
b1be0eda33 Fix import completion.
* lisp/progmodes/python.el (python-shell-completion-get-completions):
Fix import case regexp.

Fixes: debbugs:18582
2014-10-12 12:12:04 -03:00
Stefan Monnier
cb325041b0 * lisp/progmodes/python.el: Avoid building unneeded markers.
(python-font-lock-keywords, python-indent-dedent-line)
(python-fill-paren, python-shell-completion-complete-or-indent):
Prefer point over point-marker.
(inferior-python-mode): Remove redundant completion settings.
2014-10-03 22:35:28 -04:00
Stefan Monnier
d7f413b893 Merge from emacs-24 2014-10-02 11:13:05 -04:00
Stefan Monnier
85ee81a08f * lisp/progmodes/python.el (python-shell-completion-get-completions):
Use python-shell--prompt-calculated-input-regexp from the
process buffer.
Don't assume that `line' comes from the process buffer.

Fixes: debbugs:18582
2014-09-30 20:41:51 -04:00
Stefan Monnier
07bec0fc67 Merge from emacs-24 2014-09-30 19:19:31 -04:00
Leonardo Nobrega
d3b7a90bc2 * lisp/progmodes/python.el (python-fill-paren): Don't inf-loop at EOB.
Fixes: debbugs:18462
2014-09-30 19:00:57 -04:00
Stefan Monnier
cbdc06f3be Rename 24.5 to 25.1
Except where we expect to backport the corresponding change.
2014-09-29 14:14:08 -04:00
Paul Eggert
0f2ed59206 Spelling fixes.
* lisp/ses.el (ses-file-format-extend-parameter-list): Rename from
ses-file-format-extend-paramter-list.  All uses changed.
* lisp/gnus-cloud.el (gnus-cloud-parse-version-1): Fix misspelling
of ":delete".
2014-09-11 12:44:25 -07:00
Glenn Morris
62fca47221 Merge from emacs-24; up to 2014-07-04T02:28:54Z!dmantipov@yandex.ru 2014-09-02 21:21:40 -07:00
Fabián Ezequiel Gallina
0e4c8f1856 * lisp/progmodes/python.el (python-indent-post-self-insert-function):
Avoid electric colon at beginning-of-defun. 

* test/automated/python-tests.el:
(python-indent-electric-colon-1): New test.  (Bug#18228)
2014-09-01 19:51:46 -03:00
Glenn Morris
6d26235315 Merge from emacs-24; up to 2014-07-02T00:57:53Z!juri@jurta.org 2014-08-27 18:59:29 -07:00
Sam Steingold
3f05baa175 Extract python-new-pythonpath to handle PYTHONPATH in user code
* lisp/progmodes/python.el (python-new-pythonpath): Extract from
`python-shell-calculate-process-environment'.
2014-08-20 11:33:10 -04:00
Stefan Monnier
5d3c0a067f * lisp/progmodes/python.el (python-shell-prompt-detect): Remove redundant
executable-find.

Fixes: debbugs:18244
2014-08-18 12:11:43 -04:00
Fabián Ezequiel Gallina
5ea39c0613 * lisp/progmodes/python.el: Fix completions inside (i)pdb.
(python-shell-completion-pdb-string-code): Make obsolete.
(python-shell-completion-get-completions): Use
python-shell-completion-string-code resending setup code
continuously for (i)pdb.
2014-08-04 18:35:17 -03:00
Fabián Ezequiel Gallina
01c600f6d6 * progmodes/python.el: Completion code cleanups.
(python-shell-completion-get-completions): Detect and send import
statements directly to completion function.
(python-shell-completion-at-point): Simplify prompt calculation
and import vs input completion logic.
2014-08-02 19:52:55 -03:00
Fabián Ezequiel Gallina
bc1ce1df86 * lisp/progmodes/python.el: Shell output capture enhancements.
(python-shell-accept-process-output): New function.
(inferior-python-mode)
(python-shell-send-setup-code): Use it.
2014-07-31 21:18:19 -03:00
Fabián Ezequiel Gallina
6628be853e * lisp/progmodes/python.el (inferior-python-mode): Make input prompts
read-only.
2014-07-28 18:07:10 -03:00
Glenn Morris
da41ffdd08 Merge from emacs-24; up to 2014-06-26T06:55:15Z!rgm@gnu.org 2014-07-28 05:39:09 -04:00
Fabián Ezequiel Gallina
7daa4ff121 Parse completion input in a iPython friendly way.
* lisp/progmodes/python.el
(python-shell-completion-at-point): Rename from
python-shell-completion-complete-at-point.
(inferior-python-mode): Use it.
(python-completion-at-point): Rename from
python-completion-complete-at-point.  Parse input up to first
backward occurrence of whitespace, open-paren, close-paren or
string delimiter.
(python-mode): Use it.

Fixes: debbugs:18084
2014-07-28 01:32:28 -03:00
Fabián Ezequiel Gallina
4256626a7a Prevent Python process shell buffer to pop twice.
* lisp/progmodes/python.el (python-shell-switch-to-shell): Do not call
pop-to-buffer.
2014-07-28 00:58:06 -03:00
Fabián Ezequiel Gallina
ca43b53625 * lisp/progmodes/python.el
(python-shell-with-shell-buffer): New macro.
(python-shell-font-lock-get-or-create-buffer)
(python-shell-font-lock-kill-buffer)
(python-shell-font-lock-with-font-lock-buffer)
(python-shell-font-lock-cleanup-buffer)
(python-shell-font-lock-toggle): Use it.
(python-shell-font-lock-turn-on)
(python-shell-font-lock-turn-off): Use it.  Make command.
2014-07-28 00:35:37 -03:00
Fabián Ezequiel Gallina
f5bed1021b Grab all Python process output before inferior-python-mode hooks.
* lisp/progmodes/python.el (inferior-python-mode): Call
accept-process-output and sit-for to ensure all output for process
has been received before running hooks.
(python-shell-internal-get-or-create-process): Cleanup
accept-process-output and sit-for calls.
2014-07-27 23:47:29 -03:00
Fabián Ezequiel Gallina
72c64ae95a More robust shell startup and code setup.
* lisp/progmodes/python.el (python-shell-make-comint): Remove
accept-process-output call.
(python-shell-get-buffer): Return current buffer if major-mode is
inferior-python-mode.
(python-shell-get-or-create-process): Use it.
(python-shell-send-setup-code): Send all setup code in one string,
output success message and accept-process-output.
2014-07-27 22:41:29 -03:00
Fabián Ezequiel Gallina
c76059efc6 Cleanup error signals.
* lisp/progmodes/python.el
(python-indent-shift-left): Use user-error instead.
(python-shell-prompt-detect): Use lwarn with python group.
(python-completion-complete-at-point)
(python-eldoc--get-doc-at-point): Don't signal error.

Fixes: debbugs:18067
2014-07-27 04:05:13 -03:00
Fabián Ezequiel Gallina
4b03be01ce Support for packages in Python shell.
* lisp/progmodes/python.el (python-shell--package-depth): New var.
(python-shell-package-enable): New command.
(python-util-list-directories, python-util-list-files)
(python-util-list-packages): New functions.

Fixes: debbugs:13570
2014-07-27 03:39:17 -03:00
Glenn Morris
9578a71f2e * python.el (python-shell-enable-font-lock): Fix typo in earlier change. 2014-07-26 22:59:49 -04:00
Fabián Ezequiel Gallina
a6dc66a544 Faster comint output.
* lisp/progmodes/python.el:
(python-comint-output-filter-function): Make obsolete.
(python-comint-postoutput-scroll-to-bottom): New function.
(inferior-python-mode): Set comint-output-filter-functions to a
minimum.

Fixes: debbugs:16875
2014-07-26 23:02:38 -03:00
Fabián Ezequiel Gallina
85bc77b270 * lisp/progmodes/python.el (inferior-python-mode): Doc fix. 2014-07-26 22:36:48 -03:00
Fabián Ezequiel Gallina
ef29dc9b14 * lisp/progmodes/python.el (python-shell-font-lock-post-command-hook):
Safeguard current point and undo history.
2014-07-26 22:00:26 -03:00
Fabián Ezequiel Gallina
60cc81af68 Robust shell syntax highlighting. (Bug#18084, Bug#16875)
* lisp/progmodes/python.el:
(python-shell-prompt-input-regexps): Add iPython block prompt.
(python-shell-output-syntax-table): Delete var.
(python-shell-font-lock-with-font-lock-buffer): New macro.
(python-shell-font-lock-get-or-create-buffer)
(python-shell-font-lock-kill-buffer)
(python-shell-font-lock-cleanup-buffer)
(python-shell-font-lock-post-command-hook)
(python-shell-font-lock-turn-off): New functions.
(python-shell-font-lock-turn-on): New function.
(inferior-python-mode): Use it.
(python-shell-font-lock-toggle): New command.
(python-shell-font-lock-enable): Rename from
python-shell-enable-font-lock.
(run-python-internal): Use it.
(python-shell-font-lock-comint-output-filter-function): New function.
(python-shell-comint-end-of-output-p): New function.
(python-shell-output-filter): Use it.
(python-util-comint-last-prompt): New function.
(python-util-text-properties-replace-name): New function.
2014-07-26 20:43:51 -03:00
Paul Eggert
ad4c5263f5 Spelling fixes. 2014-07-21 07:41:19 -07:00
Glenn Morris
190644a011 Merge from emacs-24; up to 2014-06-25T10:17:41Z!rgm@gnu.org 2014-07-21 02:03:08 -04:00
Fabián Ezequiel Gallina
1651cf2ed5 * lisp/progmodes/python.el: Add comment about pipe buffering and
solutions for missing/delayed output in inferior Python shells.

Fixes: debbugs:17304
2014-07-20 16:51:16 -03:00
Fabián Ezequiel Gallina
f72d7fa132 * lisp/progmodes/python.el (python-mode): Don't set
mode-require-final-newline.

Fixes: debbugs:17990
2014-07-20 15:28:50 -03:00
Fabián Ezequiel Gallina
b06a0dff84 Make python.el work with IPython automatically.
* lisp/progmodes/python.el:
(python-shell-completion-setup-code): New value supporting iPython.
(python-shell-completion-string-code): New value supporting iPython.
(python-shell-completion-get-completions): Use them.
(python-shell-completion-module-string-code): Make obsolete.
(python-shell-prompt-input-regexps)
(python-shell-prompt-output-regexps): Add safeguard for ipdb.
(python-shell-output-filter): Fix comment typo.

* test/automated/python-tests.el:
(python-util-clone-local-variables-1): Fix test.

Fixes: debbugs:15510
2014-07-20 15:12:30 -03:00
Fabián Ezequiel Gallina
eb8cb39e89 Fix Python shell prompts detection for remote hosts.
* lisp/progmodes/python.el (python-shell-prompt-detect): Replace
call-process with process-file and make it more robust.
2014-07-19 16:19:47 -03:00
Fabián Ezequiel Gallina
d949ade3c1 Autodetect Python shell prompts.
* lisp/progmodes/python.el:
(python-shell-interpreter-interactive-arg)
(python-shell-prompt-detect-enabled)
(python-shell-prompt-detect-failure-warning)
(python-shell-prompt-input-regexps)
(python-shell-prompt-output-regexps): New vars.
(python-shell-prompt-calculated-input-regexp)
(python-shell-prompt-calculated-output-regexp): New vars.
(python-shell-get-process-name)
(python-shell-internal-get-process-name)
(python-shell-output-filter)
(python-shell-completion-get-completions): Use them.
(python-shell-prompt-detect)
(python-shell-prompt-validate-regexps): New functions.
(python-shell-prompt-set-calculated-regexps): New function.
(inferior-python-mode): Use it.  Also honor overriden
python-shell-interpreter and python-shell-interpreter-args.
(python-shell-make-comint): Honor overriden
python-shell-interpreter and python-shell-interpreter-args.
(python-shell-get-or-create-process): Make it testable by allowing
to call run-python non-interactively.
(python-util-valid-regexp-p): New function.
(python-shell-prompt-regexp, python-shell-prompt-block-regexp)
(python-shell-prompt-output-regexp)
(python-shell-prompt-pdb-regexp): Use it as defcustom :safe.

* test/automated/python-tests.el (python-shell-make-comint-1):
(python-shell-make-comint-2): Fix indentation.
(python-shell-make-comint-3)
(python-shell-make-comint-4): New tests.
(python-shell-get-or-create-process-1): Fix test.
(python-shell-get-or-create-process-2)
(python-shell-get-or-create-process-3): New tests.
(python-shell-internal-get-or-create-process-1): Fix test.
(python-shell-prompt-detect-1): New test.
(python-shell-prompt-detect-2): New test.  (Bug#17370)
(python-shell-prompt-detect-3)
(python-shell-prompt-detect-4)
(python-shell-prompt-detect-5)
(python-shell-prompt-detect-6)
(python-shell-prompt-validate-regexps-1)
(python-shell-prompt-validate-regexps-2)
(python-shell-prompt-validate-regexps-3)
(python-shell-prompt-validate-regexps-4)
(python-shell-prompt-validate-regexps-5)
(python-shell-prompt-validate-regexps-6)
(python-shell-prompt-validate-regexps-7)
(python-shell-prompt-set-calculated-regexps-1)
(python-shell-prompt-set-calculated-regexps-2)
(python-shell-prompt-set-calculated-regexps-3)
(python-shell-prompt-set-calculated-regexps-4)
(python-shell-prompt-set-calculated-regexps-5)
(python-shell-prompt-set-calculated-regexps-6)
(python-util-valid-regexp-p-1): New tests.
2014-07-19 10:13:07 -03:00
Glenn Morris
b39c4d7b33 Merge from emacs-24; up to 2014-06-22T05:00:14Z!dmantipov@yandex.ru 2014-07-12 10:53:29 -07:00
Fabián Ezequiel Gallina
fded0b4a15 Fix dedenters and electric colon handling.
* lisp/progmodes/python.el
(python-rx-constituents): Add dedenter and block-ender.
(python-indent-dedenters, python-indent-block-enders): Delete.
(python-indent-context): Return new case for dedenter-statement.
(python-indent-calculate-indentation): Handle new case.
(python-indent-calculate-levels): Fix levels calculation for
dedenter statements.
(python-indent-post-self-insert-function): Fix colon handling.
(python-info-dedenter-opening-block-message): New function.
(python-indent-line): Use it.
(python-info-closing-block)
(python-info-closing-block-message): Remove.
(python-info-dedenter-opening-block-position)
(python-info-dedenter-opening-block-positions)
(python-info-dedenter-statement-p): New functions.

* test/automated/python-tests.el
(python-indent-block-enders-1)
(python-indent-block-enders-2): Fix tests.
(python-indent-block-enders-3)
(python-indent-block-enders-4)
(python-indent-block-enders-5)
(python-indent-dedenters-1)
(python-indent-dedenters-2): Remove tests.
(python-indent-dedenters-1)
(python-indent-dedenters-2)
(python-indent-dedenters-3)
(python-indent-dedenters-4)
(python-indent-dedenters-5)
(python-indent-dedenters-6)
(python-indent-dedenters-7)
(python-info-dedenter-opening-block-position-1)
(python-info-dedenter-opening-block-position-2)
(python-info-dedenter-opening-block-position-3)
(python-info-dedenter-opening-block-positions-1)
(python-info-dedenter-opening-block-positions-2)
(python-info-dedenter-opening-block-positions-3)
(python-info-dedenter-opening-block-positions-4)
(python-info-dedenter-opening-block-positions-5)
(python-info-dedenter-opening-block-message-1)
(python-info-dedenter-opening-block-message-2)
(python-info-dedenter-opening-block-message-3)
(python-info-dedenter-opening-block-message-4)
(python-info-dedenter-opening-block-message-5)
(python-info-dedenter-statement-p-1)
(python-info-dedenter-statement-p-2)
(python-info-dedenter-statement-p-3)
(python-info-dedenter-statement-p-4)
(python-info-dedenter-statement-p-5): New tests.

Fixes: debbugs:15163
2014-07-09 00:55:53 -03:00
Glenn Morris
2d3c9015c7 Merge from emacs-24; up to 2014-06-15T04:52:34Z!eli@barzilay.org 2014-07-02 23:00:53 -07:00
Fabián Ezequiel Gallina
3acd6262d9 * lisp/progmodes/python.el (python-indent-post-self-insert-function):
Enhancements to electric indentation behavior inside
parens.

* test/automated/python-tests.el
(python-tests-self-insert): New function.
(python-triple-quote-pairing): Use it.
(python-util-forward-comment-1): New test. (Bug#17658)
2014-07-01 00:54:11 -03:00