"John Hunter" <jd******@ace.bsd.uchicago.edu> wrote:
John> Using emacs python-mode with a class
John>
John> class C:
John> def method1(self):
John> pass
John>
John> def anothermethod(self):
John> pass
John>
John> def method2(self):
John> pass
John>
John> is there any way to select all the methods and have emacs order
John> them alphabetically? If not, is there a good too to do so?
Sort of, but there are problems. Emacs does have a sort-paragraphs
function. Python-mode has a py-mark-block command. If you place the
cursor at the start of the "class" line and hit C-c C-k you'll mark the
class. Hit C-n C-x C-x to highlight the block except for the class line
itself then M-x sort-paragraphs RET.
This has a gotcha. The notion of paragraph separator is basically a blank
line. To make this more effective you'd have to modify the
paragraph-separate variable. If you come up with a reasonable value for
Python code, send it along to
py*********@python.org and we'll update
python-mode.el.
Skip