How to turn off company mode in org mode? - emacs

I'm using spacemacs and tried to turn off company mode in org mode while keeping it in other major modes. I've tried the following:
(global-company-mode '(not org-mode))
but it's not working.

Disable from org-mode-hook (this method will work with pretty much any globalized minor mode and major mode):
(defun jpk/org-mode-hook ()
(company-mode -1))
(add-hook 'org-mode-hook #'jpk/org-mode-hook)
Or use company's configuration variable:
(setq company-global-modes '(not org-mode))

At the Spacemacs configuration layer level you can disable auto-completion layer for a set of layers with the following line in dotspacemacs-configuration-layers (for instance disabling auto-completion for both org and git)
(auto-completion :disabled-for org git)

Related

How I can associate two mode this one file in emacs?

I need associate from file.html to mode:
html-mode
emmet-mode
I am try this(but this not working):
(define-derived-mode my-html-mode
text-mode "Emmet+HTML"
(html-mode 1)
(emmet-mode 1))
(add-to-list 'auto-mode-alist '("\\.html\\'" . my-html-mode))
I'm going to assume that emmet-mode is a minor mode (you can't have more than one major mode in a single buffer).
html-mode is a major mode, and therefore its mode function takes no arguments, so (html-mode 1) is invalid (and should be causing an error. Were you seeing an error? "not working" doesn't tell us much.)
In Emacs 24+ you can associate minor modes with major modes by using the major mode's mode hook like so:
(add-hook 'html-mode 'emmet-mode)
See also https://stackoverflow.com/a/36416231
Since html-mode is a major mode and emmet-mode is a minor mode, you could derive your new mode from html-mode, and activate emmet-mode when my-html-mode is activated:
(define-derived-mode my-html-mode
html-mode "Emmet+HTML"
(emmet-mode 1))
(add-to-list 'auto-mode-alist '("\\.html\\'" . my-html-mode))

How to enable org-indent-mode by default?

I am using Emacs 25.1.50.2
When I am using Org-mode, the org-indent-mode is off by default. So I have to enable it using M-x org-indent-mode everytime.
I put the lisp below into my config file ~/.emecs.d/init.el with no effect.
;; Enable org-indent mode by default
(org-indent mode 1)
;; Above line really should be (org-indent-mode 1)
Thanks for your time :)
You can use the mode hook for the major mode to enable this buffer-local minor mode in org-mode buffers.
For Emacs 24+ you can simply write:
(add-hook 'org-mode-hook 'org-indent-mode)
In earlier Emacs versions you should instead use a custom function to explicitly enable the minor mode by calling (org-indent-mode 1), and then add that custom function to the hook variable.
In 2021 current version of org, you can do this:
(setq org-startup-indented t)

Can't properly disable flyspell in org mode

I set up emacs to turn flyspell on by default for text mode using
(add-hook 'flyspell-mode-hook 'flyspell-buffer)
(add-hook 'text-mode-hook 'flyspell-mode)
I would like to disable it automatically in org mode files, and I did manage to disable it using a lambda function in the org mode hook:
(add-hook 'org-mode-hook (lambda () (flyspell-mode -1)))
This works, but the syntax highlight changes that flyspell did still remain, and interfere with org mode's syntax highlight. I also see in the minibuffer that flyspell does run when I visit that file, so apparently it is turned off only afterwards. How do I turn it off in such a way that would leave no trace of it in the org mode file, or better yet not run at all?
You can selectively enable flyspell in text-mode hook by checking the major-mode. The following will enable flyspell in text-mode and its derived modes except org-mode
(add-hook 'flyspell-mode-hook 'flyspell-buffer)
(add-hook 'text-mode-hook (lambda ()
(when (not (equal major-mode 'org-mode))
(flyspell-mode t))))
Regarding the first question (remove the highlightings), the following call should do it:
(flyspell-delete-all-overlays)
However, are you really, really, really sure you want to disable flyspell in Org mode??? Is there a really, really, really good reason for that?
If yes, shouldn't you solve that one, instead of trying the above?

Auto Completion with auto-complete OR predictive based on mode

I'm using emacs-snapshot (24.2.50) on Xubuntu 12.10. For completion I am currently using auto-complete (v1.4).
I have a pretty nice setup of auto-complete with various sources, including the semantic source for code completion of my c++ programming. However, I'd like to switch to predictive-mode for completion of LaTeX documents (I'm using AUCTeX for all LaTeX related stuff).
My current auto-complete config (for LaTeX; I omitted all non-LaTeX config) looks like this:
(require 'auto-complete-latex)
(require 'ac-math)
(add-to-list 'ac-modes 'latex-mode) ; make auto-complete aware of {{{latex-mode}}}
(defun ac-latex-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-latex ac-source-latex-commands)
ac-sources))
)
(add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup)
After adding predictive to the load-path and doing the auto-load stuff as described here I tried to disable auto-complete for LaTeX-mode and enable predictive-mode in turn by exchanging the above code by this:
(defun ele/latex-mode-completion-setup ()
(auto-complete-mode -1)
(predictive-mode 1)
)
(add-hook 'LaTeX-mode-hook 'ele/latex-mode-completion-setup)
Unfortunately this doesn't work as expected: auto-complete is actually disabled but predictive-mode is not enabled and instead of using AUCTeX the build-in tex-mode is used.
I have uploaded all LaTeX related config here. Note that this is loaded after the above completion setup, but this is the case for the old auto-complete based setup as well. Also note that exchanging that order does not make a difference as far as I can tell. Furthermore I found that simply commenting the auto-complete config (first snippet I posted) results in the same behaviour: tex-mode is used instead of AUCTeX.
I don't want to switch to predictive-mode for all modes but I really like many features it provides when doing LaTeX editing.
Any suggestions?
(remove-hook
might clear the hook, not to run unwanted stuff - just a suggestion indeed

How can I disable auto-fill mode in Emacs?

Today I got my new PC (Windows 7, 32 bit) and installed Vincelt Goulets Emacs. The only other thing I did was updating Org-mode.
Now, I am stuck with auto-fill-mode on every time I start Emacs new, which I hate. I would like to turn auto-fill-mode off, for now and forever. I even deleted my .emacs file, but auto-fill-mode was still turned on.
The only solution that worked was (a) a nasty workaround or (b) always typing M-x auto-fill-mode every time I start Emacs anew.
Is there a solution?
To be clear, the only thing the current .emacs file contains is: '(inhibit-startup-screen t)
Add to your .emacs,
(auto-fill-mode -1)
If there are hooks for specific modes, you will need to zap those as well. My suspicion is that you do not actually have auto-fill-mode on by default in all modes, but with the information you have supplied, at least this should be a starting point.
A reasonable safeguard would be to also disable auto-fill mode from `text-mode-hook':
(remove-hook 'text-mode-hook #'turn-on-auto-fill)
You may need something similar for other modes as well.
Assuming that he has not made fundamental changes, you have several paths:
You can just turn off the mode globally in your .emacs file:
(turn-off-auto-fill)
;; ...or (auto-fill-mode -1)
Since Emacs of that vintage also turns on auto-fill for text-mode, add:
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
That should account for all the default places, but check the major mode hooks if you have other modes enabling this automatically.
If you'd like to keep it turned-on in most text-mode while disable auto-fill in specific modes, e.g. org-mode in my case, you could use the following:
;; turn on auto-fill for text-mode
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; turn off auto-fill for org-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill)