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)
Related
In Emacs how do I stop the auto-fill minor mode from loading when I start the idlwave major mode?
So far I have been completely unsuccessful at figuring out how to do this. I have tried to use remove-hook for both idl-mode-hook and text-mode-hook without success.
You might have enabled auto-fill-mode as a global minor mode, so it is on in all buffers by default. If that is the case, the task is not so much not turning it on in idlwave-mode but rather turning it off.
Most major modes provide a special hook variable: it's a list containing functions that are called whenever that major mode is invoked. For instance, with the following line you can make sure that auto-fill-mode will get turned off each time a buffer goes into idlwave-mode:
(add-hook 'idlwave-mode-hook (lambda () (auto-fill-mode 0)))
Put the above line in your init file (e.g. ~/.emacs or ~/.emacs.d/init.el) and auto-fill-mode should be turned off in idlwave mode after you restarted 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)
Normally, I need to enable the auto-fill-mode, so I have it turned on in .emacs. But when editting PHP in php-mode, I'd like to not use auto-fill-mode. Is there way to set it in .emacs such that when I'm in PHP mode, the auto-fill-paragraph mode is automatically turned off and when I leave php-mode, it's automatically turned on, barring other overriding?
Update: a closer examination of the .emacs revealed that auto-fill is set up by
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
...
'(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
...)
Some major-modes inherit certain settings from other modes (e.g., text-mode is used by many popular major modes). The following code snippet can be used to disable a feature for a particular major-mode using its mode hook:
(add-hook 'php-mode-hook (lambda ()
(auto-fill-mode -1) ))
It is sometimes helpful to check and see whether a particular feature has been enabled globally or locally, which in turn can give a clue as to whether that feature has been inherited by a major mode. In this case, the documentation for auto-fill-mode states as follows -- https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html:
"Auto Fill mode is a buffer-local minor mode (see Minor Modes) in which lines are broken automatically when they become too wide. Breaking happens only when you type a <SPC> or <RET>."
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)
Users use 'M-x auto-revert-mode' for starting auto revert mode. How can I set the .emacs file to do the same thing when emacs starts?
How to start a specific mode, when a major mode starts? For example, how to set the .emacs file when I want to start the auto revert mode when LaTeX mode starts?
If you want auto-revert-mode on for all files, add:
(global-auto-revert-mode 1)
If you want it for files for specific modes, try:
(add-hook 'latex-mode-hook '(lambda () (auto-revert-mode 1)))
and substitute the mode name for latex.