Foreword
I know the title looks subjective, but I want this question to be a smooth introduction to spacemacs for newcomers not coming from emacs at all (which is my case).
You might wonder why I decided to use spacemacs, which is a highly custom hack over emacs, without taking the time to get used to vanilla emacs first. Well, in fact, I've been trying to use emacs and vim for a long time because I could understand why those software were able to boost productivity and make you feel more "at home" when coding/hacking.
Unfortunately, while I was starting to get used to vim a bit, the time you need to spend in learning, and most of all, the time you need to spend in configuring those software, was way too high for me.
Then I discovered spacemacs, which takes a bit of what is great in vim, what is great in emacs, and put them together into a nice mostly preconfigured package.
The issue is that most of the configuration is done through emacs-lisp, and expects the user to understand how the code is loaded and executed when you start the software, which I completely don't (as I started to realize the more and more I digged into the code).
What I want to achieve
I want to be able to start emacs, and see it execute some custom code I would write so that:
- the line numbers are showing in any buffer I open
- git live changes are shown in the left side
- symbols are highlighted when the cursor is over
- my "home page" show a list of projects and I can load the most recent one, which remembers the buffer configuration from last time
I want to be able to actually code those features (and maybe a bunch of others) when necessary, or install them when they are already available.
What I tried
(and what doesn't work)
I (naively) configured my spacemacs like any lisp/emacs newcomer would do:
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration. You are free to put any user code."
;; TODO
;; - Display whitespaces
;; - Install workgroups2
;; interface ;; this works
(setq powerline-default-separator 'arrow)
;; mouse scroll ;; this works? maybe
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
;; middle click copy-paste ;; this works
(setq x-select-enable-primary t)
;; diff-hl ;; this used to work but now does not
(diff-hl-flydiff-mode)
(setq diff-hl-side 'left)
;; rust ;; this works (and seems the right way to do it)
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
;; neotree ;; this works? maybe
(setq neo-show-hidden-files nil)
;; toggle preferences ;; this does not work
(spacemacs/toggle-automatic-symbol-highlight-on)
(spacemacs/toggle-line-numbers-on)
;; COrrect DOuble CAps ;; this does not works either (should be a hook)
(doublecaps-mode 1)
)
The question
I am conscious that there is a concept called "major-modes" and "minor-modes" which apply respectively to all buffers or only specific buffer instances, but I am also very confused about the fact that emacs has its own global and local variables (which seems to be customizable through (setq)
), that spacemacs also has variables or methods to customize (spacemacs/toggle-something-on)
but also (custom-set-variables)
, and that most of what I want to do is achievable using "hooks".
The spacemacs documentation leaves me completely clueless because it mostly asumes you know how things work, and the emacs one is like a nuclear plant maintenance guide.
Could somebody at ease with spacemacs give me an "entry point" to understanding those concepts?
I want to be able to answer the questions: "Oh, I want to customize that behavior, where do I need to code? What are the methods I should call? What are the methods I should NOT call? What variable can I change/create? What is actually executed when I put my code here?...etc"