This is a backport of Stefan Monnier's migration to the new font-lock
machinery (introduced in 2010-09-10T23:13:42Z!monnier@iro.umontreal.ca).
New Vars:
+ python-syntax-propertize-function
Deleted Vars:
+ python-font-lock-syntactic-keywords
This reverts commit f4d086427343eb0b8bc91355388d2437c568b1f6, reversing
changes made to 8f697fd2ef23a9e1d9a06ac8ca419d76ccedb27d.
While the fix worked with empty triple quoted strings it broke simpler cases
like these:
"""
def someting(a, b, c):
"
"""
or
'''
def someting(a, b, c):
'
'''
Another approach is needed for giving triple quoted string the correct syntax.
`python-nav-beginning-of-defun' and
`python-beginning-of-defun-function' have changed and now they don't
handle decorators anymore.
`python-end-of-defun-function' is now smart enough to detect the real
ending of the current defun.
`python-shell-send-defun' always sends the outermost defun and
includes decorators. When called with prefix argument the decorators
are skipped.
`python-info-current-defun' has been modified to use the new defun
movement API.
New Functions:
+ python-info-looking-at-beginning-of-defun
This is a simplified version of @dandavison pull request (thanks dan!)
`python-nav-list-defun-positions' now uses
`python-nav-list-defun-positions-cache' buffer local variable to store
cached values of defun positions.
`python-nav-jump-to-defun' now benefits from this new cache and if
called with prefix argument it will invalidate it so new defuns are
scanned.
New Vars:
+ `python-nav-list-defun-positions-cache'
`python-indent-line' and `python-indent-electric-colon' now uses the
new `python-info-closing-block-message' function that takes care of
messaging the block the current line is closing (if applicable).
New Functions:
+ `python-info-closing-block-message'
For this to work `python-indent-post-self-insert-function' is added to
the `post-self-insert-hook.' when python-mode is initialized.
New functions:
+ `python-indent-post-self-insert-function'
The module completer wants e.g. 'from xxx' as input, not just 'xxx'.
This change also causes all modules to be offered as completions to
'from ', whereas previously this was regarded as empty input.
The comint prompt retrieval logic was failing on
`python-shell-completion--do-completion-at-point' when calls to it
happened from outside the process buffer.
Calling `end-of-defun' on a python file will now do the correct thing,
even for cases like this:
def fib(n):
if n < 2:
# base cases
return n
else:
return fib(n - 2) + fib(n - 1)
Backslashed continuations with parens in the middle are now handled
correctly. Things like this are now indented properly:
objects = Thing.objects.all() \
.filter(
type="toy",
status="bought"
subtype="car"
) \
.aggregate(
Sum('amount')
) \
.values_list()
New Functions:
* `python-info-beginning-of-backlash' returns the point where a
backslashed line start.
This commit includes:
* A more robust implementation of `python-indent-calculate-indentation'.
* enhancements on `python-indent-context' when dealing with backslashes
and blocks.
* Many changes, comments and enhancements to
`python-indent-calculate-indentation'. Many of them especially focused
to match pep8 guidelines, being this one the most important new one:
http://mail.python.org/pipermail/python-dev/2011-June/111760.html
* Better `python-info-line-ends-backslash-p' that would work as intended
on narrowed buffers.
* `python-info-continuation-line-p' now does what's supposed to do.
* Enhanced implementation of `python-info-continuation-line-p',
`python-info-block-continuation-line-p' and
`python-info-assignment-continuation-line-p'
New Functions:
* `python-util-forward-comment' a simple replacement `forward-comment'
with some necessary enhancements.
`python-shell-completion--do-completion-at-point' has been modified in
order to support different completion contexts easily.
New vars:
+ python-shell-completion-pdb-string-code