I have a question about Emacs Lisp. What is the difference between setq and setq-default?
Tutorials say setq takes effect in the local buffer while setq-default affects all buffers.
For example, if I wrote (setq a-var a-vars-value) in init.el, I found after starting Emacs and opening a new buffer, the a-var is also there and its value is a-vars-value. I thought it was not supposed to be there. It seems there is no difference between setq and setq-default.
Is there something wrong with my understanding?
For example:
I wrote (setq hello 123) in the init.el file, and I run emacs abuffer in the shell, then I input "hello C-x C-e", it shows "123". The same happens when I run this in all new buffers.
I wrote (setq tab-width 4) in the init.el file. When I run tab-width C-x C-e, it shows "8" (Current mode is 'Text'). However, when I use (setq-default tab-width 4), it show "4". I can't explain this phenomenon.