Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In my .emacs I have the following line of code:

(modify-syntax-entry ?_ "." python-mode-syntax-table)

This is so that commands like forward-word and backward-kill-word stop at any underscores that are in a word. This is different behavior than the default, and it is the behavior I want. The problem is that then auto-complete-mode also respects underscores as word boundaries in an undesirable way. For example, if I have a variable called foo_var, and I type fo and then try to complete, it will only complete to foo not foo_var.

In text-mode and c-mode the behavior is exactly what I want i.e. motion obeys underscores, but auto-complete-mode will complete across them. What do I need to change in my auto-complete-mode configuration to fix this in Python?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I managed to get my problem solved. I did a diff on the syntax tables loaded for both python-mode and c-mode (using C-h s). I noticed that in c-mode, the underscore was a symbol character ("_") and in python-mode the underscore was a punctuation character ("."). So, I simply changed the aforementioned line of code to

(modify-syntax-entry ?_ "_" python-mode-syntax-table)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.