Emacs and ELSE

Peter Milliken peterm at resmed.com.au
Sun Jan 5 14:51:23 EST 2003


Alternately, if you decide you don't want ELSE turned on for editting every
Python file (heaven forbid! :-) I am the author of ELSE - why am I telling
you this? :-)), just keep your .emacs to:

(require 'else-mode)

and then turn it on or off (manually) whenever you feel like it through the
sequence:

M-x else-mode

The addition of else-mode to the python-mode-hook (as Andrew's reply shows
it) will automatically turn on ELSE whenever you load a file with the .py
extension (or whenever else you invoke python mode) - you may not want this
in the long run.

Also, if you start ELSE when editting an existing .py file (as Andrew so
ably points out, the "placeholder" {compilation_unit} is only automatically
inserted on empty .py files), then just either "insert" as placeholder as a
starting point i.e. type:

[statement]...                               (note the ellipses - this tells
ELSE to repeat the placeholder when you "use up" this one)

and "expand" this by typing C-/ e (I bind all of my ELSE commands to
convenient keys such as F2 - F6).

The other alternative is to type an "abbreviation" and expand that i.e. the
key sequence

ifC-/ e   will give you an if construct like this:

  if {expression}:
    {statement}...
  [elif_part]...
  [else_part]

Just start typing when in a placeholder (text surrounded by a {} or []) and
it will be replaced by whatever you type :-)

If you are one of the rare people who like to use code
templates/abbreviations, then I would recommend that you read the ELSE
manual - I am also happy to answer any questions or provide any help with
definition/customisation of templates :-)

Hope this helps and adds constructively to Andrew's explanation - good luck
:-)

Peter


"Andrew McGregor" <andrew at indranet.co.nz> wrote in message
news:mailman.1041769390.15953.python-list at python.org...
> It should say ELSE in the modeline.
>
> The docs kind of assume you already know emacs.
>
> Once you have the ELSE files in your load path, you need:
>
> (require 'else-mode)
> (add-hook 'python-mode-hook 'else-mode)
>
> in your .emacs to automagically get ELSE turned on for python, and similar
> add-hooks for the other languages it supports if you use those.
>
> Then if you open a new .py file, ELSE will insert a tag like
>
> {compilation unit}
>
> for you at the top of the buffer.  Point at it and type C-c / e and ELSE
> will expand it into the template for a python file.  If there are
> alternative templates any time you type that key sequence, ELSE pops up a
> menu to select them from.  Emacs can also parse the provided else.info
file
> for you so you can navigate the docs, and always remember that C-h m lists
> the current keybindings for all active modes in the current buffer!
>
> (if you didn't have the add-hook, you could go M-x else-mode RET to
> manually start ELSE in the current buffer)
>
> Andrew
>
> --On Sunday, January 05, 2003 02:49:05 +0100 Dialtone
> <"dialtone/#NOSPAM#\\"@aruba.it> wrote:
>
> > Hi all. After reading the very long thread about Python editors under
> > linux (and maybe also under windows), I've been trying out Emacs (I
> > already know how to use Vim and GVim, and I may say I love them)...
> >
> > The main reason I'm trying emacs is because of the possibility to
> > lauch the inpterpreter inside Emacs without external apps working and
> > ELSE...
> >
> > Well... I've followed all the instructions in both
> > www.python.org/emacs/python-mode
> > and
> > http://www.zipworld.com.au/~peterm/
> >
> > but I don't know if ELSE is working...
> > How can I know this?
> >
> > anyway... I found only a sample.emacs file in my Xemacs/etc
> > directory... since I did not find anything else I started with that
> > one and at the end renamed it .emacs. It should be good anyway right?
> >
> > thx for the answers.
> > --
> > try: troll = "Brain"
> > except TypeError, data:
> >    troll.plonk()
> > Co-Responsabile Hardware Information & Technology
http://hit.edengames.net
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> >
>
>
>






More information about the Python-list mailing list