[Python-bugs-list] [ python-Bugs-705005 ] python-mode.el: sexp commands don't understand Python

SourceForge.net noreply@sourceforge.net
Mon, 04 Aug 2003 20:14:52 -0700


Bugs item #705005, was opened at 2003-03-17 08:59
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=705005&group_id=5470

Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Ed Avis (epaepa)
Assigned to: Nobody/Anonymous (nobody)
Summary: python-mode.el: sexp commands don't understand Python

Initial Comment:
Emacs has a whole lot of commands dealing with 'sexps',
such as forward-sexp and kill-sexp.  These originated
with Lisp but are useful for other languages too.  For
example in c-mode, editing the text

if (x > 7) {
    puts("hello");
}

with point before the 'i', pressing M-C-k (kill-sexp)
will first kill the 'if' keyword, leaving:

 (x > 7) {
    puts("hello");
}

Then a second press of M-C-k leaves

 {
    puts("hello");
}

and a third press kills the whole block following.  So
you can kill the whole if-statement, and nothing more,
with three keypresses.  This is useful for moving
chunks of code around.

However the same doesn't work in python-mode because
Emacs doesn't appear to know about the definition of a
sexp.  You can kill balanced expressions on a
particular line but it's not possible to remove the
whole of an 'if' or 'while' block.

Along the same lines, while commands like mark-defun
work in most languages to select the current function
definition, they don't work with Python's 'def' blocks,
instead highlighting the whole file.

Is it possible to get these and similar commands
working, or is Emacs hardwired to look for starting and
ending delimiters around each block?  If it's not
possible to make these commands work correctly, it
might be better to disable them for python-mode rather
than leave them present but wrong (eg mark-defun marks
the whole buffer).

----------------------------------------------------------------------

>Comment By: Skip Montanaro (montanaro)
Date: 2003-08-04 22:14

Message:
Logged In: YES 
user_id=44345

migrating to the new python-mode project.  You can
follow it here:

https://sourceforge.net/tracker/
index.php?func=detail&aid=783241&group_id=86916&ati
d=581349


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=705005&group_id=5470