2

I've enabled auto-complete-mode mode using prog-mode-hook like so: (add-hook 'prog-mode-hook 'auto-complete-mode), but I want auto-complete-mode to be disabled for python-mode. How can I achieve this ?

I tried doing this :- (add-hook 'python-mode-hook (lambda() (auto-complete-mode -1))) But, auto-complete-mode is still enabled for python-mode.

  • Can you update the question with the exact code you used related to prog-mode-hook and MAJOR-MODE-hook? Note about your dummy form above.. it should be "major-mode-hook", not "major-mode". – Kaushal Modi Aug 5 '16 at 13:22
  • edited the post with actual code used. – Chakravarthy Raghunandan Aug 5 '16 at 13:28
  • 3
    The code shown in your edited question works just fine. You must be doing something else. Check that you're not running global-auto-complete-mode for starters. – phils Aug 5 '16 at 13:44
  • 1
    @ChakravarthyRaghunandan The best way is (you probably already know it) to comment out your whole config and gradually uncomment it in halves till you narrow down to the problematic part. Before you do that, you can also grep your config + installed packages for 'auto-complete' and see what comes up.. probably it got enabled globally by customize? – Kaushal Modi Aug 5 '16 at 14:18
  • 2
    I did emacs -Q -L popup-el -L auto-complete -l auto-complete.el evaluated (add-hook 'prog-mode-hook 'auto-complete-mode) (add-hook 'python-mode-hook (lambda() (auto-complete-mode -1))) then did M-x python-mode and auto-complete was not enabled. So this works fine, you have something in your .emacs that is messing things up. – npostavs Aug 5 '16 at 14:45
1

This can be done very easily with hooks for major-modes like so:

(add-hook 'python-mode-hook (lambda ()
                              (highlight-indent-guides-mode -1)))

If for some reason this did not work, you could try something like this:

  (add-hook 'prog-mode-hook (lambda ()
                              (unless (eq major-mode 'python-mode)
                                (highlight-indent-guides-mode))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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