This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python-mode.el: sexp commands don't understand Python
Type: Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: epaepa, skip.montanaro
Priority: normal Keywords:

Created on 2003-03-17 14:59 by epaepa, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (2)
msg15157 - (view) Author: Ed Avis (epaepa) Date: 2003-03-17 14:59
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).
msg15158 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-08-05 03:14
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
History
Date User Action Args
2022-04-10 16:07:41adminsetgithub: 38171
2003-03-17 14:59:05epaepacreate