Commit Graph

153 Commits

Author SHA1 Message Date
Barry Warsaw 77d1fce2f6 (py-compute-indentation): Use forward-comment to skip over all
whitespace and comment noise.
1998-04-16 20:04:59 +00:00
Barry Warsaw ea609c18a0 (py-toggle-shells): Added a message in the minibuf. 1998-04-10 16:08:26 +00:00
Barry Warsaw a239880a22 Quick and extremely dirty hacks to toggle between using CPython and
JPython interpreters.  This implementation may suck.

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

(py-mode-map): py-toggle-shells bound to C-c C-t

(py-toggle-shells): Command to toggle between using CPython (the
default) and JPython.  This is buffer local, and notice the mode-name
change.

(py-shell): Use either CPython or JPython.  Note that py-execute-*
still needs to be modified.
1998-04-09 23:28:20 +00:00
Barry Warsaw 3179fe03ca (imenu-example--python-class-regexp): Fix to recognize Module.Class in
inheritance list.
1998-04-04 21:36:53 +00:00
Barry Warsaw 5204b4a984 #Oops, I lost the CVS/RCS $Revision$ 1998-04-02 19:27:18 +00:00
Barry Warsaw 92166d9a75 (py-compute-indentation): When looking at a continuation line inside
an open paren, do a better job of reindenting the line.  For example:

def foo():
    print 'hello %s, %d' % (
    a, b)

Hit TAB on the line starting with `a'.  Without this patch this line
will never be reindented.
1998-04-01 21:59:41 +00:00
Barry Warsaw 585f733b39 Two patches for Emacs 20.2 compatibility:
(py-compute-indentation): int-to-char isn't defined in Emacs, but we
don't really need it anyway, so just remove this conversion.  XEmacs
is happy either way.

(py-parse-state): The Emacs branch (i.e. w/o buffer-syntactic-context)
wasn't adjusting point correctly.
1998-04-01 21:13:51 +00:00
Barry Warsaw f9b99f4375 (py-postprocess-output-buffer): Return t if an exception was found,
otherwise return nil.

(py-execute-region): When executing the buffer asynchronously in a
subprocess, if an exception occurred, show both the output buffer and
the file containing the exception, leaving point on the source line
containing bottom-most error in the traceback.  If no exception
occurred, jump to the output buffer (no change).
1998-03-26 16:08:59 +00:00
Barry Warsaw 512af04b35 (py-execute-region): Watch out for shell-command-on-region killing a
zero sized output buffer.
1998-03-25 23:27:17 +00:00
Barry Warsaw beef9e73c3 Removed all the mixed indentation face stuff. It's not as helpful as
it at first seems.  I think we've got a good idea of what to do, but
it'll be a bit of work... for later.
1998-03-20 17:06:11 +00:00
Barry Warsaw 8ca702823d (py-tab-face): => py-mixed-indentation-face
(python-font-lock-keywords): Better regexp given by Sjoerd.  This
matches only mixed indentation which is probably more useful than
matching all tabs.
1998-03-20 14:48:30 +00:00
Barry Warsaw e908b6ba57 (py-in-literal, py-fast-in-literal): New functions (mostly) stolen
from CC Mode.

(py-guess-indent-offset): Teach it about colons in `literals'
(e.g. comments and strings).  Don't false hit colons in literals; keep
searching for a real block introducing line.
1998-03-19 22:48:02 +00:00
Barry Warsaw b6c1f1f927 #minor change to eval-while-compile so that it must both find
#custom.el and have an up-to-date version (i.e. one that defines
#defcustom -- which Emacs 19.34's by default does not).
1998-03-19 22:33:06 +00:00
Barry Warsaw 0d2805b771 (py-tab-face, python-font-lock-keywords): Color all tabs at the start
of a line in py-tab-face to aid in seeing mixed tab/space indentation.
This face defaults to the `default' face so it is unobtrusive until
you `M-x customize-face' py-tab-face to something obnoxious like
"Yellow".
1998-03-19 21:52:06 +00:00
Barry Warsaw 639eea670c (py-smart-indentation): Updated docstring for new policy.
(python-mode): Implement new policy: never turn indent-tabs-mode on.
Only turn it off if tab-width != py-indent-offset.
1998-03-16 18:12:13 +00:00
Barry Warsaw 8046befce7 #(py-smart-indentation): Small fixes for clarity in the docstring. 1998-03-13 20:04:52 +00:00
Barry Warsaw 9e9968859e (python-mode): Removed vi vi vi hack for setting the tab width from a
magic comment.  Now Guido only has to worry about the northern
Wisconsin Braces Freedom Fighter Militia.
1998-03-13 18:53:15 +00:00
Barry Warsaw 742a5116d2 (py-smart-indentation): New variable which controls the automagic
setting of py-indent-offset and indent-tabs-mode.

(python-mode): After python-mode-hook is run, do the automagic
calculation if py-smart-indentation is non-nil.

(py-parse-state): Get rid of unused variable to quiet the
byte-compiler.
1998-03-13 17:29:15 +00:00
Barry Warsaw 2f32fbba34 (py-execute-region): Simplified calculation of temporary file name.
When running synchronously in a subproc buffer, be sure to
pop-to-buffer so the output is visible.
1998-02-25 16:45:43 +00:00
Barry Warsaw 6c6db0a073 (py-temp-directory): Minor docstring nit. 1998-02-25 16:33:56 +00:00
Barry Warsaw 50b3eb6a9e (py-master-file): Fixed some typos in the docstring. 1998-02-25 15:57:47 +00:00
Barry Warsaw f64b4054af (py-compute-indentation): Several changes made to improve navigation
over and around triple-quoted strings:

    - move the beginning-of-line to above the p-p-s call

    - in the `t' clause of the big cond, where we skip over
      triple-quoted strings, first find out if we're looking at a
      single or TQS, then skip over it in one fell swoop, instead of
      trying to loop over skipage of SQS's.

(py-parse-state): Implement XEmacs only hack to more accurately figure
out whether we're in a string or not.  Can't do this in Emacs because
it lacks the necessary primitive, so we just do it the old (and mostly
accurate, but foolable) way for Emacs.
1998-02-12 16:52:14 +00:00
Barry Warsaw 8ee4a60c70 (py-scroll-process-buffer): Default value changed to nil to act more
like default shell-mode behavior.
1998-02-06 16:01:52 +00:00
Barry Warsaw f1b3e89800 (py-parse-state): When looking for landing inside triple-quoted
string, don't check for indentation at column zero.  This will falsely
hit a line inside a docstring that starts at column zero but ends in a
colon.
1998-02-05 23:35:09 +00:00
Barry Warsaw 8f972b762a (py-python-command-args): New variable, allows user to customize the
arguments past to py-python-command when invoking the Python shell.
1998-02-05 20:45:49 +00:00
Barry Warsaw f06777dd7c (py-outdent-p): When looking at the previous line, watch out for
continuation lines.  This fixes this bug report, reported by Frank
Stajano.

# But if I split the "raise" line and reindent, the else WRONGLY goes up a
# level (?!?)

while condition1:
    if condition2:
        raise error3, \
              moreInfo4
else: # meant to close "if condition2"
    action5()
1998-01-21 05:36:18 +00:00
Barry Warsaw 9ec9fbc355 (py-goto-initial-line): Shut up the byte compiler. 1998-01-21 05:15:57 +00:00
Barry Warsaw 82aecb9d66 (py-mode-map): Add a binding of C-m to py-newline-and-indent. This is
a religious issue: RMS decrees that the Enter (RET) key should just do
a newline and a LFD (C-j) should do a newline and indent (i.e. the
python-mode version of this).  Almost everyone I know disagrees and
finds that RET should do newline and indent.  Almost everyone hacks
their modes to do this, if they know how.  Because it's hard for
newbies to figure out how to do this, and because most DOS keyboards
lack a LFD (leaving users to the more obscure C-j), I think it makes
better sense to add this default binding.
1998-01-21 05:14:24 +00:00
Barry Warsaw c210e69981 (py-compute-indentation): In the most common case, where indentation
is based on the line above, watch out for landing inside a triple
quoted string.  In this case, use iterative search +
parse-partial-sexp backwards to find the beginning of the string.

Note this does affect performance, but very little in the common cases
(I hope).  It could be made *much* faster by adding Emacs and XEmacs
dependent code -- different code naturally.  :-(

Fixes the following reported bug:

if len(sys.argv) >= 6:
    # More lines here
    fptr = open('/etc/hosts', 'w')
    fptr.write("""# /etc/hosts -- autocreated by /etc/ppp/ip-up
#
# Address from pppd
%-15s	%s

# For loopbacking
127.0.0.1	localhost

255.255.255.255	broadcast
""" % (ipaddr, ipname) )

os.chmod('/etc/hosts', 0644)
1998-01-20 22:52:56 +00:00
Barry Warsaw c0ecb53194 (py-master-file): New buffer-local variable which can be set in the
file local variable section of a file.  When set, and the user hits
C-c C-c, this file gets executed instead of the buffer's file.  Idea
given by Roy Dragseth <royd@math.uit.no>, but implemented differently.

(py-execute-buffer): Support py-master-file variable.  If this names a
relative path, default-directory is prepended via expand-file-name.
1998-01-20 21:43:34 +00:00
Barry Warsaw 3723152c5b Update to the Big Comment at the top of the file. It should better
explain what the users of the various Emacsen have to do to get this
all working.
1997-12-11 17:23:13 +00:00
Barry Warsaw 5ea20d52c7 Added some links to OO-Browser, given by Harri Pasanen.
Updated the to do list.
1997-12-06 00:00:47 +00:00
Barry Warsaw 9981d2226d (py-jump-on-exception): Variable which if t, means that if an
exception occurs in a synchronous Python subprocess, the mode will
automatically jump to the innermost exception.
1997-12-03 05:25:48 +00:00
Barry Warsaw 27ee115fd7 Removed redundant eval-when-compile.
(python-mode): Conditionalize imenu initializations to when we can
safely require imenu.  Under Emacs this should prevent python-mode
from hosing the global value of imenu-create-index-function and
messing things up for all other modes.  Problem identified by
Christian Egli.

(py-describe-mode): py-delete-char => py-electric-backspace.  Given by
Christian Egli.
1997-12-03 05:03:44 +00:00
Barry Warsaw 5c38bf6c62 (python-mode): Patch to make font-lock work automatically for Emacs.
Unnecessary for XEmacs, but oh well...
1997-12-02 22:01:04 +00:00
Barry Warsaw 673d05f0ee Test for an up-to-date Custom library when byte-compiling, and issue
an informative message when one cannot be found, as is the case with a
vanilla Emacs 19.34 (and NTEmacs 19.34).
1997-12-02 21:51:57 +00:00
Barry Warsaw 8529ebb78c Require 'cl when compiling so that the push macro gets picked in Emacs
19.34.
1997-12-01 20:03:12 +00:00
Barry Warsaw ffbc17da19 (py-traceback-line-re): Relaxation of regexp to catch SyntaxErrors.
Harri Pasanen.
1997-11-27 20:08:14 +00:00
Barry Warsaw f471056b0a (py-process-filter): py-delete-file-silently is obsolete. Use a
py-safe wrapped delete-file call instead.
1997-11-26 21:00:36 +00:00
Barry Warsaw 3b3ff4e96e (py-compute-indentation): Check for multiline stringness and
commentness so that hitting TAB in the middle of a comment will still
indent the line.
1997-11-26 20:58:48 +00:00
Barry Warsaw 8c4a8de75e (py-mode-map): Bind py-mark-def-or-class to C-M-h with a different
spelling so that it doesn't clobber the standard M-BS binding.  This
should be portable between X/Emacsen.
1997-11-26 20:30:33 +00:00
Barry Warsaw c8520351af (python-mode): Make imenu-create-index-function buffer local.
(imenu-example--create-python-index-engine): Use
buffer-substring-no-properties.  Also, don't use
imenu-create-submenu-name.  Apparently it is obsolete.

These Imenu patches were given by Christian Egli
<christian.egli@stest.ch>
1997-11-26 06:14:40 +00:00
Barry Warsaw 4da6bd51dd (py-mark-def-or-class): Added an exchange-point-and-mark and a
py-keep-region-active so that the marked def/class gets the
zmacs-region or transient-mark region highlighted.  Also point should
be left at the end of the marked region.

(py-mode-map): Moved py-mark-def-or-class to M-C-h to conform to Emacs
major mode standards.
1997-11-26 06:00:26 +00:00
Barry Warsaw e467bfbfe9 (python-mode): Patch to fix Imenu support under Emacs, given by
Torsten Hilbrich <Torsten.Hilbrich@bln.de>.
1997-11-26 05:40:58 +00:00
Barry Warsaw 47384789b2 (py-kill-emacs-hook): Simplification. 1997-11-26 05:27:45 +00:00
Barry Warsaw a0ee8cd982 Added comment about where to find details on python-mode.el, pointing
to the Web site.

(py-defun-start-re, py-class-start-re): Changed to defconst.

(py-traceback-line-re): Regular expression describing what traceback
lines look like.

(py-point): New defsubst copied from CC Mode.

(py-highlight-line): Function which does the work of making a
traceback line mouseable.  This only works on XEmacs.  Someone familar
with Emacs text properties and such will have to do that port.

(py-mode-map): Added C-c- bound to py-up-exception and C-c= bound to
py-down-exception.  Also, more concise form for mapcar.

(py-mode-output-map): New keymap for the *Python Output* buffer which
only has keybindings for py-mouseto-exception and py-goto-exception.
All other self-insert-command's are bound to beep.  This is actually
bogus because the buffer should really be made read-only and the
functions that insert in that buffer should bind inhibit-read-only.
Also, this map should be bound to highlighted extents in a *Python*
shell buffer, but this stuff hasn't been migrated into there.

(py-postprocess-output-buffer): New function which extentifies the
*Python Output* buffer.  The bogosities are that this only runs when
the synchronous process in the buffer is finished (so it doesn't work
for async procs), and it should also be merged into py-process-filter
so the *Python* shell gets mouseable too.

(py-shell): Added C-c- and C-c= to the comint buffer's keymap.  The
bogosity is that py-goto-exception should also be bound, but it cannot
be bound to C-cC-c (since that interferes with
comint-interrupt-subjob's typical binding).  Also, traceback lines
aren't mouseable in this buffer.

(py-execute-region): Support for traceback jumping.  This really is
quite a kludge, but necessary based on the way all this stuff works.
There's bound to be broken interactions here.

(py-jump-to-exception, py-mouseto-exception, py-goto-exception,
py-find-next-exception, py-down-exception, py-up-exception): All new
commands and functions to implement traceback jumping.

(py-compute-indentation): Hope this change doesn't get lost in all the
noise above!!!!  This fixes broken non-indentation of a line when TAB
is hit inside a string that isn't a multi-line string.
1997-11-26 01:04:44 +00:00
Barry Warsaw 6ae21ad687 #(py-emacs-features): Fixed typo in docstring. 1997-11-06 14:36:49 +00:00
Barry Warsaw b8f1166922 (python-font-lock-keywords): Pick up block introducing keywords with
immediately following colons.  Sjoerd noticed this one too.  Here's a
nonsense.py file that flexes all the font-lock keyword combinations.

class A:
    class B(A):
	pass
    def __init__(self):
	if i == 2 and j == 3 or k == 4:
	    import stuff
	    from otherstuff import cool
	    for i in range(cool.count):
		if i == j:
		    break
		elif j == 1:
		    continue
		print i
	    else:
		return not i
	elif q is not i:
	    return lambda x: x + 1
	else:
	    try:
		try:
		    raise stuff.error
		except stuff.error, v:
		    print v
		except:
		    global q
	    finally:
		while q > 0:
		    q = q - 1
		assert q == 0

def make():
    a = A()
    exec "nonsense"
    del a
1997-11-06 14:35:15 +00:00
Barry Warsaw ef3c891773 (python-font-lock-keywords): Fix for consecutive keyword font locking,
given by Sjoerd Mullender <Sjoerd.Mullender@cwi.nl>.
1997-11-05 18:55:50 +00:00
Barry Warsaw 5e21cb0bfb (py-emacs-features): Test for working make-temp-name, which is broken
on NTEmacs 19.34.6.

(py-serial-number): New variable.

(py-execute-region): If make-temp-name is broken, simply append a
serial number to the string "python-" to get a temporary file name.
It's possible concurrent NTEmacs can step on each others toes, but it
makes no sense to further coddle a busted NTEmacs.
1997-11-05 18:41:11 +00:00