Spacemacs Rocks Note Day 3
A series of notes that I learn Emacs hacking. Splitting the `init.el` file, enabling auto revert mode, package loading mechanism overview, enable abbreivation mode, about popwin package, more about major and minor mode in Eamcs, function and variable naming convention, counsel-git to find files.
init.el configuration into multiple files
Use git to keep track of your
git add .
git commit -m "initial commit"
- Or do it with Github (my choice).
- We can also use git to backup
./elpa, in case bug occurs after upgrading a package.
git throw(a self-defined command) to discard anything that is not committed.
- Auto load a file from disk once it is revised by external command.
Package loading mechanism
- The differences can be found on the web
C-h v features: view all the features available.
The real topic of this part
- Recommended organization of configuration files.
init-packages.el: deal with the 3rd party packages, loading and configurations.
init-ui.el: how Emacs looks like.
init-better-defaults.el: improvement of built-in settings.
custom.el: save customize-group.
- Such that we can view and edit things faster.
- Remember to add
- Remember to add the configuration file directory to
- For the
custom.el, we have to all one line code to set the customize group.
- Help to type things fast!
1 2 3 4 (abbrev-mode t) (define-abbrev-table 'global-abbrev-table '( ("ltd" "LanternD") ))
- Recommand: use ‘8’ as the start of the abbrev, prevent typo accidentally.
<enter>to complete the word.
- For key binding,
C-cis for customize key, while
C-xis for built-in keys.
- It helps to move the cursor to the new opened window, such as function manual.
1 2 (require 'popwin) (popwin-mode t)
More about major and minor mode
- Some package just use
(global-xx-mode 1), while some use
- The difference is
autoloadmarco. it needs
- It works with
- “Require” will load a file indirectly, we can do it by calling load-file function.
LanternD/xxxas personal variable or function names.
- Mode naming: everything (variable and function) in the mode should starts with the name of the mode.
- Naming of features:
- We can use prog-mode-hook to turn on line number only for programing mode.
3 types of major mode
Set key for counsel-git
- counsel-git can find a file very fast in a git managed directory.
- Add key binding to it.
1 (global-set-key (kbd "C-c p f") 'counsel-git)