diff --git a/.gitignore b/.gitignore index da502ad99141f67ca906fb7074f4d556b07e37f1..e4a3374688872dc7fadd3d2b3404d99c7ad72597 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ history .env session.* projectile.cache +/eln-cache diff --git a/configuration.org b/configuration.org index c56dfea592d757afb7a4c7ca08d5dff4918eaab9..c5470040870f25d55406f7375100967d1b3815fb 100644 --- a/configuration.org +++ b/configuration.org @@ -11,382 +11,386 @@ Some of my configuration entries where borrowed from other people, see * Performances tweaks (part. 1, start) ** 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 +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 ** Garbage collector - 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 -(setq gc-cons-threshold (* 60 1024 1024)) - #+end_src +#+begin_src emacs-lisp + (setq gc-cons-threshold (* 60 1024 1024)) +#+end_src * Personal information - Sets who I am +Sets who I am - #+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 +#+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 * Packages management - 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 +I use Melpa 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 -(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") - #+END_SRC +#+BEGIN_SRC emacs-lisp + (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") +#+END_SRC - Then add package repositories +Then add package repositories - #+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 +#+BEGIN_SRC emacs-lisp + (require 'package) + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) + (unless (fboundp 'package-activate-all) (package-initialize)) +#+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 -(when (not (package-installed-p 'use-package)) - (package-refresh-contents) - (package-install 'use-package)) - #+END_SRC +#+BEGIN_SRC emacs-lisp + (when (not (package-installed-p 'use-package)) + (package-refresh-contents) + (package-install 'use-package)) +#+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 -(require 'use-package-ensure) -(setq use-package-always-ensure t) - #+END_SRC +#+BEGIN_SRC emacs-lisp + (require 'use-package-ensure) + (setq use-package-always-ensure t) +#+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 -;; (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 +#+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 - 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 -(use-package auto-compile - :config - (auto-compile-on-load-mode) - (setq load-prefer-newer t) -) - #+end_src +#+begin_src emacs-lisp + (use-package auto-compile + :config + (auto-compile-on-load-mode) + (setq load-prefer-newer t) + ) +#+end_src + +some packages I use depends on =pkg-info= +#+begin_src emacs-lisp + (use-package pkg-info) +#+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 -(add-to-list 'load-path "~/.emacs.d/plugins") - #+end_src +#+begin_src emacs-lisp + (add-to-list 'load-path "~/.emacs.d/plugins") +#+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. Moreover, Ido is not set everywhere by =better-defaults= and I really want it 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. Moreover, Ido is not set everywhere by =better-defaults= and I really want it everywhere - #+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 +#+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 - 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 -(fset 'yes-or-no-p 'y-or-n-p) - #+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 -(when (eq system-type 'darwin) - (setq mac-right-option-modifier nil)) - #+end_src +#+begin_src emacs-lisp + (when (eq system-type 'darwin) + (setq mac-right-option-modifier nil)) +#+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 -(save-place-mode t) - #+end_src +#+begin_src emacs-lisp + (save-place-mode t) +#+end_src - Syntax highlighting everywhere +Syntax highlighting everywhere - #+begin_src emacs-lisp -(global-font-lock-mode t) -(setq font-lock-maximum-decoration t) - #+end_src +#+begin_src emacs-lisp + (global-font-lock-mode t) + (setq font-lock-maximum-decoration t) +#+end_src - Use 4 spaces as tab +Use 4 spaces as tab - #+begin_src emacs-lisp -(setq tab-width 4) - #+end_src +#+begin_src emacs-lisp + (setq tab-width 4) +#+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 -(setq scroll-error-top-bottom t) - #+end_src +#+begin_src emacs-lisp + (setq scroll-error-top-bottom t) +#+end_src - Replace selection as I type +Replace selection as I type - #+begin_src emacs-lisp -(delete-selection-mode t) - #+end_src +#+begin_src emacs-lisp + (delete-selection-mode t) +#+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 -(setq kill-whole-line t) - #+end_src +#+begin_src emacs-lisp + (setq kill-whole-line t) +#+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 -(setq track-eol t) - #+end_src +#+begin_src emacs-lisp + (setq track-eol t) +#+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 -(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 +#+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 - Do not word wrap buffers, truncate long lines +Do not word wrap buffers, truncate long lines - #+begin_src emacs-lisp -;; Truncate lines (don't word wrap) -(setq truncate-lines t) - #+end_src +#+begin_src emacs-lisp + ;; Truncate lines (don't word wrap) + (setq truncate-lines t) +#+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 -;; 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 +#+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 - 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 -(defun mh/indent-buffer() - (interactive) - (save-excursion - (indent-region (point-min) (point-max)))) +#+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 + (global-set-key (kbd "C-c i b") 'mh/indent-buffer) +#+end_src - Set the line width for fill command +Set the line width for fill command - #+begin_src emacs-lisp -(setq-default fill-column 100) - #+end_src +#+begin_src emacs-lisp + (setq-default fill-column 100) +#+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 like to have Emacs 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 -;; Do not show welcome screen -(setq inhibit-startup-screen t) +#+BEGIN_SRC emacs-lisp + ;; Do not show welcome screen + (setq inhibit-startup-screen t) -;; Highlight current line -(global-hl-line-mode t) + ;; Highlight current line + (global-hl-line-mode t) -;; Show line number on the left hand side of the code -(global-display-line-numbers-mode) + ;; Show line number on the left hand side of the code + (global-display-line-numbers-mode) -;; Show matching parenthesis -(show-paren-mode t) + ;; Show matching parenthesis + (show-paren-mode t) -;; Detailed window title -(setq-default frame-title-format (list "%65b %f")) -(setq-default icon-title-format (list "%b")) - #+END_SRC + ;; Detailed window title + (setq-default frame-title-format (list "%65b %f")) + (setq-default icon-title-format (list "%b")) +#+END_SRC ** Theme - #+BEGIN_SRC emacs-lisp -(use-package color-theme-sanityinc-tomorrow - :config - (load-theme 'sanityinc-tomorrow-bright t) -) - #+END_SRC +#+BEGIN_SRC emacs-lisp + (use-package color-theme-sanityinc-tomorrow + :config + (load-theme 'sanityinc-tomorrow-bright t) + ) +#+END_SRC - Select the font I will use depending on the system +Select the font I will use depending on the system #+begin_src emacs-lisp -(if (eq system-type 'darwin) - ; Font on MacOS - (setq mh-font "Fira Code-13") - ; Font on Other Systems (Linux actually, I do not use emacs on windows) + (if (eq system-type 'darwin) + ; Font on MacOS + (setq mh-font "Fira Code-13") + ; Font on Other Systems (Linux actually, I do not use emacs on windows) (setq mh-font "DejaVu Sans Mono-12") -) -(set-face-attribute 'default t :font mh-font ) -(set-frame-font mh-font nil t) + ) + (set-face-attribute 'default t :font mh-font ) + (set-frame-font mh-font nil t) #+end_src ** Modeline - 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) + ;; Show line and column number in mode line + (column-number-mode t) + (line-number-mode t) -;; Show time in mode line -(setq display-time-24hr-format t) -(setq display-time-day-and-date t) -(display-time-mode t) - #+end_src + ;; Show time in mode line + (setq display-time-24hr-format t) + (setq display-time-day-and-date t) + (display-time-mode t) +#+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 -(use-package diminish - :config - (eval-after-load "company" '(diminish 'company-mode)) - (eval-after-load "company-box" '(diminish 'company-box-mode)) - (eval-after-load "undo-tree" '(diminish 'undo-tree-mode)) - (eval-after-load "yasnippet" '(diminish 'yas-minor-mode)) - (eval-after-load "which-key" '(diminish 'which-key-mode)) - (diminish 'eldoc-mode) -) - #+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 + (use-package diminish + :config + (eval-after-load "company" '(diminish 'company-mode)) + (eval-after-load "company-box" '(diminish 'company-box-mode)) + (eval-after-load "undo-tree" '(diminish 'undo-tree-mode)) + (eval-after-load "yasnippet" '(diminish 'yas-minor-mode)) + (eval-after-load "which-key" '(diminish 'which-key-mode)) + (diminish 'eldoc-mode) + ) +#+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 -(use-package tramp-theme - :ensure t - :config - (load-theme 'tramp t) -) - #+end_src +#+begin_src emacs-lisp + (use-package tramp-theme + :ensure t + :config + (load-theme 'tramp 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 -(use-package which-key - :config - (which-key-mode t)) - #+end_src +#+begin_src emacs-lisp + (use-package which-key + :config + (which-key-mode t)) +#+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 -(winner-mode t) - #+end_src +#+begin_src emacs-lisp + (winner-mode t) +#+end_src ** Better mini-buffer @@ -394,817 +398,733 @@ Vertico and Marginlia upgrades the minibuffer completion window by making it mor (=vertico=) and displaying a short documentation string for each item. #+begin_src emacs-lisp -(use-package vertico - :config - (vertico-mode t) - ) -(use-package marginalia - :config - (marginalia-mode t) - ) + (use-package vertico + :config + (vertico-mode t) + ) + (use-package marginalia + :config + (marginalia-mode t) + ) #+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 -(use-package org - ;; :ensure org-plus-contrib - ;; :ensure org-tempo - :custom - ;; Tab keeps indenting in src blocks - (org-src-tab-acts-natively t) - ;; IDO for completion when applicable - (org-completion-use-ido t) - ;; hide emphasis markers - ;; (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 - - Add a shortcut to toggle display of emphasis characters - - #+begin_src emacs-lisp -(defun org-toggle-emphasis () - "Toggle hiding/showing of org emphasize markers." - (interactive) - (if org-hide-emphasis-markers - (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 - - Use =org-mode= for the initial scratch buffer +#+BEGIN_SRC emacs-lisp + (use-package org + :bind (("C-c l" . 'org-store-link) + ("C-c a" . 'org-agenda) + ("C-c c" . 'org-capture) + ) + :custom + ;; Tab keeps indenting in src blocks + (org-src-tab-acts-natively t) + ;; IDO for completion when applicable + (org-completion-use-ido t) + ;; hide emphasis markers + ;; (org-hide-emphasis-markers t) + (org-file-apps '(("org" . emacs) + ("rs" . emacs) + ("c" . emacs) + ("h" . emacs) + )) + ;; Define the right latexmk command to export to latex + (org-latex-pdf-process (list "latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -output-directory=%o -pdf %f")) + + ;; Task management configuration + (org-log-done 'time) + (org-enforce-todo-dependencies t) + (org-enforce-todo-checkbox-dependencies t) + (org-todo-keywords '((sequence "TODO" "WAITING" "|" "DONE"))) + + ;; where org mode can find its files for archiving and capture + (org-directory "~/documents/org") + (org-archive-location "~/documents/org/archive.org::* From %s") + (org-agenda-files (list "~/documents/org/index.org" + "~/.emacs.d/configuration.org" + "~/documents/org/work.org" + "~/documents/org/archive.org")) + + ;; Agenda + ;; The week begin today + (org-agenda-start-on-weekday nil) + ;; 15 days in agenda view + (org-agenda-span 15) + ;; + ;; 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. + + (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)))) + )))) + + ;; Define some capture template to be able to create tasks, or maybe + ;; other things later + + (org-capture-templates + '(("f" "Finished book" + table-line (file "~/Documents/org/books-read.org") + "| %^{Title} | %^{Author} | %u |") + + ("t" "Todo" + entry + (file+headline org-index-file "Tâches") + "* TODO %?\n:PROPERTIES:\nCREATED: %u\n:END:\n") + + ("b" "Bookmarks" + table-line (file "~/Documents/org/bookmarks.org") + "| %^{prompt|rust|other} | %^{url} | %^{what}") + + + ("c" "Cycling" + table-line (file "~/Documents/org/cycling.org") + "| %t | balade | %^{prompt|standard|électrique} | %^{Distance} |") + + ("w" "Cycling to work" + table-line (file "~/Documents/org/cycling.org") + "| %t | boulot | %^{prompt|électrique|standard} | 26.2 |"))) + :config + (add-to-list 'org-structure-template-alist + '("el" . "src emacs-lisp")) + (set-face-foreground 'org-verbatim "orange1") + ;; Define a document class that do not use parts and start with chapters for latex export + ) +#+END_SRC + +Add a shortcut to toggle display of emphasis characters - #+begin_src emacs-lisp -(setq initial-major-mode 'org-mode) - #+end_src - - And set some keyboard shortcuts for links and agenda - - #+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 - - Add shortcuts to quickly add code blocks using =C-,= - - #+begin_src emacs-lisp -(add-to-list 'org-structure-template-alist - '("el" . "src emacs-lisp")) - #+end_src - -** Latex export - - Use =latexmk= to export to Latex - - #+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 - - - - Use =org-ref= for citation - - #+begin_src emacs-lisp -(use-package org-ref) -(use-package org-ref-prettify) - #+end_src - - - And use the same shortcut for =org-reftex-citation= than for =reftex-citation= - - #+begin_src emacs-lisp -(define-key org-mode-map (kbd "C-c [") 'org-reftex-citation) - #+end_src - - Define a document class that do not use parts and start with chapters - - #+begin_src emacs-lisp -(add-to-list 'org-latex-classes - '("book-noparts" - "\\documentclass{book}" - ("\\chapter{%s}" . "\\chapter*{%s}") - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) - #+end_src - - -** Visuals - - Use bullets instead of asterisks - - #+begin_src emacs-lisp -(use-package org-bullets - :init - (add-hook 'org-mode-hook 'org-bullets-mode)) - #+end_src - - #+begin_src emacs-lisp -(set-face-foreground 'org-verbatim "orange1") - #+end_src +#+begin_src emacs-lisp + (defun org-toggle-emphasis () + "Toggle hiding/showing of org emphasize markers." + (interactive) + (if org-hide-emphasis-markers + (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 -** Task management +Use =org-mode= for the initial scratch buffer - 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 + (setq initial-major-mode 'org-mode) +#+end_src - #+begin_src emacs-lisp -(setq org-log-done 'time) -(setq org-enforce-todo-dependencies t) -(setq org-enforce-todo-checkbox-dependencies t) - #+end_src +Use =org-ref= for citation - 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 + (use-package org-ref + :bind ("C-c [" . 'org-reftex-citation) + ) + (use-package org-ref-prettify) +#+end_src - #+begin_src emacs-lisp -(setq org-todo-keywords - '((sequence "TODO" "WAITING" "|" "DONE"))) - #+end_src +Use bullets instead of asterisks +#+begin_src emacs-lisp + (use-package org-bullets + :hook org-mode + ) +#+end_src -*** index and archive files - - Index and archive are my main todo lists (index) and a list of archived (done) tasks. - - #+begin_src emacs-lisp -(setq org-directory "~/documents/org") - -(defun org-file-path (filename) - "Return the absolute address of an org file, given its relative name." - (concat (file-name-as-directory org-directory) filename)) - -(setq org-index-file (org-file-path "index.org")) -(setq org-archive-location - (concat (org-file-path "archive.org") "::* From %s")) - #+end_src - - Then more specifics org files to add to the agenda list - - #+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 - - 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 -(defun hrs/mark-done-and-archive () - "Mark the state of an org-mode item as DONE and archive it." - (interactive) - (org-todo 'done) - (org-archive-subtree)) - -(define-key org-mode-map (kbd "C-c C-x C-s") 'hrs/mark-done-and-archive) - #+end_src - - -** Agenda - - The week should begin today, not last Monday for the agenda view - - #+begin_src emacs-lisp -(setq org-agenda-start-on-weekday nil) - #+end_src - - I want to see more days in the agenda view - - #+begin_src emacs-lisp -(setq org-agenda-span 15) - #+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. - - #+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 - -** Capture - - Define some capture template to be able to create tasks, or maybe - other things later - - #+begin_src emacs-lisp -(setq org-capture-templates - '(("f" "Finished book" - table-line (file "~/Documents/org/books-read.org") - "| %^{Title} | %^{Author} | %u |") - - ("t" "Todo" - entry - (file+headline org-index-file "Tâches") - "* TODO %?\n:PROPERTIES:\nCREATED: %u\n:END:\n") - - ("b" "Bookmarks" - table-line (file "~/Documents/org/bookmarks.org") - "| %^{prompt|rust|other} | %^{url} | %^{what}") - - - ("c" "Cycling" - table-line (file "~/Documents/org/cycling.org") - "| %t | balade | %^{prompt|standard|électrique} | %^{Distance} |") - - ("w" "Cycling to work" - table-line (file "~/Documents/org/cycling.org") - "| %t | boulot | %^{prompt|électrique|standard} | 26.2 |"))) - #+end_src - - + ** Tree slide Tree slide displays an org file as /slides/ - #+begin_src emacs-lisp -(use-package org-tree-slide - :config - (define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode) - ) - #+end_src +#+begin_src emacs-lisp + (use-package org-tree-slide + :bind (:map org-mode-map + ("<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 -;; Add Beamer to export list -(require 'ox-beamer) -;; And markdown -(require 'ox-md) - -;; some HTML slide export engines -;; Don't really use them actually so commented out -;; (use-package ox-html5slide) -;; (use-package ox-impress-js) -;; (use-package ox-reveal) -;; (use-package ox-spectacle ) - -;; bootstrap html -(use-package ox-twbs) - -;; Export using pandoc -(use-package ox-pandoc) - #+end_src +#+begin_src emacs-lisp + ;; Add Beamer to export list + (use-package ox-beamer + :ensure nil + ) + ;; And markdown + (use-package ox-md + :ensure nil + ) + + ;; some HTML slide export engines + ;; Don't really use them actually so commented out + ;; (use-package ox-html5slide) + ;; (use-package ox-impress-js) + ;; (use-package ox-reveal) + ;; (use-package ox-spectacle ) + + ;; bootstrap html + (use-package ox-twbs) + + ;; Export using pandoc + (use-package ox-pandoc) +#+end_src - 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 -;; 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 +#+begin_src emacs-lisp - For HTML source code highlight, use =htmlize= + (use-package ox-latex + :ensure nil + :custom + (org-latex-listings 'minted) + :config + (add-to-list 'org-latex-classes + '("book-noparts" + "\\documentclass{book}" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + (add-to-list 'org-latex-packages-alist '("cache=false" "minted")) + ) +#+end_src - #+begin_src emacs-lisp -(use-package htmlize) - #+end_src +For HTML source code highlight, use =htmlize= +#+begin_src emacs-lisp + (use-package htmlize) +#+end_src - Turn off validate link in org html export: - #+begin_src emacs-lisp -(setq org-html-validation-link nil) - #+end_src +Turn off validate link in org html export: + +#+begin_src emacs-lisp +(use-package ox-html + :ensure nil + :custom + (org-html-validation-link nil) + ) +#+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 -(use-package gnuplot) -(use-package gnuplot-mode) -(use-package ob-rust) - -(org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (C . t) - (latex . t) - (gnuplot . t) - (dot . t) - (java . t) - (python . t) - (makefile . t) - (org . t) - (perl . t) - (sed . t) - (shell . t) - (rust . t) - )) - #+END_SRC - - - 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 +#+begin_src emacs-lisp + (use-package gnuplot) + (use-package gnuplot-mode) + (use-package ob-rust) + + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (C . t) + (latex . t) + (gnuplot . t) + (dot . t) + (java . t) + (python . t) + (makefile . t) + (org . t) + (perl . t) + (sed . t) + (shell . t) + (rust . t) + )) +#+END_SRC + + +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 - Don't ask before evaluating +Don't ask before evaluating - #+begin_src emacs-lisp -(setq org-confirm-babel-evaluate nil) - #+end_src +#+begin_src emacs-lisp + (setq org-confirm-babel-evaluate nil) +#+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 -(use-package graphviz-dot-mode) -(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) - #+end_src +#+begin_src emacs-lisp + (use-package graphviz-dot-mode) + (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) +#+end_src - Make org mode correctly export quotes +Make org mode correctly export quotes - #+begin_src emacs-lisp -(setq org-export-with-smart-quotes t) - #+end_src +#+begin_src emacs-lisp + (setq org-export-with-smart-quotes t) +#+end_src - Use =python3= +Use =python3= - #+begin_src emacs-lisp -(setq org-babel-python-command "python3") - #+end_src +#+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 -(setq org-babel-min-lines-for-block-output 10) - #+end_src +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 ** 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 -(require 'json-to-org-table nil t) - #+end_src +#+begin_src emacs-lisp + (require 'json-to-org-table nil t) +#+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 -(setq markdown-command "pandoc --standalone --mathjax") - #+end_src +#+begin_src emacs-lisp + (setq markdown-command "pandoc --standalone --mathjax") +#+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 -(use-package company - :ensure company-box - :ensure company-php - :ensure company-web - :init - (global-company-mode t) - (global-set-key (kbd "M-/") 'company-complete) - ;; Complete quite soon - :custom - (company-minimum-prefix-length 3) - (company-idle-delay 0.1) - (company-show-quick-access "off") - (company-quick-access-hint-function (lambda (param) " unknown")) - ) - #+end_src +#+begin_src emacs-lisp + (use-package company + :ensure company-box + :ensure company-php + :ensure company-web + :init + (global-company-mode t) + (global-set-key (kbd "M-/") 'company-complete) + ;; Complete quite soon + :custom + (company-minimum-prefix-length 3) + (company-idle-delay 0.1) + (company-show-quick-access "off") + (company-quick-access-hint-function (lambda (param) " unknown")) + ) +#+end_src - 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 -(use-package company-box - :ensure frame-local - :hook (company-mode . company-box-mode)) - #+end_src +#+begin_src emacs-lisp + (use-package company-box + :ensure frame-local + :hook (company-mode . company-box-mode)) +#+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 -(use-package company-php) -(use-package company-web) - #+end_src +#+begin_src emacs-lisp + (use-package company-php) + (use-package company-web) +#+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 -(use-package treemacs - :custom - (treemacs--icon-size 16) - :bind ("C-c t" . treemacs-select-window) - ) - #+end_src +#+begin_src emacs-lisp + (use-package treemacs + :custom + (treemacs--icon-size 16) + :bind ("C-c t" . treemacs-select-window) + ) +#+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 -(use-package projectile - :config - (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) - (projectile-mode t)) - #+end_src +#+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 - As I use =treemacs=, adds =treemacs-projectile= plugin +As I use =treemacs=, adds =treemacs-projectile= plugin - #+begin_src emacs-lisp -(use-package treemacs-projectile) - #+end_src +#+begin_src emacs-lisp + (use-package treemacs-projectile) +#+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 -(use-package yasnippet - :init - (yas-global-mode)) -(use-package yasnippet-snippets) - #+end_src +#+begin_src emacs-lisp + (use-package yasnippet + :init + (yas-global-mode)) + (use-package yasnippet-snippets) +#+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 -(use-package lsp-mode - :hook ( - (c++-mode . lsp) - (python-mode . lsp) - (rust-mode . lsp) - (slint-mode . lsp) - (lsp-mode . lsp-enable-which-key-integration) - ) - :config - (lsp-headerline-breadcrumb-mode t) - :commands lsp - ) - #+end_src +#+begin_src emacs-lisp + (use-package lsp-mode + :hook ( + (c++-mode . lsp) + (python-mode . lsp) + (rust-mode . lsp) + (slint-mode . lsp) + (lsp-mode . lsp-enable-which-key-integration) + ) + :config + (lsp-headerline-breadcrumb-mode t) + :commands lsp + ) +#+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 -(use-package lsp-ui - :commands lsp-ui-mode) - #+end_src +#+begin_src emacs-lisp + (use-package lsp-ui + :commands lsp-ui-mode) +#+end_src - LSP keybinds +LSP keybinds - #+begin_src emacs-lisp -(setq lsp-keymap-prefix "s-l") - #+end_src +#+begin_src emacs-lisp + (setq lsp-keymap-prefix "s-l") +#+end_src *** LSP through TRAMP - For rust +For rust - #+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 +#+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 *** 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 -(use-package lsp-treemacs - :custom - (lsp-treemacs-sync-mode 1)) - #+end_src +#+begin_src emacs-lisp + (use-package lsp-treemacs + :custom + (lsp-treemacs-sync-mode 1)) +#+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 -(use-package flycheck) - #+end_src +#+begin_src emacs-lisp + (use-package flycheck) +#+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 +Set indentation size and parameters +#+begin_src emacs-lisp + (setq c-default-style "linux" + c-basic-offset 4) +#+end_src *** 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 -(use-package rust-mode - :custom - (lsp-rust-server 'rust-analyzer) -) - #+end_src +#+begin_src emacs-lisp + (use-package rust-mode + :custom + (lsp-rust-server 'rust-analyzer) + ) +#+end_src - For this to work, you need to install =rust-analyzer= and =rustmft=. This can be done using - =rustup=. +For this to work, you need to install =rust-analyzer= and =rustmft=. This can be done using +=rustup=. - Adds cargo installed binaries to exec path +Adds cargo installed binaries to exec path - #+begin_src emacs-lisp -(setq exec-path (cons "~/.cargo/bin" exec-path)) - #+end_src +#+begin_src emacs-lisp + (setq exec-path (cons "~/.cargo/bin" exec-path)) +#+end_src *** Lua - Simply add =lua-mode= +Simply add =lua-mode= - #+begin_src emacs-lisp -(use-package lua-mode) - #+end_src +#+begin_src emacs-lisp + (use-package lua-mode) +#+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 -(use-package dockerfile-mode) -(use-package docker-compose-mode) -(use-package docker) - ;(use-package docker-tramp) -(use-package docker-api) -(use-package docker-cli) - #+end_src +#+begin_src emacs-lisp + (use-package dockerfile-mode) + (use-package docker-compose-mode) + (use-package docker) + ;(use-package docker-tramp) + (use-package docker-api) + (use-package docker-cli) +#+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 -(use-package web-mode - :config - (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) - ) -(use-package rainbow-mode) -(use-package simple-httpd) -(use-package impatient-mode) - #+end_src +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)) + (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) + ) + (use-package rainbow-mode) + (use-package simple-httpd) + (use-package impatient-mode) + #+end_src *** LaTeX - Enable =reftex= whenever =tex-mode= is activated +Enable =reftex= whenever =tex-mode= is activated - #+begin_src emacs-lisp -(add-hook 'latex-mode-hook 'reftex-mode) - #+end_src +#+begin_src emacs-lisp + (add-hook 'latex-mode-hook 'reftex-mode) +#+end_src - Use =auctex= for better experience editing latex files +Use =auctex= for better experience editing latex files - #+begin_src emacs-lisp -(use-package auctex - :ensure auctex-latexmk - :defer t - ) - #+end_src +#+begin_src emacs-lisp + (use-package auctex + :ensure auctex-latexmk + :defer t + ) +#+end_src - If using macos, add mactex to =exec-path= +If using macos, add mactex to =exec-path= - #+begin_src emacs-lisp -(when (eq system-type 'darwin) - (setq exec-path (cons "/Library/TeX/texbin" exec-path))) - #+end_src +#+begin_src emacs-lisp + (when (eq system-type 'darwin) + (setq exec-path (cons "/Library/TeX/texbin" exec-path))) +#+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 -(use-package nginx-mode) - #+end_src +#+begin_src emacs-lisp + (use-package nginx-mode) +#+end_src *** Terraform - Packages to edit terraform configuration files +Packages to edit terraform configuration files - #+begin_src emacs-lisp -(use-package terraform-mode) -(use-package terraform-doc) -(use-package company-terraform) - #+end_src +#+begin_src emacs-lisp + (use-package terraform-mode) + (use-package terraform-doc) + (use-package company-terraform) +#+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 -(use-package slint-mode) - #+end_src +#+begin_src emacs-lisp + (use-package slint-mode) +#+end_src - =slint-lsp= langage server can be installed using: +=slint-lsp= langage server can be installed using: - #+begin_src shell -cargo install slint-lsp - #+end_src +#+begin_src shell + cargo install slint-lsp +#+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 -(use-package magit - :config - (magit-auto-revert-mode t) - (magit-save-repository-buffers t) - :bind ("C-x g" . magit-status) - ) - #+end_src + #+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 *** Protocol buffers - #+begin_src emacs-lisp -(use-package protobuf-mode) - #+end_src +#+begin_src emacs-lisp + (use-package protobuf-mode) +#+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 -(setq ispell-program-name "aspell") - #+end_src +#+begin_src emacs-lisp + (setq ispell-program-name "aspell") +#+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 -(defun mh/spellcheck () - (interactive) - (flyspell-mode t) - (flyspell-buffer) - ) - #+end_src +#+begin_src emacs-lisp + (defun mh/spellcheck () + (interactive) + (flyspell-mode t) + (flyspell-buffer) + ) +#+end_src - And define a global binding to call it +And define a global binding to call it - #+begin_src emacs-lisp -(global-set-key (kbd "C-c s") 'mh/spellcheck) - #+end_src +#+begin_src emacs-lisp + (global-set-key (kbd "C-c s") 'mh/spellcheck) +#+end_src - Binding to fix a word /then/ go to the next error. +Binding to fix a word /then/ go to the next error. - #+begin_src emacs-lisp -(defun mh/cycle-spellcheck () - (interactive) - (flyspell-goto-next-error) - (ispell-word)) +#+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 + (global-set-key (kbd "C-$") 'mh/cycle-spellcheck) +#+end_src ** Grammalecte - Using grammalecte with flycheck +Using grammalecte with flycheck - #+begin_src emacs-lisp -(use-package flycheck-grammalecte) - #+end_src +#+begin_src emacs-lisp + (use-package flycheck-grammalecte) +#+end_src * Misc. - Adds =/usr/local/bin= to Emacs =exec-path= +Adds =/usr/local/bin= to Emacs =exec-path= - #+begin_src emacs-lisp -(setq exec-path (cons "/usr/local/bin" exec-path)) - #+end_src +#+begin_src emacs-lisp + (setq exec-path (cons "/usr/local/bin" exec-path)) +#+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 -(server-start) - #+end_src +#+begin_src emacs-lisp + (server-start) +#+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 -emacsclient -a emacs ... - #+end_src +#+begin_src bash + emacsclient -a emacs ... +#+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 -(use-package ssh-config-mode) - #+end_src +#+begin_src emacs-lisp + (use-package ssh-config-mode) +#+end_src * To check later @@ -1215,52 +1135,52 @@ 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 -(add-hook 'emacs-startup-hook - (lambda () - (message "Emacs ready in %s with %d garbage collections." - (format "%.2f seconds" - (float-time - (time-subtract after-init-time before-init-time))) - gcs-done))) - #+end_src +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." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) +#+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 -(use-package esup - :ensure t - ;; To use MELPA Stable use ":pin mepla-stable", - :pin melpa - :commands (esup)) - #+end_src +#+begin_src emacs-lisp + (use-package esup + :ensure t + ;; To use MELPA Stable use ":pin mepla-stable", + :pin melpa + :commands (esup)) +#+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 -(setq gc-cons-threshold (* 2 1024 1024)) - #+end_src +#+begin_src emacs-lisp + (setq gc-cons-threshold (* 2 1024 1024)) +#+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