Commit Graph

204 Commits

Author SHA1 Message Date
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
Barry Warsaw f19feb8fb5 (py-mode-map): Add back force of RET (aka C-m) to
py-newline-and-indent.
1999-01-21 17:06:11 +00:00
Barry Warsaw cb5540e72a (py-mode-map): Removed special bindings for C-m and C-j to
py-newline-and-indent.  These ought to get picked up by the mapcar
that follows; any existing binding to newline-and-indent gets shadowed
to py-newline-and-indent.

This will break some people who, e.g. bind C-m or C-j to newline but
still want these bound to py-newline-and-indent in Python mode.  On
the other hand, the forced binding pisses off Emacs diehards.  So
consider this experimental and see if any tall Dutch guys complain :-)
1999-01-19 13:26:56 +00:00
Barry Warsaw f8ddb6afa0 (py-narrow-to-defun): New command (bound to C-x n d) which mimics the
standard narrow-to-defun but works with Python classes and methods.
With no arg, narrows to most enclosing def/method.  With C-u arg,
narrows to most enclosing class.
1999-01-18 21:49:39 +00:00
Barry Warsaw 1d7b0fa9ca (py-electric-delete): Implement the XEmacs 21 blessed way of checking
for delete forwardness.
1999-01-15 02:12:31 +00:00
Barry Warsaw 1a1c6bbf8c (py-outdent-p): Short circuit infloop for illegal construct
(e.g. except: on first line of buffer).
1999-01-09 17:22:38 +00:00
Barry Warsaw 9c1696cff5 (py-goto-beginning-of-tqs): Finds the beginning of the triple quoted
string we find ourselves in, based on the passed in delimiter.

(py-compute-indentation): Fixes for indentation errors when we land
inside a triple quoted string.  For example:

def foo():
   if os.path.isfile(o_pri_mbox_file) and os.path.isfile(o_pub_mbox_file):
       print """\
I found both a private and a public mbox archive file
    private: %s
    public : %s

I won't move either file, but you should choose one and move it to

    %s

You may want to merge them manually, but be careful about exposing private
correspondences to the public.""" % (
    o_pri_mbox_file, o_pub_mbox_file, mbox_file)
*----indentation would be wrong on this line.
1998-12-15 04:36:22 +00:00
Barry Warsaw 34d8317013 (py-execute-region): Hack around the different behavior and switch
semantics between CPython/JPython when the script source is piped to
stdin.
1998-11-20 03:04:07 +00:00
Barry Warsaw 014e0e29b1 (py-execute-region): Patch by Hunter Kelly so that execution uses the
correct Python shell (CPython or JPython).
1998-11-17 19:24:47 +00:00
Barry Warsaw 1d5f988457 (py-imenu-method-regexp): Fix suggested by Daniel Calvelo to
generalize the matching of function arguments.
1998-10-28 04:08:13 +00:00
Barry Warsaw 6839d3af10 #XEmacs 21 now supports Imenu, so I am able to test (and fix) some
#simple things.  First step: rename the Imenu supportive variables and
#functions in this file to py-imenu-* so I can grok what is part of
#python-mode and what is part of Imenu.

(py-imenu-create-index-engine): Fixed problem with two classes in a
single file, caused by new semantics of py-beginning-of-def-or-class
when called programmatically.

#Note, there are still some problems with Imenu when arguments to
#functions are funky, but it should be much better now.
1998-10-28 00:10:45 +00:00
Barry Warsaw 38e21e75ad #Some minor changes in the commentary, obstensibly to test the new
#checkin script.
1998-10-27 22:09:25 +00:00
Barry Warsaw 1bbc031999 #Fixed some typos in docstrings. 1998-10-27 21:54:56 +00:00
Barry Warsaw 4f94c73879 (py-comint-output-filter-function): Horrible kludgearound for making
the de-queing of exec files work for NT XEmacs 21.0.
1998-09-25 19:40:10 +00:00
Barry Warsaw d35c255e44 (py-guess-indent-offset): Only print message about py-indent-offset
when in an interactive session (suggested by B. Wiener).
1998-09-25 00:08:38 +00:00
Barry Warsaw 02e5f69c90 (py-execute-file, py-execute-import-or-reload): Use a Python `raw'
string in the argument to execfile() so a Windows temp directory
named, e.g. c:\\tmp doesn't get interpreted as a file name with an
embedded tab!  (given by C. Waldman).
1998-09-24 23:48:40 +00:00
Barry Warsaw 218eb75ba7 (py-block-comment-prefix): Remove trailing space. Also explain that
this string should not end with whitespace.

(py-compute-indentation): Append whitespace regexp to
py-block-comment-prefix so that any combination of intervening
whitespace will be recognized.
1998-09-22 19:51:47 +00:00
Barry Warsaw bc3760b09d #Code rearranging to quiet byte-compiler 1998-09-14 16:16:18 +00:00
Barry Warsaw 4d1874093f (py-in-literal): How'd this get through? c-point => py-point 1998-08-29 06:32:31 +00:00
Barry Warsaw f7039e29ec Update commentary. For most stuff, point people to the web page 1998-08-20 22:10:46 +00:00
Barry Warsaw 6dfbe5dcec (py-shell-map): New variable contains the keymap used in *Python*
shell buffers.

(py-shell): Moved the require of comint to the top level.  Also
use-local-map py-shell-map instead of hacking on the comint-mode-map.
This eliminates breakage of other comint-mode buffers (e.g. shell).
1998-08-20 21:51:27 +00:00
Barry Warsaw a81fb33c6b (py-shell): comint-output-filter-functions is already buffer-local 1998-08-20 20:00:53 +00:00
Barry Warsaw 3c96f6f361 (py-process-filter): Deleted this function. In order to fix
interactions with newer Emacsen, I've rewritten the way all the
process filters work in the *Python* buffer.  We use more of the
comint infrastructure, specifically the default process filter.  This
means that scrolling is now handled by the default comint variables
including comint-scroll-to-bottom-on-output.  Note that this is
somewhat experimental change!

(py-comint-output-filter-function): Moved to here from the obsolete
py-process-filter function, the logic to pop and exec the next queued
file waiting to be executed.

(py-execute-file): Don't bind comint-scroll-to-bottom-on-output to t,
and save the excursion when inserting the "working on" message.  This
lets the standard comint scrolling variables as set by the user,
continue to work.

(python-mode, py-shell, py-describe-mode): Remove description of
py-scroll-process-buffer.  Also in py-shell, make
comint-output-filter-functions buffer-local, and add
py-comint-output-filter-function to this hook (instead of setting the
process filter).

(py-scroll-process-buffer): Deleted this variable.  See comint
variables including comint-scroll-to-bottom-on-output.

(py-execute-region): When exec files are being queued, push the next
temp file on the end of the list.

(py-submit-bug-report): Removed reporting of py-scroll-process-buffer.
1998-08-20 19:44:51 +00:00
Barry Warsaw 93c88cca06 (imenu-example--create-python-index-engine): Fix nesting breakage when
a method definition has args that span multiple lines; be sure to go
to the beginning of the method definition -- but watch out for the
match-data!
1998-08-18 02:00:44 +00:00
Barry Warsaw 650e8a6db2 (imenu-example--python-method-regexp): Patch from Christian Tanzer:
"3.67 fixes Imenu as far as classes are concerned, but some default
values for function arguments are still not supported."

This ought to fix that problem.
1998-08-10 21:46:24 +00:00
Barry Warsaw 12c9294ea3 (py-compute-indentation): Changes to the `t' condition which affect
indetnation of normal statements: The regular expression that searches
for indenting comment lines has been changed to not require a
space/tab after the first `#'.  We then explicitly look for
py-block-comment-prefix depending on the value of
py-honor-comment-indentation.

I think this more accurately reflects the documentation for
py-honor-comment-indentation.
1998-08-10 21:44:37 +00:00
Barry Warsaw 71c3adb7ec #Typos from previous checkin 1998-08-10 16:34:33 +00:00
Barry Warsaw 41a05c75d4 Huge number of docstring changes, typo fixes, rewordings, GNU standard
conformations, etc., etc. inspired and given by Michael Ernst.  These
include error string fixes, moving of comments to docstrings, some
other non-related typos, terminology standardizing (b/w TP and myself,
and b/w myself and myself :-) although more can still be done.
E.g. "outdenting" => "dedenting".
1998-08-10 16:33:12 +00:00
Barry Warsaw 1b3442493a (py-execute-region): When temp-names are broken (Emacs 19.34), a
serial number isn't enough to uniquify the temp file name -- what if
two users are on the same machine?  Add in the (emacs-pid) to help
further.  Should never be tickled on Emacs 20, XEmacs 20, 21.
1998-08-07 22:24:16 +00:00
Barry Warsaw 7c29b2328b (py-beginning-of-def-or-class, py-end-of-def-or-class,
py-mark-def-or-class): Integrated Michael Ernst latest patches.
Primarily, it allows functions that search or mark defs/classes based
on programmatic specification, to take an 'either flag value which
allows searching for both classes and defs (stopping at the nearest
construct).

Also clean up some docstrings.
1998-07-07 17:45:38 +00:00
Barry Warsaw 003932a508 (py-comment-indent-function): A replacement for
comment-indent-function's default lambda value (in simple.el), this
version finally kills this nit: auto-filling a comment that starts in
column zero with filladapt turned off would cascade the #'s to the
right.

Now auto-filling seems to work with or without filladapt, and with the
comment starting in any column.

(python-mode): Set comment-indent-function.
1998-07-07 15:11:24 +00:00
Barry Warsaw 3bfed5b6b1 (py-ask-about-save): New variable used in
py-execute-import-or-reload.  Same semantics as
compilation-ask-about-save.
1998-05-19 16:25:04 +00:00
Barry Warsaw 1d0364b2dc (py-execute-string): Bind to C-c C-s, and put on menu 1998-05-19 16:15:26 +00:00
Barry Warsaw 751f4931d8 (py-stringlit-re): Another ME patch to recognize SQTQs and DQTQs
(single and double quoted triple quoted strings :-) with embedded
single like-quotes.  Also recognizes raw prefix.
1998-05-19 16:06:21 +00:00
Barry Warsaw 820273d6d1 More ME patches:
(py-execute-import-or-reload): Cool new command that imports or
reloads the current file as a module, so as not to clutter the global
namespace.  Bound to C-c C-m.

(py-execute-def-or-class): New command that sends the current def or
class to the interpreter.  Bound to C-M-x.

(py-execute-string): New command that sends arbitrary string to the
interpreter.  Not bound by default.

(py-describe-mode): Doco updates.
1998-05-19 15:54:45 +00:00
Barry Warsaw ab0e86cbcc (beginning-of-python-def-or-class): Renamed to
py-beginning-of-def-or-class, and defaliased for backwards
compatibility.  ME patch to add optional second argument, count.

(end-of-python-def-or-class): Renamed to py-end-of-def-or-class, and
defaliased for backwards compatibility.  ME patch to add optional
second argument, count.
1998-05-19 15:31:46 +00:00
Barry Warsaw ebc7b7ac45 More ME patches:
(py-shell): Recognize the Python debugger prompt

(py-jump-to-exception): Force into python-mode any buffer that gets
jumped to on exception.  Cope with py-exception-buffer possibly a
cons.
1998-05-19 15:01:06 +00:00