Adjusting company-mode to not change buffer contents accidentally

Posted: August 27, 2013 in Emacs, Emacs Lisp
Tags: ,

Some weeks ago, I’ve tried out company-mode. While I’ve been really satisfied with its UI and completion machinery, I still stopped using it because when simply navigating using the arrow keys in some code buffer, the company-popup frequently opened without me noticing and my next <up> or <down> keystroke changed my buffer although I just wanted to move point.

So today I’ve thought I should go ahead and add an option to company-mode to trigger completion only if the last command has been an editing command. And guess what, that feature is already there. :-)

(setq company-begin-commands '(self-insert-command))

That will make the company completion trigger only if the last command has been self-insert-command. You can add as many commands as you like there. The default value is t which means to always trigger company completion after company-idle-delay.

With this setting and a very short company-idle-delay (0.3 secs), company-mode now works great for me.

Advertisements
Comments
  1. Dmitry Gutov says:

    Sorry for the annoyance, I use this value of `company-begin-commands` myself, and other people also recommend it in several places.

    Guess it’s time to change the default. :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s