[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: writing Python in Emacs

From: Drew Adams
Subject: RE: writing Python in Emacs
Date: Sun, 20 Jan 2008 11:28:21 -0800

> >> I need the following features:
> >> 1) Tab completion, ideally Slime like. That is, when there's not
> >> enough letters to unambiguously complete a symbol, I want it to
> >> show a buffer (w/o taking the focus) w/ the possible
> >> completions.
> > I use hippie expand (M-/) to cycle through possible completions.
> Also known as dabbrev-expand, and tied to Ctrl-TAB.

`hippie-expand' and `dabbrev-expand' are different. And neither is bound to
C-TAB (by default), AFAIK. `hippie-expand' is not bound to any keys by
default, but people often bind it to M-/. See node Hippie Expand in the
Emacs manual.

> I like it *a lot*, and I like it even more because it *isn't* Python
> aware. I can use the same function no matter what I am typing, often
> with files noone would dream of writing a mode for.

> >> In an ideal world, it would be able to complete<TAB> to
> >> I imagine this would require quite tight Emacs-Python
> >> integration.

You can use `C-M-/', bound to `dabbrev-completion', to use completion
instead of cycling to choose one of several matches. However, in vanilla
Emacs, this is only prefix completion.

If you use Icicles, then `C-M-/' is enhanced to give you apropos completion,
in addition to prefix completion. That is, what you type can match a regexp
(e.g. substring), not just a prefix. So, for example, you could complete or fo.*ba or f.*b or oba or bar to foobar.

Icicles also lets you cycle among your input matches. You can access them in
any order, and you need not run through each match while cycling - you can
access individual matches directly.

> >> 4) (optional) I would like to see the definition of a function
> >> function or class by hitting M-. on its name. (I understand that
> >> this may be impossible for methods, as Emacs would have to
> >> automagically infer the type of the object).
> >
> > This is just an emacs tag file need. Have you googled for
> > something like emacs tags python?
> Tags works fine, or at least as well as can be expected.  I use the
> 'etags' which comes with 'ctags', apparently.

Tags are always a good solution. One of the best things Emacs has ever
offered the world, and available from its birth.

Another approach, which has advantages and disadvantages, is to use Imenu.
(This assumes that Python mode is Imenu-aware.)

If you use Icicles, then you can use C-' (`icicle-imenu') to browse any
definitions that Imenu can recognize, cycling among those that match your
input (regexp) or accessing them directly. You can do this across any number
of files or buffers at once.

This is a great way to bounce around among definitions. The definitions act
as completion candidates. *Completions* is dynamically updated to show you
those that match your current input.

Again, this assumes that Python mode is Imenu-aware. Dunno if it is. If not,
you can make it aware by defining the appropriate regexps.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]