diff --git a/configuration.org b/configuration.org
index 2f78959e5716220b63bb72607da6f4fa68dcd033..befa462e3fa5e59e3bf07f47f35278bcc5cd11ab 100644
--- a/configuration.org
+++ b/configuration.org
@@ -8,251 +8,251 @@ Some of my configuration entries where borrowed from other people, see
* Performances tweaks (part. 1, start)
- I am currently experimenting with Emacs 28 and, specifically,
- GccEmacs that compiles elisp to native binaries. To compile emacs28
- to macOs (until it is released):
-
- 1. Clone [[https://github.com/jimeh/build-emacs-for-macos][build-emacs-for-macos]]
- 2. Install build dependencies with =brew bundle install= in the cloned folder
- 3. run =./build-emacs-for-macos feature/native-comp=
- 4. The =Emacs.app= will be available in an archive in the =builds=
- folder
-
- This sets gcc optimization flag to =-O2= (max optimization level,
- fully adherent to the langage semantic).
-#+begin_src emacs-lisp
+I am currently experimenting with Emacs 28 and, specifically,
+GccEmacs that compiles elisp to native binaries. To compile emacs28
+to macOs (until it is released):
+
+1. Clone [[https://github.com/jimeh/build-emacs-for-macos][build-emacs-for-macos]]
+2. Install build dependencies with =brew bundle install= in the cloned folder
+3. run =./build-emacs-for-macos feature/native-comp=
+4. The =Emacs.app= will be available in an archive in the =builds=
+ folder
+
+ This sets gcc optimization flag to =-O2= (max optimization level,
+ fully adherent to the langage semantic).
+ #+begin_src emacs-lisp
(unless (version< emacs-version "28")
-(setq comp-speed 2)
-)
-#+end_src
+ (setq comp-speed 2)
+ )
+ #+end_src
- Decrease the GC frequency by setting the threshold high for
- configuration loading. The threshold will be set lower at the end of
- the configuration to make each GC call faster for normal emacs use.
+ Decrease the GC frequency by setting the threshold high for
+ configuration loading. The threshold will be set lower at the end of
+ the configuration to make each GC call faster for normal emacs use.
- #+begin_src emacs-lisp
+ #+begin_src emacs-lisp
(setq gc-cons-threshold (* 60 1024 1024))
- #+end_src
+ #+end_src
* Personal information
- Sets who I am
+Sets who I am
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq user-full-name "Michaël Hauspie"
user-mail-address "michael.hauspie@univ-lille.fr"
calendar-latitude 50.60483
calendar-longitude 3.1464
calendar-location-name "Villeneuve d'Ascq, France")
- #+end_src
+#+end_src
* Packages management
- 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 repository, thus I need to add them to the =package-archives= list
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
- #+END_SRC
+#+END_SRC
- Then, to ensure that packages are installed and that I can launch
- Emacs on a new computer and have it setup automatically, I use
- =use-package=.
+Then, to ensure that packages are installed and that I can launch
+Emacs on a new computer and have it setup automatically, I use
+=use-package=.
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
(when (not (package-installed-p 'use-package))
(package-refresh-contents)
(package-install 'use-package))
- #+END_SRC
+#+END_SRC
- If I use a package, I want to ensure that it is installed, so set
- ensure package by default
+If I use a package, I want to ensure that it is installed, so set
+ensure package by default
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
(require 'use-package-ensure)
(setq use-package-always-ensure t)
- #+END_SRC
+#+END_SRC
- I like to keep things up to date, so I use =auto-package-update=
+I like to keep things up to date, so I use =auto-package-update=
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
;; (use-package auto-package-update
;; :config
;; (setq auto-package-update-delete-old-versions t)
;; (setq auto-package-update-hide-results t)
;; (auto-package-update-maybe))
- #+END_SRC
+#+END_SRC
- 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
:config (auto-compile-on-load-mode))
(setq load-prefer-newer t)
- #+end_src
+#+end_src
* Global editing configuration
** 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
- - put temporary files in a specific folder rather as =~= files everywhere
+ - use =ido= almost 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
- of changed behaviors. In particular, it switches the menu bar off and
- I quite like have it around sometimes, so I re-enable it.
+ there is more to =better-defaults=, be sure to have a look at its list
+ of changed behaviors. In particular, it switches the menu bar off and
+ I quite like have it around sometimes, so I re-enable it.
- #+BEGIN_SRC emacs-lisp
+ #+BEGIN_SRC emacs-lisp
(use-package better-defaults)
;; I want menu bar
(menu-bar-mode t)
- #+END_SRC
+ #+END_SRC
- Ido is not set everywhere by =better-defaults= and I really want it everywhere
+ Ido is not set everywhere by =better-defaults= and I really want it everywhere
- #+begin_src emacs-lisp
+ #+begin_src emacs-lisp
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
- #+end_src
+ #+end_src
- As I often use Emacs on MacOS, I need the right option (alt) key to
- behave *as* an option key and not an Emacs =meta= key.
+As I often use Emacs on MacOS, I need the right option (alt) key to
+behave *as* an option key and not an Emacs =meta= key.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(when (eq system-type 'darwin)
(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
+Allow pressing only =y= instead of =yes= for fast answer to yes or no question
- #+begin_src emacs-lisp
+#+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
+#+end_src
** 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)
- #+end_src
+#+end_src
- Syntax highlighting everywhere
+Syntax highlighting everywhere
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(global-font-lock-mode 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)
- #+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)
- #+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)
- #+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)
- #+end_src
+#+end_src
- When moving the cursor up or down, remember when it was on a line end
- and keep it that way even if next line is longer or shorter
+When moving the cursor up or down, remember when it was on a line end
+and keep it that way even if next line is longer or shorter
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq track-eol t)
- #+end_src
+#+end_src
- Automatically revert buffers if they change on disk. This prevent
- keeping an outdated buffer open and makes changes that will overwrite
- the newer file on disk. If the buffer was edited since the last
- save/revert, Emacs asks what to do.
+Automatically revert buffers if they change on disk. This prevent
+keeping an outdated buffer open and makes changes that will overwrite
+the newer file on disk. If the buffer was edited since the last
+save/revert, Emacs asks what to do.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(global-auto-revert-mode t)
;; kept for future use, I think I do not want that
;; (setq global-auto-revert-non-file-buffers nil)
- #+end_src
+#+end_src
- Do not word wrap buffers, truncate long lines
- #+begin_src emacs-lisp
+Do not word wrap buffers, truncate long lines
+#+begin_src emacs-lisp
;; Truncate lines (don't word wrap)
(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
(setq time-stamp-active t ; do enable time-stamps
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
(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()
(interactive)
(save-excursion
(indent-region (point-min) (point-max))))
(global-set-key (kbd "C-c i b") 'mh/indent-buffer)
- #+end_src
+#+end_src
- #+RESULTS:
- : mh/indent-buffer
+#+RESULTS:
+: mh/indent-buffer
** Undo on steroids
- Manage undo as a tree so that we can undo/redo more. Bound by default on =C-x u=
+Manage undo as a tree so that we can undo/redo more. Bound by default on =C-x u=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package undo-tree
:config
(global-undo-tree-mode))
- #+end_src
+#+end_src
* UI and visual tweaks
** 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 buffer. I also have Emacs to show me
- matching parenthesis. Also do not show the welcome screen.
+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.
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
;; Do not show welcome screen
(setq inhibit-startup-screen t)
@@ -268,50 +268,50 @@ Some of my configuration entries where borrowed from other people, see
;; Detailed window title
(setq-default frame-title-format (list "%65b %f"))
(setq-default icon-title-format (list "%b"))
- #+END_SRC
+#+END_SRC
- #+RESULTS:
- | %b |
+#+RESULTS:
+| %b |
** Theme
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
(use-package color-theme-sanityinc-tomorrow
:config
(load-theme 'sanityinc-tomorrow-bright t)
)
- #+END_SRC
+#+END_SRC
- Use Fira Code with ligature
+Use Fira Code with ligature
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package fira-code-mode
:config
(global-fira-code-mode)
(setq fira-code-mode-enable-hex-literal nil)
)
- #+end_src
+#+end_src
** Modeline
- Use =moody= for a nice looking bottom modeline
+Use =moody= for a nice looking bottom modeline
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
;; (use-package moody
;; :config
;; (setq x-underline-at-descent-line t
;; moody-mode-line-height 10)
;; (moody-replace-mode-line-buffer-identification)
;; (moody-replace-vc-mode))
- #+end_src
+#+end_src
- Tweak how some modeline elements are displayed
+Tweak how some modeline elements are displayed
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
;; Show line and column number in mode line
(column-number-mode t)
(line-number-mode t)
@@ -320,13 +320,13 @@ Some of my configuration entries where borrowed from other people, see
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time-mode t)
- #+end_src
+#+end_src
- To not display all minor modes. =eval-after-load= is there to
- ensure that diminish is called only for modules that are installed
- and loaded.
- #+begin_src emacs-lisp
+To not display all minor modes. =eval-after-load= is there to
+ensure that diminish is called only for modules that are installed
+and loaded.
+#+begin_src emacs-lisp
(use-package diminish
:config
(eval-after-load "company" '(diminish 'company-mode))
@@ -336,40 +336,40 @@ Some of my configuration entries where borrowed from other people, see
(eval-after-load "which-key" '(diminish 'which-key-mode))
(diminish 'eldoc-mode)
)
- #+end_src
+#+end_src
** Shortcut dynamic help buffer
- When a key binding sequence is started and not finished, display
- possible next keys in the mini-buffer
+When a key binding sequence is started and not finished, display
+possible next keys in the mini-buffer
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package which-key
:config
(which-key-mode t))
- #+end_src
+#+end_src
** Winner mode for undo/redo buffer configuration
- Enable winner mode globally. Then with =C-c left= and =C-c right=
- we can redo/undo the buffer configuration
+Enable winner mode globally. Then with =C-c left= and =C-c right=
+we can redo/undo the buffer configuration
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(winner-mode t)
- #+end_src
+#+end_src
* Org mode
- This is one of the most important mode I use in Emacs. I use it to
- organize tasks, take meetings notes, write articles, lectures... I use
- org with contributed packages added.
+This is one of the most important mode I use in Emacs. I use it to
+organize tasks, take meetings notes, write articles, lectures... I use
+org with contributed packages added.
** Basics
- #+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp
(use-package org
;; :ensure org-plus-contrib
;; :ensure org-tempo
@@ -379,22 +379,22 @@ Some of my configuration entries where borrowed from other people, see
;; IDO for completion when applicable
(org-completion-use-ido t)
;; hide emphasis markers
-;; (org-hide-emphasis-markers t)
+ ;; (org-hide-emphasis-markers t)
:config
;; (require 'org-tempo)
(add-hook 'org-mode-hook
(lambda ()
- (setq org-file-apps
- '(("org" . emacs)
- ("rs" . emacs)
- ("c" . emacs)
- ("h" . emacs)
- )))))
- #+END_SRC
+ (setq org-file-apps
+ '(("org" . emacs)
+ ("rs" . emacs)
+ ("c" . emacs)
+ ("h" . emacs)
+ )))))
+#+END_SRC
- Add a shortcut to toggle display of emphasis characters
+Add a shortcut to toggle display of emphasis characters
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(defun org-toggle-emphasis ()
"Toggle hiding/showing of org emphasize markers."
(interactive)
@@ -402,70 +402,70 @@ Some of my configuration entries where borrowed from other people, see
(set-variable 'org-hide-emphasis-markers nil)
(set-variable 'org-hide-emphasis-markers t)))
(define-key org-mode-map (kbd "C-c e") 'org-toggle-emphasis)
- #+end_src
+#+end_src
- Use =org-mode= for the initial scratch buffer
+Use =org-mode= for the initial scratch buffer
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq initial-major-mode 'org-mode)
- #+end_src
+#+end_src
- And set some keyboard shortcuts for links and agenda
+And set some keyboard shortcuts for links and agenda
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
- #+end_src
+#+end_src
- Add shortcuts to quickly add code blocks using =C-,=
+Add shortcuts to quickly add code blocks using =C-,=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp"))
- #+end_src
+#+end_src
** Visuals
- Use bullets instead of asterisks
+Use bullets instead of asterisks
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package org-bullets
:init
(add-hook 'org-mode-hook 'org-bullets-mode))
- #+end_src
+#+end_src
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(set-face-foreground 'org-verbatim "orange1")
- #+end_src
+#+end_src
** Task management
- Record when a todo item was marked as done and enforce marking
- dependencies as done before being able to mark an item as done
+Record when a todo item was marked as done and enforce marking
+dependencies as done before being able to mark an item as done
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-log-done 'time)
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
- #+end_src
+#+end_src
- Set default task completion states to =TODO=, =WAITING= and
- =DONE=. I use =WAITING= when I can't go further on a task because
- I'm waiting for some inputs.
+Set default task completion states to =TODO=, =WAITING= and
+=DONE=. I use =WAITING= when I can't go further on a task because
+I'm waiting for some inputs.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-todo-keywords
'((sequence "TODO" "WAITING" "|" "DONE")))
- #+end_src
+#+end_src
*** index and archive files
- Index and archive are my main todo lists (index) and a list of archived (done) tasks.
+Index and archive are my main todo lists (index) and a list of archived (done) tasks.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-directory "~/documents/org")
(defun org-file-path (filename)
@@ -475,20 +475,20 @@ Some of my configuration entries where borrowed from other people, see
(setq org-index-file (org-file-path "index.org"))
(setq org-archive-location
(concat (org-file-path "archive.org") "::* From %s"))
- #+end_src
+#+end_src
- Then more specifics org files to add to the agenda list
+Then more specifics org files to add to the agenda list
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-agenda-files (list org-index-file
"~/.emacs.d/configuration.org"
(org-file-path "work.org")
(org-file-path "archive.org"))) ; Just in case I forget to mark a subtask as done and archive the main one
- #+end_src
+#+end_src
- Hitting =C-c C-x C-s= will mark a todo as done and move it to an appropriate place in the archive.
+Hitting =C-c C-x C-s= will mark a todo as done and move it to an appropriate place in the archive.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(defun hrs/mark-done-and-archive ()
"Mark the state of an org-mode item as DONE and archive it."
(interactive)
@@ -496,44 +496,44 @@ Some of my configuration entries where borrowed from other people, see
(org-archive-subtree))
(define-key org-mode-map (kbd "C-c C-x C-s") 'hrs/mark-done-and-archive)
- #+end_src
+#+end_src
** Agenda
- The week should begin today, not last Monday for the agenda view
+The week should begin today, not last Monday for the agenda view
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-agenda-start-on-weekday nil)
- #+end_src
+#+end_src
- I want to see more days in the agenda view
+I want to see more days in the agenda view
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-agenda-span 15)
- #+end_src
+#+end_src
- Define a custom agenda view. I want my agenda with tasks that are
- scheduled or have a deadline, but also all other tasks that do not
- have a date scheduled or as deadline. This is for tasks that I will
- eventualy do later.
+Define a custom agenda view. I want my agenda with tasks that are
+scheduled or have a deadline, but also all other tasks that do not
+have a date scheduled or as deadline. This is for tasks that I will
+eventualy do later.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-agenda-custom-commands
'(("a" "Agenda"
(
(agenda "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))))
(alltodo "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline 'todo 'done))))
))))
- #+end_src
+#+end_src
** Capture
- Define some capture template to be able to create tasks, or maybe
- other things later
+Define some capture template to be able to create tasks, or maybe
+other things later
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-capture-templates
'(("f" "Finished book"
table-line (file "~/Documents/org/books-read.org")
@@ -556,25 +556,25 @@ Some of my configuration entries where borrowed from other people, see
("w" "Cycling to work"
table-line (file "~/Documents/org/cycling.org")
"| %t | boulot | %^{prompt|électrique|standard} | 26.2 |")))
- #+end_src
+#+end_src
** Tree slide
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package org-tree-slide
-:config
-(define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode)
-)
- #+end_src
+ :config
+ (define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode)
+ )
+#+end_src
** Export configuration
- I use =org-mode= to export to LaTeX, (beamer and article) markdown and to HTML
- using bootstrap template.
+I use =org-mode= to export to LaTeX, (beamer and article) markdown and to HTML
+using bootstrap template.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
;; Add Beamer to export list
(require 'ox-beamer)
;; And markdown
@@ -588,15 +588,15 @@ Some of my configuration entries where borrowed from other people, see
;; bootstrap html
(use-package ox-twbs)
- #+end_src
+#+end_src
- #+RESULTS:
+#+RESULTS:
- So that code highlighting can be done using [[https://www.ctan.org/pkg/minted][minted]] (which uses
- [[https://pygments.org/][Pygments]] as an external tool), we need to change latex export commands.
+So that code highlighting can be done using [[https://www.ctan.org/pkg/minted][minted]] (which uses
+[[https://pygments.org/][Pygments]] as an external tool), we need to change latex export commands.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
;; Configure ox-latex to export source block using minted
;; Setting minted cache to false as cache seems to fail when changing the output-directory
(add-to-list 'org-latex-packages-alist '("cache=false" "minted"))
@@ -606,23 +606,23 @@ Some of my configuration entries where borrowed from other people, see
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
- #+end_src
+#+end_src
- For HTML source code highlight, use =htmlize=
+For HTML source code highlight, use =htmlize=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package htmlize)
- #+end_src
+#+end_src
** Source code evaluation
- So that source code blocks can be evaluated inside =org-mode=, we add
- it to babel languages. =org-babel= is what executes code and outputs
- its result in your org file.
+So that source code blocks can be evaluated inside =org-mode=, we add
+it to babel languages. =org-babel= is what executes code and outputs
+its result in your org file.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package gnuplot)
(use-package gnuplot-mode)
(use-package ob-rust)
@@ -643,59 +643,59 @@ Some of my configuration entries where borrowed from other people, see
(shell . t)
(rust . t)
))
- #+END_SRC
+#+END_SRC
- Preserve indentation in source block (useful for makefiles to preserve tabs for example)
- #+begin_src emacs-lisp
+Preserve indentation in source block (useful for makefiles to preserve tabs for example)
+#+begin_src emacs-lisp
(setq org-src-preserve-indentation t)
- #+end_src
+#+end_src
- Don't ask before evaluating
+Don't ask before evaluating
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-confirm-babel-evaluate nil)
- #+end_src
+#+end_src
- Correctly associate =dot= language with the correct major-mode inside org.
+Correctly associate =dot= language with the correct major-mode inside org.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package graphviz-dot-mode)
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
- #+end_src
+#+end_src
- Make org mode correctly export quotes
+Make org mode correctly export quotes
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq org-export-with-smart-quotes t)
- #+end_src
+#+end_src
- Use =python3=
+Use =python3=
#+begin_src emacs-lisp
(setq org-babel-python-command "python3")
#+end_src
- Set line count limit before using =begin_example= blocs in code evaluation results
- #+begin_src emacs-lisp
+Set line count limit before using =begin_example= blocs in code evaluation results
+#+begin_src emacs-lisp
(setq org-babel-min-lines-for-block-output 10)
- #+end_src
+#+end_src
- #+RESULTS:
- : 10
+#+RESULTS:
+: 10
* Completion setup
- I use [[http://company-mode.github.io/][company]] mode for completion. It provides a visual completion
- list of what can be used to complete. It works with several backends such as
- LSP, with which it provides semantic completion for code editing.
+I use [[http://company-mode.github.io/][company]] mode for completion. It provides a visual completion
+list of what can be used to complete. It works with several backends such as
+LSP, with which it provides semantic completion for code editing.
- First, install and configure company and enable it for
- all buffers. I also set =M-/= to trigger =company-complete=
+First, install and configure company and enable it for
+all buffers. I also set =M-/= to trigger =company-complete=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package company
:ensure company-lsp
:ensure company-box
@@ -709,94 +709,94 @@ Some of my configuration entries where borrowed from other people, see
(company-minimum-prefix-length 3)
(company-idle-delay 0.1)
)
- #+end_src
+#+end_src
- #+RESULTS:
+#+RESULTS:
- Then, add backends and company tweaks.
+Then, add backends and company tweaks.
- =company-box= adds icons to company complete list. It is useful when
- completing symbols in source code.
+=company-box= adds icons to company complete list. It is useful when
+completing symbols in source code.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package company-box
:ensure frame-local
:hook (company-mode . company-box-mode))
- #+end_src
+#+end_src
- Now some backends I use. Mainly lsp, php and web
- related. =company-lsp= is slow to start, so we force a defer loading
- only when it's needed.
+Now some backends I use. Mainly lsp, php and web
+related. =company-lsp= is slow to start, so we force a defer loading
+only when it's needed.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package company-php)
(use-package company-web)
(use-package company-lsp
:defer t)
- #+end_src
+#+end_src
* Code navigation
** Treemacs
- I use [[https://github.com/Alexander-Miller/treemacs][Treemacs]] for code navigation. You can use it to define
- /projects/ (a project is a folder actually) from which you can easily
- navigate. You can have several workspaces that are simply a list of
- projects. I bind =C-c t= to toggle treemacs panel.
+I use [[https://github.com/Alexander-Miller/treemacs][Treemacs]] for code navigation. You can use it to define
+/projects/ (a project is a folder actually) from which you can easily
+navigate. You can have several workspaces that are simply a list of
+projects. I bind =C-c t= to toggle treemacs panel.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package treemacs
:custom
(treemacs--icon-size 16)
:bind ("C-c t" . treemacs-select-window)
)
- #+end_src
+#+end_src
** Projectile
- Projectile allows for easy file navigation inside
- projects. Projects are automatically detected by projectile
- whenever a =.git= folder or a =.projectile= file is in a foler.
+Projectile allows for easy file navigation inside
+projects. Projects are automatically detected by projectile
+whenever a =.git= folder or a =.projectile= file is in a foler.
- Bind =C-c p= as the prefix for projectile command keybinds.
+Bind =C-c p= as the prefix for projectile command keybinds.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package projectile
:config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode t))
- #+end_src
+#+end_src
- As I use =treemacs=, adds =treemacs-projectile= plugin
+As I use =treemacs=, adds =treemacs-projectile= plugin
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package treemacs-projectile)
- #+end_src
+#+end_src
* Snippets
- I use =yasnippet= for defining and using snippets for several modes. I
- preload all snippets by [[https://github.com/AndreaCrotti/yasnippet-snippets][AndreaCrotti]] (=yasnippet-snippets= package).
+I use =yasnippet= for defining and using snippets for several modes. I
+preload all snippets by [[https://github.com/AndreaCrotti/yasnippet-snippets][AndreaCrotti]] (=yasnippet-snippets= package).
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package yasnippet
:init
(yas-global-mode))
(use-package yasnippet-snippets)
- #+end_src
+#+end_src
* Developpement
- Here, I setup all packages for developping in several languages. This
- starts by configuring [[https://emacs-lsp.github.io/lsp-mode/][LSP]] which allow emacs to get semantic
- information from a language server dedicated to the programming
- language currently in use.
+Here, I setup all packages for developping in several languages. This
+starts by configuring [[https://emacs-lsp.github.io/lsp-mode/][LSP]] which allow emacs to get semantic
+information from a language server dedicated to the programming
+language currently in use.
** LSP
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package lsp-mode
:hook (
(c++-mode . lsp)
@@ -808,67 +808,77 @@ Some of my configuration entries where borrowed from other people, see
(lsp-headerline-breadcrumb-mode t)
:commands lsp
)
- #+end_src
+#+end_src
- For displaying more information directly in the buffer, I use =lsp-ui=
+For displaying more information directly in the buffer, I use =lsp-ui=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package lsp-ui
:commands lsp-ui-mode)
- #+end_src
+#+end_src
- LSP keybinds
+LSP keybinds
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq lsp-keymap-prefix "s-l")
- #+end_src
+#+end_src
*** Integration with treemacs
- LSP can integrate with treemacs to display packages, class, symbols and such.
+LSP can integrate with treemacs to display packages, class, symbols and such.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package lsp-treemacs
:custom
(lsp-treemacs-sync-mode 1))
- #+end_src
+#+end_src
** Flycheck
- [[https://www.flycheck.org/][Flycheck]] allow synthax checking in the source code buffer. LSP uses
- flycheck if available to show code diagnosis.
+[[https://www.flycheck.org/][Flycheck]] allow synthax checking in the source code buffer. LSP uses
+flycheck if available to show code diagnosis.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package flycheck)
- #+end_src
+#+end_src
- For languages that do not have LSP yet, we can add some flycheck extensions
+For languages that do not have LSP yet, we can add some flycheck extensions
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package flycheck-perl6)
- #+end_src
+#+end_src
** Language specific configuration
+*** C
+
+Set indentation size and parameters
+#+begin_src emacs-lisp
+(setq c-default-style "linux"
+ c-basic-offset 4)
+#+end_src
+
+#+RESULTS:
+
*** Rust
- Install =rust-mode= and set the rust language server to [[https://rust-analyzer.github.io/][rust-analyzer]]
+Install =rust-mode= and set the rust language server to [[https://rust-analyzer.github.io/][rust-analyzer]]
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package rust-mode
:custom
(lsp-rust-server 'rust-analyzer)
; (rust-format-on-save t)
)
- #+end_src
+#+end_src
- For this to work, you need to install =rust-analyzer= and =rustmft=.
+For this to work, you need to install =rust-analyzer= and =rustmft=.
- #+begin_src bash :results output verbatim
+#+begin_src bash :results output verbatim
if [[ "$OSTYPE" =~ ^darwin ]]
then
echo "Installing for macos"
@@ -879,54 +889,54 @@ else
fi
curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/$binary -o ~/.cargo/bin/rust-analyzer
chmod +x ~/.cargo/bin/rust-analyzer
- #+end_src
+#+end_src
- #+RESULTS:
- : Installing for macos
+#+RESULTS:
+: Installing for macos
- Adds cargo installed binaries to exec path
+Adds cargo installed binaries to exec path
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq exec-path (cons "~/.cargo/bin" exec-path))
- #+end_src
+#+end_src
*** Lua
- Simply add =lua-mode=
+Simply add =lua-mode=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package lua-mode)
- #+end_src
+#+end_src
*** Docker
- For dockerfiles and docker-compose files, install some docker packages
+For dockerfiles and docker-compose files, install some docker packages
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package dockerfile-mode)
(use-package docker-compose-mode)
(use-package docker)
(use-package docker-api)
(use-package docker-cli)
(use-package docker-tramp)
- #+end_src
+#+end_src
*** Web
- Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web editing.
-
- - =web-mode= is a major mode for web template editing. We
- associate the mode with web files
- - =rainbow-mode= colorizes color names in buffers
- - =simple-httpd= is an http server implemented in =elisp= that can
- serve local directory and even remote directory if associated
- with tramp
- - =impatient-mode= serves buffers dynamically with
- =simple-httpd=. What you edit in emacs is immediatly visible on
- the web browser
+Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web editing.
+
+- =web-mode= is a major mode for web template editing. We
+ associate the mode with web files
+- =rainbow-mode= colorizes color names in buffers
+- =simple-httpd= is an http server implemented in =elisp= that can
+ serve local directory and even remote directory if associated
+ with tramp
+- =impatient-mode= serves buffers dynamically with
+ =simple-httpd=. What you edit in emacs is immediatly visible on
+ the web browser
- #+begin_src emacs-lisp
+ #+begin_src emacs-lisp
(use-package web-mode
:config
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
@@ -941,43 +951,53 @@ chmod +x ~/.cargo/bin/rust-analyzer
(use-package rainbow-mode)
(use-package simple-httpd)
(use-package impatient-mode)
- #+end_src
+ #+end_src
*** LaTeX
- Enable =reftex= whenever =tex-mode= is activated
+Enable =reftex= whenever =tex-mode= is activated
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(add-hook 'latex-mode-hook 'reftex-mode)
- #+end_src
+#+end_src
- Use =auctex= for better experience editing latex files
+Use =auctex= for better experience editing latex files
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package auctex
:ensure auctex-latexmk
:defer t
)
- #+end_src
+#+end_src
- If using macos, add mactex to =exec-path=
+If using macos, add mactex to =exec-path=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(when (eq system-type 'darwin)
(setq exec-path (cons "/Library/TeX/texbin" exec-path)))
- #+end_src
+#+end_src
*** Ningx configuration
- A mode to edit [[https://nginx.org/][nginx]] configuration files.
+A mode to edit [[https://nginx.org/][nginx]] configuration files.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package nginx-mode)
- #+end_src
+#+end_src
+
+*** Terraform
+
+Packages to edit terraform configuration files
+
+#+begin_src emacs-lisp
+(use-package terraform-mode)
+(use-package terraform-doc)
+(use-package company-terraform)
+#+end_src
** Magit
- [[https://magit.vc/][Magit]] is git porcelain inside emacs.
+[[https://magit.vc/][Magit]] is git porcelain inside emacs.
+ Bind =C-x g= to pop up the magit status buffer
@@ -987,85 +1007,85 @@ chmod +x ~/.cargo/bin/rust-analyzer
+ Save buffers that visit a file that belongs to a repository if
needed
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package magit
:config
(magit-auto-revert-mode t)
(magit-save-repository-buffers t)
:bind ("C-x g" . magit-status)
)
- #+end_src
+#+end_src
*** Protocol buffers
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package protobuf-mode)
- #+end_src
+#+end_src
* Spell checking
- First, set =aspell= to be the spell checking program instead of =ispell=
+First, set =aspell= to be the spell checking program instead of =ispell=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq ispell-program-name "aspell")
- #+end_src
+#+end_src
- #+RESULTS:
- : aspell
+#+RESULTS:
+: aspell
- Then define a command that will run flyspell on the buffer *and* activate it
+Then define a command that will run flyspell on the buffer *and* activate it
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(defun mh/spellcheck ()
(interactive)
(flyspell-mode t)
(flyspell-buffer)
)
- #+end_src
+#+end_src
- And define a global binding to call it
+And define a global binding to call it
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(global-set-key (kbd "C-c s") 'mh/spellcheck)
- #+end_src
+#+end_src
- Binding to fix a word /then/ go to the next error. Special syntax
- =[?\C-\$]= is used to protect the =$= sign
+Binding to fix a word /then/ go to the next error. Special syntax
+=[?\C-\$]= is used to protect the =$= sign
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(defun mh/cycle-spellcheck ()
(interactive)
(flyspell-goto-next-error)
(ispell-word))
(global-set-key (kbd "C-$") 'mh/cycle-spellcheck)
- #+end_src
+#+end_src
* Misc.
- Adds =/usr/local/bin= to Emacs =exec-path=
+Adds =/usr/local/bin= to Emacs =exec-path=
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq exec-path (cons "/usr/local/bin" exec-path))
- #+end_src
+#+end_src
- Starts Emacs server so that we can use =emacsclient= for opening new
- files.
+Starts Emacs server so that we can use =emacsclient= for opening new
+files.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(server-start)
- #+end_src
+#+end_src
- A handy way of starting Emacs from the shell is then to call
+A handy way of starting Emacs from the shell is then to call
- #+begin_src bash
+#+begin_src bash
emacsclient -a emacs ...
- #+end_src
+#+end_src
- This will attempt to connect to Emacs server and run Emacs if the
- server is not started yet.
+This will attempt to connect to Emacs server and run Emacs if the
+server is not started yet.
* To check later
@@ -1077,10 +1097,10 @@ emacsclient -a emacs ...
* Performances tweaks (part. 2, profiling)
- This configuration can make emacs being long to start, let's profile a bit
+This configuration can make emacs being long to start, let's profile a bit
- This will print emacs start time as well as the count of GC calls
- #+begin_src emacs-lisp
+This will print emacs start time as well as the count of GC calls
+#+begin_src emacs-lisp
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
@@ -1088,41 +1108,41 @@ emacsclient -a emacs ...
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
- #+end_src
+#+end_src
- [[https://github.com/jschaf/esup][ESup]] is an emacs profiler
+[[https://github.com/jschaf/esup][ESup]] is an emacs profiler
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(use-package esup
:ensure t
;; To use MELPA Stable use ":pin mepla-stable",
:pin melpa
:commands (esup))
- #+end_src
+#+end_src
- #+RESULTS:
+#+RESULTS:
* Performances tweaks (part. 3, the end)
- Set GC threshold to something more reasonable for standard use.
+Set GC threshold to something more reasonable for standard use.
- #+begin_src emacs-lisp
+#+begin_src emacs-lisp
(setq gc-cons-threshold (* 2 1024 1024))
- #+end_src
+#+end_src
* Acknowledgment
- I learned a great deal of how to use =org-mode= for emacs
- configuration from [[https://github.com/hrs/dotfiles/][Harry R. Schwartz]] configuration files. He also gave
- a great [[https://www.youtube.com/watch?v=SzA2YODtgK4][talk]] on emacs =org-mode=. Parts of my configuration are
- directly copied from his.
+I learned a great deal of how to use =org-mode= for emacs
+configuration from [[https://github.com/hrs/dotfiles/][Harry R. Schwartz]] configuration files. He also gave
+a great [[https://www.youtube.com/watch?v=SzA2YODtgK4][talk]] on emacs =org-mode=. Parts of my configuration are
+directly copied from his.
- [[https://www.youtube.com/watch?v=gfZDwYeBlO4][Alain M. Lafon]] also gave a great talk on how emacs can be /played
- like an instrument/.
+[[https://www.youtube.com/watch?v=gfZDwYeBlO4][Alain M. Lafon]] also gave a great talk on how emacs can be /played
+like an instrument/.
- A [[https://blog.d46.us/advanced-emacs-startup/][guide]] on how to speed up emacs starting time
+A [[https://blog.d46.us/advanced-emacs-startup/][guide]] on how to speed up emacs starting time