erikcw
erikcw

Reputation: 11057

Emacs autocomplete inside Python string?

I'm new to emacs and am trying to figure out how to make auto-complete mode auto complete while my cursor is inside quotes.

For example, while writing Python (I'm using emacs-jedi) I'd love to be able to autocomplete dictionary lookups. It doesn't even need to introspect my dictionary, just offer the word if it has already been used in the buffer.

data = {"test_auto_complete": 1}
data['test_

Thoughts?

Upvotes: 3

Views: 613

Answers (2)

tkf
tkf

Reputation: 3020

AC does not complete when you are in face specified by ac-disable-faces. It is '(font-lock-comment-face font-lock-string-face font-lock-doc-face) by default. Remove font-lock-string-face from it or simply remove all:

(setq ac-disable-faces nil)

Upvotes: 8

ocodo
ocodo

Reputation: 30248

For string literals, use either dabbrev-expand or hippie-expand.

I keep them bound to M-/ and S-/ (ie. Meta / and Super /) YMMV

This won't go through the auto-complete interface, if you really want that, there will be a way, but is that really necessary?

Note: hippie-expand will expand/autocomplete from the filesystem, and other places (including everything dabbrev-expand does.)

dabbrev-expand will only expand from the open buffers and the abbrev dictionary.

Edit: using autocomplete with dabbrev

http://www.emacswiki.org/emacs/ac-dabbrev.el - this emacs lisp will make dabbrev a source for auto-complete

Upvotes: 5

Related Questions