I use [[https://elpa.gnu.org][Elpa]], [[https://melpa.org][Melpa]] and [[http://orgmode.org][Org mode]] packages repository, thus I need to add them to the =package-archives= list
I use [[https://elpa.gnu.org][Elpa]], [[https://melpa.org][Melpa]] and [[http://orgmode.org][Org mode]] packages repositories, thus I need to add them to the =package-archives= list
For older emacs version, fix some gnutls algorithm priority
For older emacs version, fix some gnutls algorithm priority
and I want to be sure that compiled versions of packages are up-to-date
and I want to be sure that compiled versions of packages are up-to-date
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(use-package auto-compile
(use-package auto-compile
:config (auto-compile-on-load-mode))
:config
(auto-compile-on-load-mode)
(setq load-prefer-newer t)
(setq load-prefer-newer t)
#+end_src
)
#+end_src
** Non package modules
** Non package modules
Add a folder for .el files that are not available as packages
Add a folder for .el files that are not available as packages
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/plugins")
(add-to-list 'load-path "~/.emacs.d/plugins")
#+end_src
#+end_src
* Global editing configuration
* Global editing configuration
** Default behavior
** Default behavior
I use [[https://github.com/technomancy/better-defaults][better-defaults]] to tweak some annoying Emacs default behaviors. The two most important beeing:
I use [[https://github.com/technomancy/better-defaults][better-defaults]] to tweak some annoying Emacs default behaviors. The two most important beeing:
- use =ido= almost everywhere
- use =ido= almost everywhere,
- put temporary files in a specific folder rather as =~= files everywhere
- put temporary files in a specific folder rather as =~= files everywhere.
there is more to =better-defaults=, be sure to have a look at its list
There is more to =better-defaults=, be sure to have a look at its list of changed behaviors. In
of changed behaviors. In particular, it switches the menu bar off and
particular, it switches the menu bar off and I quite like have it around sometimes, so I re-enable
I quite like have it around sometimes, so I re-enable it.
it. Moreover, Ido is not set everywhere by =better-defaults= and I really want it everywhere
#+BEGIN_SRC emacs-lisp
(use-package better-defaults)
;; I want menu bar
#+BEGIN_SRC emacs-lisp
(menu-bar-mode t)
(use-package better-defaults
#+END_SRC
:config
(menu-bar-mode t)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
)
#+END_SRC
Ido is not set everywhere by =better-defaults= and I really want it everywhere
Allow pressing only =y= instead of =yes= for fast answer to yes or no question
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq ido-enable-flex-matching t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq ido-everywhere t)
#+end_src
#+end_src
** MacOS
As I often use Emacs on MacOS, I need the right option (alt) key to
As I often use Emacs on MacOS, I need the right option (alt) key to behave *as* an option key and
behave *as* an option key and not an Emacs =meta= key.
not an Emacs =meta= key.
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(when (eq system-type 'darwin)
(when (eq system-type 'darwin)
(setq mac-right-option-modifier nil))
(setq mac-right-option-modifier nil))
#+end_src
#+end_src
Allow pressing only =y= instead of =yes= for fast answer to yes or no question
#+begin_src emacs-lisp
;; Make the y or n suffice for a yes or no question
(fset 'yes-or-no-p 'y-or-n-p)
#+end_src
** Editor tweaks
** Editor tweaks
Save the place in the file when killing the buffer so that it reopens at the same spot later
Save the place in the file when killing the buffer so that it reopens at the same spot later
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(save-place-mode t)
(save-place-mode t)
#+end_src
#+end_src
Syntax highlighting everywhere
Syntax highlighting everywhere
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(global-font-lock-mode t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq font-lock-maximum-decoration t)
#+end_src
#+end_src
Use 4 spaces as tab
Use 4 spaces as tab
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq tab-width 4)
(setq tab-width 4)
#+end_src
#+end_src
Allow cursor to top/bottom of file before signaling a scrolling error
Allow cursor to top/bottom of file before signaling a scrolling error
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq scroll-error-top-bottom t)
(setq scroll-error-top-bottom t)
#+end_src
#+end_src
Replace selection as I type
Replace selection as I type
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(delete-selection-mode t)
(delete-selection-mode t)
#+end_src
#+end_src
When using =C-k=, kill the whole line (including =\n=)
When using =C-k=, kill the whole line (including =\n=)
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq kill-whole-line t)
(setq kill-whole-line t)
#+end_src
#+end_src
When moving the cursor up or down, remember when it was on a line end
When moving the cursor up or down, remember when it was on a line end and keep it that way even
and keep it that way even if next line is longer or shorter
if next line is longer or shorter
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq track-eol t)
(setq track-eol t)
#+end_src
#+end_src
Automatically revert buffers if they change on disk. This prevent
Automatically revert buffers if they change on disk. This prevent keeping an outdated buffer open
keeping an outdated buffer open and makes changes that will overwrite
and makes changes that will overwrite the newer file on disk. If the buffer was edited since the
the newer file on disk. If the buffer was edited since the last
last save/revert, Emacs asks what to do.
save/revert, Emacs asks what to do.
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(global-auto-revert-mode t)
(global-auto-revert-mode t)
;; kept for future use, I think I do not want that
;; kept for future use, I think I do not want that
;; (setq global-auto-revert-non-file-buffers nil)
;; (setq global-auto-revert-non-file-buffers nil)
#+end_src
#+end_src
Do not word wrap buffers, truncate long lines
Do not word wrap buffers, truncate long lines
#+begin_src emacs-lisp
#+begin_src emacs-lisp
;; Truncate lines (don't word wrap)
;; Truncate lines (don't word wrap)
(setq truncate-lines t)
(setq truncate-lines t)
#+end_src
#+end_src
If a timestamp tag is present in the file, update it when saving
If a timestamp tag is present in the file, update it when saving
#+begin_src emacs-lisp
#+begin_src emacs-lisp
;; Time stamping
;; Time stamping
(setq time-stamp-active t ; do enable time-stamps
(setq time-stamp-active t ; do enable time-stamps
time-stamp-line-limit 70 ; check first 70 buffer lines for Time-stamp:
time-stamp-line-limit 70 ; check first 70 buffer lines for Time-stamp:
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
(add-hook 'write-file-hooks 'time-stamp)
(add-hook 'write-file-hooks 'time-stamp)
#+end_src
#+end_src
Define a shortcut to re-indent all buffer. This saves the current point, marks whole buffer and call =indent-region=
Define a shortcut to re-indent all buffer. This saves the current point, marks whole buffer and call =indent-region=
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(defun mh/indent-buffer()
(defun mh/indent-buffer()
(interactive)
(interactive)
(save-excursion
(save-excursion
(indent-region (point-min) (point-max))))
(indent-region (point-min) (point-max))))
(global-set-key (kbd "C-c i b") 'mh/indent-buffer)
(global-set-key (kbd "C-c i b") 'mh/indent-buffer)
#+end_src
#+end_src
#+RESULTS:
: mh/indent-buffer
Set the line width for fill command
Set the line width for fill command
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq-default fill-column 100)
(setq-default fill-column 100)
#+end_src
#+end_src
** Undo on steroids
Manage undo as a tree so that we can undo/redo more. Bound by default on =C-x u=
**Deactivated yet**
#+begin_src emacs-lisp
;;(use-package undo-tree
;; :config
;; (global-undo-tree-mode))
#+end_src
* UI and visual tweaks
* UI and visual tweaks
** Changes to builtin visuals
** Changes to builtin visuals
I always display visual line where the cursor is and I like to have line numbers at the left of the
I always display visual line where the cursor is and I like to have line numbers at the left of the
buffer. I also have Emacs to show me matching parenthesis. Also do not show the welcome screen.
buffer. I also like to have Emacs show me matching parenthesis. Also do not show the welcome screen.
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp
;; Do not show welcome screen
;; Do not show welcome screen
(setq inhibit-startup-screen t)
(setq inhibit-startup-screen t)
...
@@ -298,54 +278,47 @@ buffer. I also have Emacs to show me matching parenthesis. Also do not show the
...
@@ -298,54 +278,47 @@ buffer. I also have Emacs to show me matching parenthesis. Also do not show the