Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 352
erikcw Avatar asked May 17 '26 02:05

erikcw


2 Answers

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)
like image 60
tkf Avatar answered May 20 '26 19:05

tkf


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

like image 37
ocodo Avatar answered May 20 '26 19:05

ocodo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!