Have done some tests with abbrev-mode
variables. I can set global-abbrev-table
even when abbrev-mode
has not been enabled yet with a hook or with (abbrev-mode 1)
. How does this happen?
1 Answer
[Too long for a comment]
"The question asks about when do variables get defined for abbrev-mode."
The answer is "whenever they are defined". When you first start Emacs, there is a global-abbrev-table
that is empty (there are many other abbrev tables as well but I just discuss the global one for simplicity). If you have a saved abbrev_defs
file from a previous session, Emacs will load that and fill in entries into global-abbrev-table
. If you want to, you can add more entries in this session. All this time, the variable exists and has some value, but it is not used. When you turn abbrev-mode
on, then the variable will be used: every time you finish a word, it will be looked up in the table and if found, it will be replaced by its definition. If you turn abbrev-mode
off, the variable is still around, holding whatever value it had, but now every word you type is NOT looked up and therefore NOT replaced by its definition. The definition still exists though (unless you delete it). Whether the mode is on or off, you can add more definitions to the table. But they will only be used if the mode is on. Finally, when you exit Emacs, the abbrev tables (not just the global one) will be saved in your abbrev_defs
file so that the process can be repeated next time you start Emacs.
The "Abbrev Concepts" section of the Emacs Reference manual says:
You can define abbrevs interactively during the editing session, irrespective of whether Abbrev mode is enabled. You can also save lists of abbrev definitions in files, which you can then reload for use in later sessions.
You can get to it with C-h i g(emacs) RET m abbrev concepts
.
For saving abbrevs, see C-h i g(emacs) RET m saving abbrevs
. Emacs looks for the file where the abbrevs are stored when it starts up and loads it if found. The file name is the value of the variable abbrev-file-name
.
I hope that's clear enough.
-
-
Not sure what you mean:
abbrev.el[c]
is "dumped" when the Emacs binary is created, so it's part of Emacs to begin with. It defines (empty)global-abbrev-table
(and others). Then as Emacs starts running, it calls a functioncommand-line
which parses the command line and does a ton of iniitialization, among which is the loading of any saved abbrev file (as described in the answer). By the time that Emacs is ready and waiting for you to say something, all of this has been done.– NickDAug 5 at 19:38
abbrev-mode
. Looks like it is built-in and becomes available as soon as emacs gets launched. When I make my own configurations, I have to performrequire
first, which I do not see that happening withabbrev-mode
.