racer-rust / emacs-racer

Racer support for Emacs
399 stars 48 forks source link

make TAB configuration org-mode compatible #13

Closed tgpfeiffer closed 8 years ago

tgpfeiffer commented 8 years ago

For me, the sample code to set the TAB key to autocomplete given in the Readme,

(global-set-key (kbd "TAB") #'company-indent-or-complete-common) ;

caused problems with org-mode, where TAB wouldn't work any more to indent. I suggest to change the sample code to

(add-hook 'company-mode-hook
  (lambda () (local-set-key (kbd "TAB") #'company-indent-or-complete-common)))

to avoid these problems.

fbergroth commented 8 years ago

The binding only needs to be set once, so you can do:

(with-eval-after-load 'company
  (define-key company-mode-map (kbd "TAB") #'company-indent-or-complete-common))

Still though, it's quite common to use company in org mode as well. Perhaps suggest another binding or leave the choice for the user.

tomjakubowski commented 8 years ago

The sample code shouldn't suggest adding a lambda hook, which can be a pain to remove (because remove-hook doesn't work as expected).

Wilfred commented 8 years ago

How about writing this in the readme?

(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)

This is far less likely to clash with existing keybindings that users may have.

Wilfred commented 8 years ago

I've made the proposed change. Let us know if you have further issues.