Commit graph

568 commits

Author SHA1 Message Date
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
Glenn Morris
c400516ab1 Merge from emacs-24; up to 2014-06-06T02:22:40Z!monnier@iro.umontreal.ca 2014-06-21 12:45:59 -07:00
Fabián Ezequiel Gallina
656f99beeb Fix completion retrieval parsing.
* progmodes/python.el (python-mode):
(python-util-strip-string): New function.
(python-shell-completion-get-completions): Use it.

* automated/python-tests.el (python-util-strip-string-1): New test.

Fixes: debbugs:17209
2014-06-21 11:14:54 -03:00
Fabián Ezequiel Gallina
3114d9e702 Enhancements for outline integration.
* lisp/progmodes/python.el (python-mode): Properly set
outline-heading-end-regexp so that comments after colons for
defuns are supported.

Fixes: debbugs:17796
2014-06-21 08:26:43 -03:00
Matthias Meulien
c77f4a90b2 * lisp/progmodes/python.el (import skeleton): New skeleton.
(python-mode-map): Bind it.

Fixes: debbugs:17672
2014-06-11 22:35:26 -04:00
Matthias Meulien
82fb2a08db * lisp/progmodes/python.el (class skeleton): Don't erase last char of class
name.

Fixes: debbugs:17683
2014-06-11 22:24:24 -04:00
Eric Hanchrow
846e6e843e * lisp/progmodes/python.el (run-python): Use read-shell-command. 2014-06-11 21:45:33 -04:00
Sam Steingold
b8e11d4102 avoid unnecessary questions
* lisp/progmodes/python.el (python-shell-get-or-create-process):
Do not bind `current-prefix-arg' so that C-c C-z does not talk
back unless requested.
2014-05-14 14:17:05 -04:00
João Távora
7aecc2f6ca Fix triple-quoting electricity in python-mode
* lisp/progmodes/python.el (python-electric-pair-string-delimiter): Fix
triple-quoting electricity. 

* test/automated/python-tests.el (python-triple-quote-pairing): New test.
(python-syntax-after-python-backspace): New test.

Fixes: debbugs:17192
2014-04-07 00:23:45 +01:00
Juanma Barranquero
fd16b061a9 lisp/progmodes/python.el: Fix docstring typos.
(defconst, python-syntax-count-quotes)
(python-indent-region, python-indent-shift-right)
(python-indent-dedent-line-backspace, python-nav-backward-sexp)
(python-nav-backward-sexp-safe, python-nav-backward-up-list)
(python-shell-prompt-block-regexp, python-shell-prompt-output-regexp)
(python-shell-prompt-pdb-regexp, python-shell-enable-font-lock)
(inferior-python-mode, python-shell-make-comint, run-python-internal)
(python-shell-buffer-substring, python-shell-send-buffer)
(python-pdbtrack-activate, python-pdbtrack-stacktrace-info-regexp)
(python-completion-complete-at-point, python-fill-docstring-style)
(python-eldoc-function, python-imenu-format-item-label)
(python-imenu-format-parent-item-label)
(python-imenu-format-parent-item-jump-label)
(python-imenu--build-tree, python-imenu-create-index)
(python-imenu-create-flat-index): Fix docstring typos.
(python-indent-context, python-shell-prompt-regexp, run-python):
Remove superfluous backslashes.
(python-indent-line, python-nav-beginning-of-defun)
(python-shell-get-buffer, python-shell-get-process)
(python-info-current-defun, python-info-current-line-comment-p)
(python-info-current-line-empty-p, python-util-popn): Doc fixes.
(python-indent-post-self-insert-function, python-shell-send-file)
(python-shell-completion-get-completions)
(python-shell-completion-complete-or-indent)
(python-eldoc--get-doc-at-point): Reflow docstrings.
2014-03-15 18:37:58 +01:00
Glenn Morris
34dc21db6e Replace "Maintainer: FSF" with the emacs-devel mailing address 2014-02-09 17:34:22 -08:00
Fabián Ezequiel Gallina
dd27d13b50 * progmodes/python.el (python-shell-send-string):
(python-shell-send-string-no-output): Fix docstring.

Fixes: debbugs:16547
2014-02-04 16:35:52 -03:00
Paul Eggert
ba3189039a Update copyright year to 2014 by running admin/update-copyright. 2014-01-01 07:43:34 +00:00
Fabián Ezequiel Gallina
fbcc63a317 * lisp/progmodes/python.el: Use lexical-binding.
(python-nav-beginning-of-defun): Stop searching ASAP.
2013-12-26 13:45:19 -03:00
Fabián Ezequiel Gallina
0137922173 * lisp/progmodes/python.el:
(python-nav--lisp-forward-sexp): New function.
(python-nav--lisp-forward-sexp-safe): Use it.  Rename from
python-nav-lisp-forward-sexp-safe.
(python-nav--forward-sexp): New argument SAFE allows switching
forward sexp movement behavior for parens.
(python-nav-forward-sexp): Throw errors on unterminated parens.
(python-nav-backward-sexp, python-nav-forward-sexp-safe)
(python-nav-backward-sexp-safe): New functions.
(python-shell-buffer-substring): Use
`python-nav-forward-sexp-safe'.

* test/automated/python-tests.el
(python-nav-lisp-forward-sexp-safe-1): Remove test.
(python-nav-forward-sexp-safe-1): New test.

Fixes: debbugs:16191
2013-12-25 15:07:31 -03:00
Fabián Ezequiel Gallina
89c868adee * lisp/progmodes/python.el (python-nav-beginning-of-statement): Speed
up.

Fixes: debbugs:15295
2013-12-24 16:48:40 -03:00
Fabián Ezequiel Gallina
ce03045172 * lisp/progmodes/python.el (python-pdbtrack-stacktrace-info-regexp):
Also match after beginning of line.
(python-pdbtrack-set-tracked-buffer): Fix logic for remote
files.  Thanks to Russell Sim.

Fixes: debbugs:15378
2013-12-12 21:56:12 -03:00
Fabián Ezequiel Gallina
bc9222c934 * lisp/progmodes/python.el (python-indent-calculate-indentation): Fix
de-denters cornercase.

* test/automated/python-tests.el (python-indent-dedenters-2): New test.

Fixes: debbugs:15731
2013-12-12 20:32:05 -03:00
Fabián Ezequiel Gallina
09faee72dd * lisp/progmodes/python.el (python-indent-context)
(python-indent-calculate-indentation): Fix auto-identation
behavior for comment blocks.

* test/automated/python-tests.el (python-indent-after-comment-1)
(python-indent-after-comment-2): New tests.

Fixes: debbugs:15916
2013-12-12 02:37:09 -03:00
Nathan Trapuzzano
f54de22e65 * lisp/progmodes/python.el (python-indent-calculate-indentation): When
determining indentation, don't treat "return", "pass", etc., as
operators when they are just string constituents. 

* automated/python-test.el (python-indent-block-enders-1): Rename
from python-indent-block-enders.
(python-indent-block-enders-2): New test.

Fixes: debbugs:15812
2013-12-12 00:47:41 -03:00
Stefan Monnier
bd15d9d1ad * lisp/progmodes/python.el (python-mode-map): Remove binding for ":".
(python-indent-electric-colon): Remove command.
(python-indent-post-self-insert-function): Integrate the previous code
of python-indent-electric-colon.  Make it conditional on
electric-indent-mode.
(python-mode): Add ?: to electric-indent-chars.
Move python-indent-post-self-insert-function to the end of
post-self-insert-hook.
2013-11-28 21:03:39 -05:00
Glenn Morris
0bf3f0fadf * lisp/progmodes/python.el (python-indent-guess-indent-offset):
Avoid corner-case error.

Fixes: debbugs:15975
2013-11-25 22:15:49 -05:00
Glenn Morris
3cfb6af3af * python.el (python-shell-send-file): Add option to delete file when done.
(python-shell-send-string, python-shell-send-region): Use it.

Fixes: debbugs:15647
2013-11-23 11:39:50 -08:00
Glenn Morris
40dd812fa3 Revert previous python.el change 2013-11-22 20:20:31 -08:00
Jorgen Schaefer
09b0f3d9cf * lisp/progmodes/python.el (python-shell--save-temp-file): Tiny change
Delete temp-file when done.

Fixes: debbugs:15647
2013-11-22 19:13:16 -08:00
Bozhidar Batsov
ae1f1ce1e2 * lisp/progmodes/python.el (python-mode): Remove incorrect text from docstring.
* lisp/progmodes/scheme.el (scheme-mode): Remove incorrect text from docstring.
* lisp/progmodes/prolog.el (prolog-mode): Remove incorrect text from docstring.
* lisp/emacs-lisp/lisp-mode.el (lisp-mode, lisp-interaction-mode, emacs-lisp-mode):
Remove incorrect text from docstring.
2013-11-05 11:47:47 +02:00
Stefan Monnier
e5afbcacfa * lisp/progmodes/python.el: Fix up last change.
(python-shell--save-temp-file): New function.
(python-shell-send-string): Use it.  Remove `msg' arg.  Don't assume
`string' comes from the current buffer.
(python-shell-send-string-no-output): Remove `msg' arg.
(python--use-fake-loc): New var.
(python-shell-buffer-substring): Obey it.  Try to compensate for the
extra coding line added by python-shell--save-temp-file.
(python-shell-send-region): Use python-shell--save-temp-file and
python-shell-send-file directly.  Add `nomain' argument.
(python-shell-send-buffer): Use python-shell-send-region.
(python-electric-pair-string-delimiter): New function.
(python-mode): Use it.
2013-11-04 14:14:58 -05:00
Stefan Monnier
195ee2f0a9 * lisp/progmodes/python.el (python-shell-get-buffer): New function.
(python-shell-get-process): Use it.
(python-shell-send-string): Always use utf-8 and add a cookie to tell
Python which encoding was used.  Don't split-string since we only care
about the first line.  Return the temp-file, if applicable.
(python-shell-send-region): Tell compile.el how to turn locations in
the temp-file into locations in the source buffer.
2013-10-29 21:28:36 -04:00
Stefan Monnier
2abb4e6560 * lisp/electric.el (electric-indent-inhibit): New var.
(electric-indent-post-self-insert-function): Use it.
* lisp/progmodes/python.el (python-mode): Set it.
2013-10-07 14:51:26 -04:00
Glenn Morris
2a08047aed Improve previous interpreter-mode-alist change
* lisp/files.el (interpreter-mode-alist): Remove \\` \\' parts.
(set-auto-mode): Don't regexp-quote elements.

* lisp/progmodes/python.el (interpreter-mode-alist): Remove \\` \\'.

* lisp/progmodes/cc-mode.el (interpreter-mode-alist):
* lisp/progmodes/ruby-mode.el (interpreter-mode-alist):
Revert previous change.

* etc/NEWS: Update.
2013-09-10 23:44:35 -07:00
Glenn Morris
93ef404dc9 Tweak previous change 2013-09-10 16:46:25 -04:00
Glenn Morris
1af4c2203c Treat interpreter-mode-alist as alist of regexps, not literals
Cf http://lists.gnu.org/archive/html/emacs-devel/2005-08/msg00472.html

* lisp/files.el (interpreter-mode-alist): Convert to regexps.
(set-auto-mode): Adapt for this. 

* lisp/progmodes/cperl-mode.el (cperl-clobber-mode-lists):
Comment out unused variable.

* lisp/progmodes/cc-mode.el (interpreter-mode-alist):
* lisp/progmodes/python.el (interpreter-mode-alist):
* lisp/progmodes/ruby-mode.el (interpreter-mode-alist): Convert to regexps.

* lisp/progmodes/sh-script.el (sh-set-shell):
No longer use interpreter-mode-alist to get list of shells.

* etc/NEWS: Mention this.

Fixes: debbugs:15306
2013-09-10 16:38:52 -04:00
Paul Eggert
71bd1a0084 Spelling fixes and tidy up a comment. 2013-09-09 09:26:38 -07:00
Stefan Monnier
c0458e0b21 * lisp/subr.el (pop): Use `car-safe'.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Remove hack
to detect unused `pop' return value.

* lisp/emacs-lisp/advice.el (defadvice): Add indent rule.

* lisp/international/mule-cmds.el: Require CL.
(find-coding-systems-for-charsets): Avoid add-to-list.
(sanitize-coding-system-list): New function, extracted from
select-safe-coding-system-interactively.
(select-safe-coding-system-interactively): Use it.
(read-input-method-name): Accept symbols for `default'.

* lisp/progmodes/python.el (python-nav-beginning-of-block): Remove unused
var `block-regexp'.
(python-nav--forward-sexp): Remove unused var `re-search-fn'.
(python-fill-string): Remove unused var `marker'.
(python-skeleton-add-menu-items): Remove unused var `items'.
2013-09-04 23:46:34 -04:00
Fabián Ezequiel Gallina
96edb67781 Format code sent to Python shell for robustness.
* progmodes/python.el (python-shell-buffer-substring): New
function.
(python-shell-send-region, python-shell-send-buffer): Use it.
2013-09-02 10:56:03 -03:00
Fabián Ezequiel Gallina
e5c144d64d * progmodes/python.el (python-nav-if-name-main): New command. 2013-09-02 00:37:18 -03:00
Fabián Ezequiel Gallina
cd16c5f1f5 * progmodes/python.el (python-shell-completion-get-completions):
Drop use of deleted `comint-last-prompt-overlay'.
2013-09-02 00:21:13 -03:00
Stefan Monnier
9e89d835b0 * lisp/progmodes/python.el (python-font-lock-keywords): Don't return nil
from a matcher-function unless there's no more matches.

Fixes: debbugs:15161
2013-08-26 22:41:41 -04:00