diff --git a/configuration.org b/configuration.org index 61cc868b633e9d1d8ddbd059b68b044c68a115a9..a3f19187870a3a43471e8cb455a1a50546ed7088 100644 --- a/configuration.org +++ b/configuration.org @@ -9,23 +9,26 @@ 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 +** Emacs 28 (GccEmacs) + 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 + #+end_src + +** Garbage collector Decrease the GC frequency by setting the threshold high for configuration loading. The threshold will be set lower at the end of @@ -37,252 +40,229 @@ to macOs (until it is released): * 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 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 -#+BEGIN_SRC emacs-lisp + #+BEGIN_SRC emacs-lisp (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") -#+END_SRC - -#+RESULTS: -: NORMAL:-VERS-TLS1.3 + #+END_SRC + Then add package repositories -#+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 - -#+RESULTS: + #+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 -We can keep things up to date, using =auto-package-update=, but it -tends to make emacs very slow to start + We can keep things up to date, using =auto-package-update=, but it + tends to make emacs very slow to start -#+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 + :config + (auto-compile-on-load-mode) + (setq load-prefer-newer t) +) + #+end_src ** 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") -#+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. 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 -(menu-bar-mode t) - #+END_SRC + #+BEGIN_SRC emacs-lisp +(use-package better-defaults + :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 -(setq ido-enable-flex-matching t) -(setq ido-everywhere t) - #+end_src + #+begin_src emacs-lisp +(fset 'yes-or-no-p 'y-or-n-p) + #+end_src +** MacOS -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 - -Allow pressing only =y= instead of =yes= for fast answer to yes or no question + #+end_src -#+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 -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 - -#+RESULTS: -: mh/indent-buffer + #+end_src -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) -#+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 + #+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 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 (setq inhibit-startup-screen t) @@ -298,54 +278,47 @@ buffer. I also have Emacs to show me matching parenthesis. Also do not show the ;; Detailed window title (setq-default frame-title-format (list "%65b %f")) (setq-default icon-title-format (list "%b")) -#+END_SRC - -#+RESULTS: -| %b | - + #+END_SRC ** 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 but do not use ligature everywhere + Select the font I will use depending on the system #+begin_src emacs-lisp -(use-package fira-code-mode - :config - ;(global-fira-code-mode) - (setq fira-code-mode-enable-hex-literal nil) - ) -(add-to-list 'default-frame-alist '(font . "Fira Code-12" )) -(set-face-attribute 'default t :font "Fira Code-12" ) +(if (eq system-type 'darwin) + ; Font on MacOS + (setq mh-font "Fira Code-20") + ; Font on Other Systems (Linux actually, I do not use emacs on windows) + (setq mh-font "DejaVu Sans Mono-12") +) +(add-to-list 'default-frame-alist '(font . mh-font )) +(set-face-attribute 'default t :font mh-font ) +(set-frame-font mh-font nil t) #+end_src -#+RESULTS: - - - ** 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) @@ -354,13 +327,13 @@ Tweak how some modeline elements are displayed (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)) @@ -369,76 +342,72 @@ and loaded. (eval-after-load "yasnippet" '(diminish 'yas-minor-mode)) (eval-after-load "which-key" '(diminish 'which-key-mode)) (diminish 'eldoc-mode) - ) -#+end_src +) + #+end_src *** TRAMP configuration for remote editing -Tramp is a mode that allows emacs to edit file remotely (over ssh) or -even as =sudo= (even combining both, effectively editing a file on a -remote machine as root while connecting to the remote machine using -ssh as an unpriviledged user) + Tramp is a mode that allows emacs to edit file remotely (over ssh) or + even as =sudo= (even combining both, effectively editing a file on a + remote machine as root while connecting to the remote machine using + ssh as an unpriviledged user) -To open a file located on a remote machine, simply open the file -=/ssh:user@host:path/to/the/file= + To open a file located on a remote machine, simply open the file + =/ssh:user@host:path/to/the/file= -To =sudo= open a local file : =/sudo::/path/to/the/file=. + To =sudo= open a local file : =/sudo::/path/to/the/file=. -Combining both : =/ssh:user@host|sudo::/path/to/the/file=. + Combining both : =/ssh:user@host|sudo::/path/to/the/file=. -There is no real configuration need for my tramp usage, however, I -would like to display on the mode line on which host I am editing (one -of the many reason is that I find myself editing the same file on -different servers on many occasions). By default, a =@= symbol is -displayed on the mode line when editing remote, but not the server -hostname. It requires mousing hover the =@= which is... impractical at -the very best. + There is no real configuration need for my tramp usage, however, I + would like to display on the mode line on which host I am editing (one + of the many reason is that I find myself editing the same file on + different servers on many occasions). By default, a =@= symbol is + displayed on the mode line when editing remote, but not the server + hostname. It requires mousing hover the =@= which is... impractical at + the very best. -For this, I use the =tramp-theme= package that does what I want. + For this, I use the =tramp-theme= package that does what I want. -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package tramp-theme :ensure t :config (load-theme 'tramp t) - ) -#+end_src - -#+RESULTS: -: t - +) + #+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 @@ -459,11 +428,11 @@ org with contributed packages added. ("c" . emacs) ("h" . emacs) ))))) -#+END_SRC + #+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) @@ -471,59 +440,59 @@ Add a shortcut to toggle display of emphasis characters (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 ** Latex export -Use =latexmk= to export to Latex + Use =latexmk= to export to Latex -#+begin_src emacs-lisp :exports code + #+begin_src emacs-lisp :exports code (setq org-latex-pdf-process (list "latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -output-directory=%o -pdf %f")) -#+end_src + #+end_src -Use =org-ref= for citation + Use =org-ref= for citation -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package org-ref) (use-package org-ref-prettify) -#+end_src + #+end_src -And use the same shortcut for =org-reftex-citation= than for =reftex-citation= + And use the same shortcut for =org-reftex-citation= than for =reftex-citation= -#+begin_src emacs-lisp + #+begin_src emacs-lisp (define-key org-mode-map (kbd "C-c [") 'org-reftex-citation) -#+end_src + #+end_src -#+RESULTS: -: org-reftex-citation + #+RESULTS: + : org-reftex-citation -Define a document class that do not use parts and start with chapters + Define a document class that do not use parts and start with chapters -#+begin_src emacs-lisp + #+begin_src emacs-lisp (add-to-list 'org-latex-classes '("book-noparts" "\\documentclass{book}" @@ -533,49 +502,49 @@ Define a document class that do not use parts and start with chapters ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) -#+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) @@ -585,20 +554,20 @@ Index and archive are my main todo lists (index) and a list of archived (done) t (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) @@ -606,44 +575,44 @@ Hitting =C-c C-x C-s= will mark a todo as done and move it to an appropriate pla (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") @@ -666,25 +635,25 @@ other things later ("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 + #+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 @@ -702,42 +671,42 @@ using bootstrap template. ;; Export using pandoc (use-package ox-pandoc) -#+end_src + #+end_src -#+RESULTS: + #+RESULTS: -Configure code highlighting using [[https://www.ctan.org/pkg/minted][minted]] (which uses -[[https://pygments.org/][Pygments]] as an external tool) for latex export + Configure code highlighting using [[https://www.ctan.org/pkg/minted][minted]] (which uses + [[https://pygments.org/][Pygments]] as an external tool) for latex export -#+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")) (setq org-latex-listings 'minted) -#+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 -Turn off validate link in org html export: + Turn off validate link in org html export: -#+begin_src emacs-lisp + #+begin_src emacs-lisp (setq org-html-validation-link nil) -#+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) @@ -758,78 +727,78 @@ its result in your org file. (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 + #+begin_src emacs-lisp (setq org-babel-python-command "python3") -#+end_src + #+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 ** Transform json results to org-table -I found a nice way to use json results in org mode by transforming a -json output to an org table. The emacs module can be found here: -https://github.com/noonker/json-to-org-table + I found a nice way to use json results in org mode by transforming a + json output to an org table. The emacs module can be found here: + https://github.com/noonker/json-to-org-table -#+begin_src emacs-lisp + #+begin_src emacs-lisp (require 'json-to-org-table nil t) -#+end_src + #+end_src * Markdown mode -I use pandoc to generate html output from markdown file. In order to -export a standalone file with the correct options, I set pandoc call here + I use pandoc to generate html output from markdown file. In order to + export a standalone file with the correct options, I set pandoc call here -#+begin_src emacs-lisp + #+begin_src emacs-lisp (setq markdown-command "pandoc --standalone --mathjax") -#+end_src + #+end_src * 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-box :ensure company-php @@ -844,90 +813,90 @@ all buffers. I also set =M-/= to trigger =company-complete= (company-show-quick-access "off") (company-quick-access-hint-function (lambda (param) " unknown")) ) -#+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 php and web -related. + Now some backends I use. Mainly php and web + related. -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package company-php) (use-package company-web) -#+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) @@ -940,86 +909,86 @@ language currently in use. (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 *** LSP through TRAMP -For rust + For rust -#+begin_src emacs-lisp + #+begin_src emacs-lisp ;; (lsp-register-client ;; (make-lsp-client :new-connection (lsp-tramp-connection "rust-analyzer") ;; :major-modes '(rust-mode) ;; :remote? t ;; :server-id 'rust-analyzer-remote)) (with-eval-after-load "tramp" (add-to-list 'tramp-remote-path "~/.cargo/bin")) -#+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 ** Language specific configuration *** C -Set indentation size and parameters -#+begin_src emacs-lisp + Set indentation size and parameters + #+begin_src emacs-lisp (setq c-default-style "linux" c-basic-offset 4) -#+end_src + #+end_src -#+RESULTS: + #+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" @@ -1030,54 +999,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-tramp) + ;(use-package docker-tramp) (use-package docker-api) (use-package docker-cli) -#+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 - - #+begin_src emacs-lisp + 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 (use-package web-mode :config (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) @@ -1092,179 +1061,179 @@ Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web edit (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 + Packages to edit terraform configuration files -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package terraform-mode) (use-package terraform-doc) (use-package company-terraform) -#+end_src + #+end_src *** Slint -[[https://slint.dev/][Slint]] is a UI framework usable in Rust. It is based on a DSL to -describe the UI element. + [[https://slint.dev/][Slint]] is a UI framework usable in Rust. It is based on a DSL to + describe the UI element. -Install and load slint mode package. + Install and load slint mode package. -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package slint-mode) -#+end_src + #+end_src -=slint-lsp= langage server can be installed using: + =slint-lsp= langage server can be installed using: -#+begin_src shell + #+begin_src shell cargo install slint-lsp -#+end_src + #+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 -+ configure magit to automatically revert buffers that are opened - if they are modified by a magit action (such as changing branch, - merging...) -+ Save buffers that visit a file that belongs to a repository if - needed + + Bind =C-x g= to pop up the magit status buffer + + configure magit to automatically revert buffers that are opened + if they are modified by a magit action (such as changing branch, + merging...) + + 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 ** Grammalecte -Using grammalecte with flycheck + Using grammalecte with flycheck -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package flycheck-grammalecte) -#+end_src + #+end_src -#+RESULTS: + #+RESULTS: * 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. -Add synthax highlighting for ssh_config files + Add synthax highlighting for ssh_config files -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package ssh-config-mode) -#+end_src + #+end_src -#+RESULTS: -: t + #+RESULTS: + : t * To check later @@ -1276,10 +1245,10 @@ Add synthax highlighting for ssh_config files * 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." @@ -1287,41 +1256,41 @@ This will print emacs start time as well as the count of GC calls (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