Because the allout.el
is standard a library, rather than an optional ELPA package, to enable the it (allout minor mode) on Emacs starts for all modes can be as simple as creating a global version of the minor mode like so:
(defun my-turn-on-allout-mode-maybe ()
"Enable `allout-mode', where applicable."
;; Unconditional here, but edit as desired if it turns out
;; that you don't actually want this for ALL modes.
;; (This function is called in every buffer, when the
;; global mode is enabled.)
(allout-mode 1))
(define-globalized-minor-mode my-global-allout-mode allout-mode
my-turn-on-allout-mode-maybe
:group 'allout)
(my-global-allout-mode 1)
thanks to phils' answer from How to redefine the allout prefix keybinding.
Now I have two questions.
Question #1, suppose, just suppose, because I don't know emacs well to give another good example, that allout-mode is a minor mode from ELPA that I installed myself. How to enable it in this case? Would the above still be good?
My main confusing is about timing. From http://www.emacswiki.org/emacs/ELPA#toc6, it says,
Whenever Emacs starts up, it automatically calls the function ‘package-initialize’ to load installed packages. This is done after loading the init file... So packages are initialized AFTER the init.el is loaded. This means you should NOT put package specific initialization into your init.el except...
So if the installed packages are loaded after loading the init file, then how can I enable them in the init file, when the package is not loaded yet? Would the above still be good?
I meant, once the ELPA packages are installed locally, they would behave exactly like any other locally available library (either from system or from person libs), right? They normally would be required, which means loading a package if it has not already been loaded. The system library are normally autoloaded, which means loading a file only when a function is called. I don't think the ELPA packages cannot be autoloaded, correct? So my anwser would be, the above will still be good, is that correct?
Question #2, now that with above code I've turn the minor mode into a global mode, how to disable it for a specific mode, say markdown-mode?
I tired this
(use-package markdown-mode
:mode ("\\.\\(txt\\|markdown\\|md\\)\\(\\'\\|\\.\\)" . gfm-mode)
:init
(progn
(flyspell-mode 1)
(allout-mode -1)
))
but the allout-mode is still on when I open a markdown file.
UPDATE, for the record, for all my questions, I gather all the answers to here.