Commit graph

240 commits

Author SHA1 Message Date
Ken Manheimer 2448f1b655 Slightly more lenient pdbtrack prompt recognition, for people who use
eg "pdb>".
2003-05-01 21:07:32 +00:00
Ken Manheimer 595adce09b Allow for multiple parens around pdb prompt for (new) nested debugging
sessions (and some cosmetic wording changes).
2003-05-01 20:46:14 +00:00
Ken Manheimer ed6000a993 py-pdbtrack-grub-for-buffer(): Rectified some logic errors i
introduced when shifting around some code, and added some redundancy
to reduce chances of hitting the wrong source code.  (This is
experimental - it will improve the accuracy, but will reduce the
ability of the user to deliberately select the buffer they want the
buffer grubbing stuff to find.  I think the accuracy improvement will
be worth it, but am not sure, so may remove this.)
2003-03-03 17:09:44 +00:00
Ken Manheimer ad428cd1cd Guard advancing past leading meta-comments. 2003-03-03 04:05:03 +00:00
Ken Manheimer e7aca521db Enhanced pdbtrack to provide for source code that's not findable by
the reported path.  (Eg, precompiled scripts with a file path suitable
for a different host, scripts actually running on a remote system or
with no valid path, like Zope through-the-web python scripts.)

On failing to find the code on the reported path, pdbtrack takes the
function name and looks through the buffers, from most to least
recent, seeking the first python-mode buffer that either is named for
the function or has a definition (def or class) for that function.  So
to get source tracking for code that's not located where the path
indicates, you put a copy of the script in a buffer, and pdbtrack will
find it.

Also, fixed a small bug so pdbtrack now properly presents the overlay
arrow when you run the pdb 'w'here command.
2003-03-03 00:35:32 +00:00
Skip Montanaro 6c5bc3457c Bernhard Herzog's paragraph and string-filling code. I've been using it for
a month or two with great success.  Barry may want to tweak it some, but I
think it's a worthwhile enough addition to get some more people trying it
out.
2002-12-31 16:56:20 +00:00
Barry Warsaw 644991fa35 (py-parse-state-re): Remove the "if" from the regular expression.
This fixes an indentation bug reported by Jeremy when seeing multiple
list comprehensions like so:

    [x for x in seq
     if blah(x)]

    # ...

    [y for y in seq
     if blah(y)]

The reason this broke is because this regexp caused the "find a safe
parsing start location higher up in the file" test to erroneously find
the if in the listcomp.  I think the other keywords in this regexp are
fine and good enough.

After a weekend of testing, I can't find any adverse effects.
2002-10-21 15:58:29 +00:00
Barry Warsaw 7f232121c9 (py-pychecker-run): Fix calculation of last command to include the
filename of the current buffer.
2002-09-28 18:17:56 +00:00
Barry Warsaw f31ff27c57 (py-pychecker-run): Use the last pychecker invocation as the default
contents of the next command.
2002-07-17 21:25:43 +00:00
Barry Warsaw 1f4fed68e9 We need to (require 'compile) to guarantee that compile-internal is
defined.  /Really/ closes SF # 580631.
2002-07-17 13:45:00 +00:00
Barry Warsaw 32a03967b7 (py-imenu-create-index-function): Skip over stuff that looks like code
but which is in a comment or string.  Closes SF bug # 572341 reported
by Adrian van den Dries.
2002-07-16 16:04:13 +00:00
Barry Warsaw daa192104d (py-pychecker-run): Thomas Heller points out that this function messes
up the compile command's history.  Fix that by using compile-internal.

Fixes SF bug # 580631
2002-07-16 15:56:28 +00:00
Barry Warsaw f070cce6af (py-goto-statement-below): Watch out for landing in a triple quoted
string with text in column zero.  Skip that stuff when looking for the
"first statement following the statement containing point".
2002-05-23 19:42:16 +00:00
Barry Warsaw 69c9266f45 (py-execute-region): Do the blank line skipping inside the
save-excursion so that when the function is complete, point is
preserved.
2002-05-12 17:37:46 +00:00
Barry Warsaw 5dfc7afff9 Watch out for older XEmacsen for which requiring info-look doesn't
define info-lookup-maybe-add-help.
2002-04-30 18:58:52 +00:00
Barry Warsaw 17afa13a9f (py-comint-output-filter-function): Put the pop-to-buffer call inside
the `when' condition so other non-Python shell comint changes won't
cause random buffers to pop.
2002-04-26 15:49:52 +00:00
Barry Warsaw cf22c826a6 Fix typo in the setup of interpreter-mode-alist. 2002-04-25 21:46:33 +00:00
Barry Warsaw 884916112e SF patch #510288 by Kevin J. Butler, mod'd by Barry. This provides
better auto-recognition of a Jython file vs. a CPython (or agnostic)
file by looking at the #! line more closely, and inspecting the import
statements in the first 20000 bytes (configurable).  Specifically,

(py-import-check-point-max): New variable, controlling how far into
the buffer it will search for import statements.

(py-jpython-packages): List of package names that are Jython-ish.

(py-shell-alist): List of #! line programs and the modes associated
with them.

(jpython-mode-hook): Extra hook that runs when entering jpython-mode
(what about Jython mode? <20k wink>).

(py-choose-shell-by-shebang, py-choose-shell-by-import,
py-choose-shell): New functions.

(python-mode): Use py-choose-shell.

(jpython-mode): New command.

(py-execute-region): Don't use my previous hacky attempt at doing
this, use the new py-choose-shell function.

One other thing this file now does: it attempts to add the proper
hooks to interpreter-mode-alist and auto-mode-alist if they aren't
already there.  Might help with Emacs users since that editor doesn't
come with python-mode by default.
2002-04-25 21:31:47 +00:00
Barry Warsaw 4aab68e1c1 (py-execute-region): Alexander Schmolck points out that leading
whitespace can hose the needs-if test.  So just skip all blank lines
at the start of the region right off the bat.
2002-04-25 19:17:42 +00:00
Barry Warsaw 13caba30b8 (py-comint-output-filter-function): Add a pop-to-buffer call so you
always get to see the result of e.g. a py-execute-region.  Funny, this
bugged both me /and/ Guido!
2002-04-25 16:26:38 +00:00
Barry Warsaw 56bd2edeef (py-shell-hook): A new hook variable, run at the end of py-shell.
Allows for some customization of the underlying comint buffer.

(py-shell): Call the new hook.

(info-lookup-maybe-add-help): A new call suggested by Milan Zamazal to
make lookups in the Info documentation easier.
2002-04-25 15:44:17 +00:00
Barry Warsaw 0494955b8f Merge in Skip's last few updates w.r.t. py-help-at-point:
(py-mode-map): Bind py-help-at-point to f1 as well as C-c C-h

(py-help-at-point): Make sure the symbol is quoted so things like
pydoc.help('sys.platform') work correctly.  Also, leave the *Python
Output* buffer in help-mode; this may be a bit more controversial.
2002-04-22 22:05:49 +00:00
Barry Warsaw 29a90f0a7a Some contributions and ideas by Alexander Schmolck: add a keybinding
to call pychecker on the current file, add a face for pseudo
keywords self, None, True, False, and Ellipsis.  Specifically,

(py-pychecker-command, py-pychecker-command-args): New variables.

(py-pseudo-keyword-face): New face variable, defaulting to a copy of
font-lock-keyword-face.

(python-font-lock-keywords): Add an entry for self, None, True, False,
Ellipsis to be rendered in py-pseudo-keyword-face.

(py-pychecker-history): New variable.

(py-mode-map): Bind C-c C-w to py-pychecker-run.

(py-pychecker-run): New command.
2002-04-22 21:48:20 +00:00
Barry Warsaw a7cc43b9e8 Skip Montanaro's contribution (slightly mod'd by Barry) to provide a
"help-on-symbol-at-point" feature which uses pydoc to provide help on
the symbol under point, if available.

Mods include some name changes, a port to Emacs, binding the command
to C-c C-h, and providing a more informative error message if the
symbol's help can't be found (through use of a nasty bare except).

Note also that py-describe-mode has been moved off of C-c C-h m; it's
now just available on C-c ?

Closes SF patch #545439.
2002-04-22 17:15:19 +00:00
Barry Warsaw a0113cd5cd (py-execute-region): If the line at the beginning of the region is a
#! line, use the command on that line as the shell command to use to
execute the region.  I.e. if the region looks like

----------------
#! /usr/bin/env python1.5

print 'hello world'.startswith('hello')
----------------

you'll get an exception! :)

This closes SF bug #232398.
2002-04-22 16:23:29 +00:00
Barry Warsaw b2d5e62d65 (py-execute-region): If you ran this without having visited a
python-mode file, py-which-shell would have been nil and the command
to use would not get set correctly.  This changes things so that 1)
the temporary file has a .py extension, 2) the temporary file is put
into python-mode, and 3) the temporary file's py-which-shell is
captured in a local `shell' variable, which is used to calculate the
command to use.  Closes SF bug #545436.

(py-parse-state): Rip out the XEmacs-specific calls to
buffer-syntactic-context, which can get quite confused if there's an
open paren in column zero say, embedded in a triple quoted string.
This was always a performance hack anyway, and computers are fast
enough now that we should be able to get away with the slower, more
portable, full-parse branch.  Closes SF bug #451841.

Update the comments at the top of the file.
2002-04-22 15:29:27 +00:00
Barry Warsaw d164837856 (py-temp-directory): Add /var/tmp to the list of directories this
searches.  This is added after /tmp.  Closes SF bug #505488, except
that /var/tmp comes after /tmp instead of the patch's suggestion of
putting it before /usr/tmp.
2002-03-18 18:53:56 +00:00
Barry Warsaw d36cfe495e (py-honor-comment-indentation, py-compute-indentation): Fix the
implementation to match the documentation for
py-honor-comment-indentation w.r.t. not nil or t value.  In that case
it should still ignore ## for indentation purposes.  Closes SF bug
#523825, w/ patch provided by Christian Stork (mod'd by Barry).

Python 2.2.1 candidate.
2002-03-15 16:46:46 +00:00
Barry Warsaw 19b1c6156b (py-version): Hopefully fixed my XEmacs settings so this doesn't get
clobbered on checkin.
2001-07-06 20:27:29 +00:00
Barry Warsaw 40fb452be9 (py-continuation-offset): Update docstring to describe that this
additional offset is only applied to continuation lines for block
opening statements.

(py-compute-indentation): Only add py-continuation-offset if
py-statement-opens-block-p is true.
2001-07-06 20:07:13 +00:00
Barry Warsaw e275c42c38 (python-font-lock-keywords): Add "yield" as a keyword to support the
new "simple generators" feature of 2.2.  See PEP 255.
2001-06-19 18:24:42 +00:00
Barry Warsaw fd4c9e87a7 (py-continuation-offset): New variable which controls how much to
indent continuation lines, defined as lines following those that end
in backslash.

(py-compute-indentation): Support for py-continuation-offset.
2001-06-18 23:40:35 +00:00
Barry Warsaw c8c1a5b7b6 (py-pdbtrack-track-stack-file): On Ken's suggestion, add "pdbtrack:"
prefix to the message lines.
2001-04-11 22:27:41 +00:00
Barry Warsaw 4f577d2f47 intermediate 2001-04-11 20:23:17 +00:00
Barry Warsaw 68d486c8f4 (py-parse-state): Teach python-mode how to scan code which follows
multi-line list comprehensions.
2001-02-24 00:09:17 +00:00
Barry Warsaw 715346060a (py-execute-region): This one's easy... kill the temporary file's
buffer after executing its contents.
2001-02-20 23:07:56 +00:00
Barry Warsaw e0c182fb5f (python-font-lock-keywords): Add highlighting of `as' as a keyword,
but only in "import foo as bar" statements (including optional
preceding `from' clause).
2000-12-27 17:41:47 +00:00
Barry Warsaw 3c34bb33ff (py-goto-beginning-of-tqs): When searching backwards for the matching
delimiter, watch out for backslash escaped delimiters.  Also use =
instead of eq for character comparison (because a character is = to
it's integer value, but not eq to it).
2000-10-27 05:00:25 +00:00
Barry Warsaw 99eadf4de9 (py-execute-region): Make sure the new temporary buffer is current for
the insertion of the text.
2000-06-23 20:24:25 +00:00
Barry Warsaw caee2fe35d (py-execute-region): Based on suggestions by Francois Pinard and Skip
Montanaro, handle execution of indented regions by inserting an "if
1:" in front of the block.  This better preserves things like triple
quoted strings and commented regions.  This patch resolves PR#264.
2000-05-23 05:47:43 +00:00
Barry Warsaw 50765abb29 (py-shell): Set the default shell if not set yet. It's sometimes
convenient to call py-shell before the first Python file has been
visited.
1999-08-10 21:49:00 +00:00
Barry Warsaw 5ed843fc52 A few minor Customize changes:
(python): Set defgroup :prefix to "py-" to make variable names cleaner.

(py-jpython-command, py-jpython-command-args): Set :tag for proper
capitalization of JPython in variable name display.
1999-07-28 22:06:06 +00:00
Barry Warsaw 11f215607e (python-mode): Set which interpreter (CPython or JPython) to use the
first time a py buffer is visited during the Emacs session.  This
ensures that py-which-shells is initialized and also guarantees that
the mode lines reflect the correct shell.  First bug found by GvR,
second one has long bugged :) me.

(py-toggle-shells): Programmatically, arg can also take the symbols
`cpython' or `jpython', which makes it easy to call with the value of
py-default-interpreter.

(py-shell): Don't need to initialize py-which-* variables since these
will guarantee to be initialized by python-mode when the first py
buffer is visited.

(py-default-interpreter): Update docstring.
1999-07-28 21:59:43 +00:00
Barry Warsaw ddc469679b (py-beginning-of-def-or-class): Only move to match-beginning if the
regex match actually succeeded!
1999-07-27 21:40:02 +00:00
Barry Warsaw c0d2d51dd2 (py-statement-closes-block-p): py-goto-initial-line could leave us in
the line's whitespace.  back-to-indentation should /follow/ this call.
1999-06-03 22:18:59 +00:00
Barry Warsaw fa2def2a61 (py-electric-backspace): I'm not sure this function should be special
casing when py-honor-comment-indentation is nil, but this could be a
religious issue with some.  Seems to me we should still be dedenting
such comment lines one level.
1999-05-24 21:43:37 +00:00
Barry Warsaw 53db859408 (py-parse-state): When running under Emacs -- which doesn't have
buffer-syntactic-context -- just short circuit the TQS test by jumping
to point-min and doing the test from there.  For long files, this will
be faster than looping with a re-search-backwards.
1999-05-24 19:57:32 +00:00
Barry Warsaw a8f99ba2d2 (py-statement-closes-block-p): Add a py-goto-initial-line which fixes
indentation when the return value is a multiline sexp:

def bug():
    try:
        if 2>1:
            return (11+
                    12)

        else:   #XXX
            return 12
    except:
        return 13
1999-05-24 18:37:57 +00:00
Barry Warsaw 3b4e2f0b87 (py-shell): Added optional argprompt, which will prompt for additional
switches to pass into the shell process (only on initial startup).
1999-02-16 23:52:46 +00:00
Barry Warsaw aa384fd616 (py-default-interpreter): New variable which selects whether CPython
or JPython is the default interpreter to use when `C-c !' is entered
for the first time.
1999-02-16 23:36:16 +00:00