Skip to content
Snippets Groups Projects
Commit bb130bf8 authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Start cleaning a bit

parent c0d36d8c
No related branches found
No related tags found
No related merge requests found
...@@ -9,23 +9,26 @@ Some of my configuration entries where borrowed from other people, see ...@@ -9,23 +9,26 @@ Some of my configuration entries where borrowed from other people, see
* Performances tweaks (part. 1, start) * Performances tweaks (part. 1, start)
I am currently experimenting with Emacs 28 and, specifically, ** Emacs 28 (GccEmacs)
GccEmacs that compiles elisp to native binaries. To compile emacs28 I am currently experimenting with Emacs 28 and, specifically,
to macOs (until it is released): 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 1. Clone [[https://github.com/jimeh/build-emacs-for-macos][build-emacs-for-macos]]
3. run =./build-emacs-for-macos feature/native-comp= 2. Install build dependencies with =brew bundle install= in the cloned folder
4. The =Emacs.app= will be available in an archive in the =builds= 3. run =./build-emacs-for-macos feature/native-comp=
folder 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). This sets gcc optimization flag to =-O2= (max optimization level,
#+begin_src emacs-lisp fully adherent to the langage semantic).
#+begin_src emacs-lisp
(unless (version< emacs-version "28") (unless (version< emacs-version "28")
(setq comp-speed 2) (setq comp-speed 2)
) )
#+end_src #+end_src
** Garbage collector
Decrease the GC frequency by setting the threshold high for Decrease the GC frequency by setting the threshold high for
configuration loading. The threshold will be set lower at the end of configuration loading. The threshold will be set lower at the end of
...@@ -37,252 +40,229 @@ to macOs (until it is released): ...@@ -37,252 +40,229 @@ to macOs (until it is released):
* Personal information * 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" (setq user-full-name "Michaël Hauspie"
user-mail-address "michael.hauspie@univ-lille.fr" user-mail-address "michael.hauspie@univ-lille.fr"
calendar-latitude 50.60483 calendar-latitude 50.60483
calendar-longitude 3.1464 calendar-longitude 3.1464
calendar-location-name "Villeneuve d'Ascq, France") calendar-location-name "Villeneuve d'Ascq, France")
#+end_src #+end_src
* Packages management * 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") (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
#+END_SRC #+END_SRC
#+RESULTS:
: NORMAL:-VERS-TLS1.3
Then add package repositories
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(require 'package) (require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t) (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 '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize) (package-initialize)
#+END_SRC #+END_SRC
#+RESULTS:
Then, to ensure that packages are installed and that I can launch Then, to ensure that packages are installed and that I can launch
Emacs on a new computer and have it setup automatically, I use Emacs on a new computer and have it setup automatically, I use
=use-package=. =use-package=.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(when (not (package-installed-p 'use-package)) (when (not (package-installed-p 'use-package))
(package-refresh-contents) (package-refresh-contents)
(package-install 'use-package)) (package-install 'use-package))
#+END_SRC #+END_SRC
If I use a package, I want to ensure that it is installed, so set If I use a package, I want to ensure that it is installed, so set
ensure package by default ensure package by default
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(require 'use-package-ensure) (require 'use-package-ensure)
(setq use-package-always-ensure t) (setq use-package-always-ensure t)
#+END_SRC #+END_SRC
We can keep things up to date, using =auto-package-update=, but it We can keep things up to date, using =auto-package-update=, but it
tends to make emacs very slow to start tends to make emacs very slow to start
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; (use-package auto-package-update ;; (use-package auto-package-update
;; :config ;; :config
;; (setq auto-package-update-delete-old-versions t) ;; (setq auto-package-update-delete-old-versions t)
;; (setq auto-package-update-hide-results t) ;; (setq auto-package-update-hide-results t)
;; (auto-package-update-maybe)) ;; (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 (use-package auto-compile
:config (auto-compile-on-load-mode)) :config
(auto-compile-on-load-mode)
(setq load-prefer-newer t) (setq load-prefer-newer t)
#+end_src )
#+end_src
** Non package modules ** Non package modules
Add a folder for .el files that are not available as packages Add a folder for .el files that are not available as packages
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/plugins") (add-to-list 'load-path "~/.emacs.d/plugins")
#+end_src #+end_src
* Global editing configuration * Global editing configuration
** Default behavior ** Default behavior
I use [[https://github.com/technomancy/better-defaults][better-defaults]] to tweak some annoying Emacs default behaviors. The two most important beeing: I use [[https://github.com/technomancy/better-defaults][better-defaults]] to tweak some annoying Emacs default behaviors. The two most important beeing:
- use =ido= almost everywhere - use =ido= almost everywhere,
- put temporary files in a specific folder rather as =~= files everywhere - put temporary files in a specific folder rather as =~= files everywhere.
there is more to =better-defaults=, be sure to have a look at its list There is more to =better-defaults=, be sure to have a look at its list of changed behaviors. In
of changed behaviors. In particular, it switches the menu bar off and particular, it switches the menu bar off and I quite like have it around sometimes, so I re-enable
I quite like have it around sometimes, so I re-enable it. it. Moreover, Ido is not set everywhere by =better-defaults= and I really want it everywhere
#+BEGIN_SRC emacs-lisp
(use-package better-defaults)
;; I want menu bar #+BEGIN_SRC emacs-lisp
(menu-bar-mode t) (use-package better-defaults
#+END_SRC :config
(menu-bar-mode t)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
)
#+END_SRC
Ido is not set everywhere by =better-defaults= and I really want it everywhere Allow pressing only =y= instead of =yes= for fast answer to yes or no question
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq ido-enable-flex-matching t) (fset 'yes-or-no-p 'y-or-n-p)
(setq ido-everywhere t) #+end_src
#+end_src
** MacOS
As I often use Emacs on MacOS, I need the right option (alt) key to As I often use Emacs on MacOS, I need the right option (alt) key to behave *as* an option key and
behave *as* an option key and not an Emacs =meta= key. not an Emacs =meta= key.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(when (eq system-type 'darwin) (when (eq system-type 'darwin)
(setq mac-right-option-modifier nil)) (setq mac-right-option-modifier nil))
#+end_src #+end_src
Allow pressing only =y= instead of =yes= for fast answer to yes or no question
#+begin_src emacs-lisp
;; Make the y or n suffice for a yes or no question
(fset 'yes-or-no-p 'y-or-n-p)
#+end_src
** Editor tweaks ** Editor tweaks
Save the place in the file when killing the buffer so that it reopens at the same spot later Save the place in the file when killing the buffer so that it reopens at the same spot later
#+begin_src emacs-lisp #+begin_src emacs-lisp
(save-place-mode t) (save-place-mode t)
#+end_src #+end_src
Syntax highlighting everywhere Syntax highlighting everywhere
#+begin_src emacs-lisp #+begin_src emacs-lisp
(global-font-lock-mode t) (global-font-lock-mode t)
(setq font-lock-maximum-decoration t) (setq font-lock-maximum-decoration t)
#+end_src #+end_src
Use 4 spaces as tab Use 4 spaces as tab
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq tab-width 4) (setq tab-width 4)
#+end_src #+end_src
Allow cursor to top/bottom of file before signaling a scrolling error Allow cursor to top/bottom of file before signaling a scrolling error
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq scroll-error-top-bottom t) (setq scroll-error-top-bottom t)
#+end_src #+end_src
Replace selection as I type Replace selection as I type
#+begin_src emacs-lisp #+begin_src emacs-lisp
(delete-selection-mode t) (delete-selection-mode t)
#+end_src #+end_src
When using =C-k=, kill the whole line (including =\n=) When using =C-k=, kill the whole line (including =\n=)
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq kill-whole-line t) (setq kill-whole-line t)
#+end_src #+end_src
When moving the cursor up or down, remember when it was on a line end When moving the cursor up or down, remember when it was on a line end and keep it that way even
and keep it that way even if next line is longer or shorter if next line is longer or shorter
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq track-eol t) (setq track-eol t)
#+end_src #+end_src
Automatically revert buffers if they change on disk. This prevent Automatically revert buffers if they change on disk. This prevent keeping an outdated buffer open
keeping an outdated buffer open and makes changes that will overwrite and makes changes that will overwrite the newer file on disk. If the buffer was edited since the
the newer file on disk. If the buffer was edited since the last last save/revert, Emacs asks what to do.
save/revert, Emacs asks what to do.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(global-auto-revert-mode t) (global-auto-revert-mode t)
;; kept for future use, I think I do not want that ;; kept for future use, I think I do not want that
;; (setq global-auto-revert-non-file-buffers nil) ;; (setq global-auto-revert-non-file-buffers nil)
#+end_src #+end_src
Do not word wrap buffers, truncate long lines Do not word wrap buffers, truncate long lines
#+begin_src emacs-lisp
#+begin_src emacs-lisp
;; Truncate lines (don't word wrap) ;; Truncate lines (don't word wrap)
(setq truncate-lines t) (setq truncate-lines t)
#+end_src #+end_src
If a timestamp tag is present in the file, update it when saving If a timestamp tag is present in the file, update it when saving
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; Time stamping ;; Time stamping
(setq time-stamp-active t ; do enable time-stamps (setq time-stamp-active t ; do enable time-stamps
time-stamp-line-limit 70 ; check first 70 buffer lines for Time-stamp: time-stamp-line-limit 70 ; check first 70 buffer lines for Time-stamp:
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S (%u)") ; date format time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
(add-hook 'write-file-hooks 'time-stamp) (add-hook 'write-file-hooks 'time-stamp)
#+end_src #+end_src
Define a shortcut to re-indent all buffer. This saves the current point, marks whole buffer and call =indent-region= Define a shortcut to re-indent all buffer. This saves the current point, marks whole buffer and call =indent-region=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun mh/indent-buffer() (defun mh/indent-buffer()
(interactive) (interactive)
(save-excursion (save-excursion
(indent-region (point-min) (point-max)))) (indent-region (point-min) (point-max))))
(global-set-key (kbd "C-c i b") 'mh/indent-buffer) (global-set-key (kbd "C-c i b") 'mh/indent-buffer)
#+end_src #+end_src
#+RESULTS:
: mh/indent-buffer
Set the line width for fill command Set the line width for fill command
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq-default fill-column 100) (setq-default fill-column 100)
#+end_src #+end_src
** Undo on steroids
Manage undo as a tree so that we can undo/redo more. Bound by default on =C-x u=
**Deactivated yet**
#+begin_src emacs-lisp
;;(use-package undo-tree
;; :config
;; (global-undo-tree-mode))
#+end_src
* UI and visual tweaks * UI and visual tweaks
** Changes to builtin visuals ** Changes to builtin visuals
I always display visual line where the cursor is and I like to have line numbers at the left of the I always display visual line where the cursor is and I like to have line numbers at the left of the
buffer. I also have Emacs to show me matching parenthesis. Also do not show the welcome screen. buffer. I also like to have Emacs show me matching parenthesis. Also do not show the welcome screen.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; Do not show welcome screen ;; Do not show welcome screen
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
...@@ -298,54 +278,47 @@ buffer. I also have Emacs to show me matching parenthesis. Also do not show the ...@@ -298,54 +278,47 @@ buffer. I also have Emacs to show me matching parenthesis. Also do not show the
;; Detailed window title ;; Detailed window title
(setq-default frame-title-format (list "%65b %f")) (setq-default frame-title-format (list "%65b %f"))
(setq-default icon-title-format (list "%b")) (setq-default icon-title-format (list "%b"))
#+END_SRC #+END_SRC
#+RESULTS:
| %b |
** Theme ** Theme
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package color-theme-sanityinc-tomorrow (use-package color-theme-sanityinc-tomorrow
:config :config
(load-theme 'sanityinc-tomorrow-bright t) (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 #+begin_src emacs-lisp
(use-package fira-code-mode (if (eq system-type 'darwin)
:config ; Font on MacOS
;(global-fira-code-mode) (setq mh-font "Fira Code-20")
(setq fira-code-mode-enable-hex-literal nil) ; 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 . "Fira Code-12" )) )
(set-face-attribute 'default t :font "Fira Code-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 #+end_src
#+RESULTS:
** Modeline ** 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 ;; (use-package moody
;; :config ;; :config
;; (setq x-underline-at-descent-line t ;; (setq x-underline-at-descent-line t
;; moody-mode-line-height 10) ;; moody-mode-line-height 10)
;; (moody-replace-mode-line-buffer-identification) ;; (moody-replace-mode-line-buffer-identification)
;; (moody-replace-vc-mode)) ;; (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 ;; Show line and column number in mode line
(column-number-mode t) (column-number-mode t)
(line-number-mode t) (line-number-mode t)
...@@ -354,13 +327,13 @@ Tweak how some modeline elements are displayed ...@@ -354,13 +327,13 @@ Tweak how some modeline elements are displayed
(setq display-time-24hr-format t) (setq display-time-24hr-format t)
(setq display-time-day-and-date t) (setq display-time-day-and-date t)
(display-time-mode t) (display-time-mode t)
#+end_src #+end_src
To not display all minor modes. =eval-after-load= is there to To not display all minor modes. =eval-after-load= is there to
ensure that diminish is called only for modules that are installed ensure that diminish is called only for modules that are installed
and loaded. and loaded.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package diminish (use-package diminish
:config :config
(eval-after-load "company" '(diminish 'company-mode)) (eval-after-load "company" '(diminish 'company-mode))
...@@ -369,76 +342,72 @@ and loaded. ...@@ -369,76 +342,72 @@ and loaded.
(eval-after-load "yasnippet" '(diminish 'yas-minor-mode)) (eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
(eval-after-load "which-key" '(diminish 'which-key-mode)) (eval-after-load "which-key" '(diminish 'which-key-mode))
(diminish 'eldoc-mode) (diminish 'eldoc-mode)
) )
#+end_src #+end_src
*** TRAMP configuration for remote editing *** TRAMP configuration for remote editing
Tramp is a mode that allows emacs to edit file remotely (over ssh) or 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 even as =sudo= (even combining both, effectively editing a file on a
remote machine as root while connecting to the remote machine using remote machine as root while connecting to the remote machine using
ssh as an unpriviledged user) ssh as an unpriviledged user)
To open a file located on a remote machine, simply open the file To open a file located on a remote machine, simply open the file
=/ssh:user@host:path/to/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 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 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 of the many reason is that I find myself editing the same file on
different servers on many occasions). By default, a =@= symbol is different servers on many occasions). By default, a =@= symbol is
displayed on the mode line when editing remote, but not the server displayed on the mode line when editing remote, but not the server
hostname. It requires mousing hover the =@= which is... impractical at hostname. It requires mousing hover the =@= which is... impractical at
the very best. 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 (use-package tramp-theme
:ensure t :ensure t
:config :config
(load-theme 'tramp t) (load-theme 'tramp t)
) )
#+end_src #+end_src
#+RESULTS:
: t
** Shortcut dynamic help buffer ** Shortcut dynamic help buffer
When a key binding sequence is started and not finished, display When a key binding sequence is started and not finished, display
possible next keys in the mini-buffer possible next keys in the mini-buffer
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package which-key (use-package which-key
:config :config
(which-key-mode t)) (which-key-mode t))
#+end_src #+end_src
** Winner mode for undo/redo buffer configuration ** Winner mode for undo/redo buffer configuration
Enable winner mode globally. Then with =C-c left= and =C-c right= Enable winner mode globally. Then with =C-c left= and =C-c right=
we can redo/undo the buffer configuration we can redo/undo the buffer configuration
#+begin_src emacs-lisp #+begin_src emacs-lisp
(winner-mode t) (winner-mode t)
#+end_src #+end_src
* Org mode * Org mode
This is one of the most important mode I use in Emacs. I use it to 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 organize tasks, take meetings notes, write articles, lectures... I use
org with contributed packages added. org with contributed packages added.
** Basics ** Basics
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org (use-package org
;; :ensure org-plus-contrib ;; :ensure org-plus-contrib
;; :ensure org-tempo ;; :ensure org-tempo
...@@ -459,11 +428,11 @@ org with contributed packages added. ...@@ -459,11 +428,11 @@ org with contributed packages added.
("c" . emacs) ("c" . emacs)
("h" . 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 () (defun org-toggle-emphasis ()
"Toggle hiding/showing of org emphasize markers." "Toggle hiding/showing of org emphasize markers."
(interactive) (interactive)
...@@ -471,59 +440,59 @@ Add a shortcut to toggle display of emphasis characters ...@@ -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 nil)
(set-variable 'org-hide-emphasis-markers t))) (set-variable 'org-hide-emphasis-markers t)))
(define-key org-mode-map (kbd "C-c e") 'org-toggle-emphasis) (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) (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 l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda) (global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture) (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 (add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp")) '("el" . "src emacs-lisp"))
#+end_src #+end_src
** Latex export ** 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")) (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)
(use-package org-ref-prettify) (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) (define-key org-mode-map (kbd "C-c [") 'org-reftex-citation)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
: org-reftex-citation : 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 (add-to-list 'org-latex-classes
'("book-noparts" '("book-noparts"
"\\documentclass{book}" "\\documentclass{book}"
...@@ -533,49 +502,49 @@ Define a document class that do not use parts and start with chapters ...@@ -533,49 +502,49 @@ Define a document class that do not use parts and start with chapters
("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+end_src #+end_src
** Visuals ** Visuals
Use bullets instead of asterisks Use bullets instead of asterisks
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org-bullets (use-package org-bullets
:init :init
(add-hook 'org-mode-hook 'org-bullets-mode)) (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") (set-face-foreground 'org-verbatim "orange1")
#+end_src #+end_src
** Task management ** Task management
Record when a todo item was marked as done and enforce marking Record when a todo item was marked as done and enforce marking
dependencies as done before being able to mark an item as done 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-log-done 'time)
(setq org-enforce-todo-dependencies t) (setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t) (setq org-enforce-todo-checkbox-dependencies t)
#+end_src #+end_src
Set default task completion states to =TODO=, =WAITING= and Set default task completion states to =TODO=, =WAITING= and
=DONE=. I use =WAITING= when I can't go further on a task because =DONE=. I use =WAITING= when I can't go further on a task because
I'm waiting for some inputs. I'm waiting for some inputs.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-todo-keywords (setq org-todo-keywords
'((sequence "TODO" "WAITING" "|" "DONE"))) '((sequence "TODO" "WAITING" "|" "DONE")))
#+end_src #+end_src
*** index and archive files *** 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") (setq org-directory "~/documents/org")
(defun org-file-path (filename) (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 ...@@ -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-index-file (org-file-path "index.org"))
(setq org-archive-location (setq org-archive-location
(concat (org-file-path "archive.org") "::* From %s")) (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 (setq org-agenda-files (list org-index-file
"~/.emacs.d/configuration.org" "~/.emacs.d/configuration.org"
(org-file-path "work.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 (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 () (defun hrs/mark-done-and-archive ()
"Mark the state of an org-mode item as DONE and archive it." "Mark the state of an org-mode item as DONE and archive it."
(interactive) (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 ...@@ -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)) (org-archive-subtree))
(define-key org-mode-map (kbd "C-c C-x C-s") 'hrs/mark-done-and-archive) (define-key org-mode-map (kbd "C-c C-x C-s") 'hrs/mark-done-and-archive)
#+end_src #+end_src
** Agenda ** 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) (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) (setq org-agenda-span 15)
#+end_src #+end_src
Define a custom agenda view. I want my agenda with tasks that are 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 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 have a date scheduled or as deadline. This is for tasks that I will
eventualy do later. eventualy do later.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-agenda-custom-commands (setq org-agenda-custom-commands
'(("a" "Agenda" '(("a" "Agenda"
( (
(agenda "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)))) (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)))) (alltodo "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline 'todo 'done))))
)))) ))))
#+end_src #+end_src
** Capture ** Capture
Define some capture template to be able to create tasks, or maybe Define some capture template to be able to create tasks, or maybe
other things later other things later
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-capture-templates (setq org-capture-templates
'(("f" "Finished book" '(("f" "Finished book"
table-line (file "~/Documents/org/books-read.org") table-line (file "~/Documents/org/books-read.org")
...@@ -666,25 +635,25 @@ other things later ...@@ -666,25 +635,25 @@ other things later
("w" "Cycling to work" ("w" "Cycling to work"
table-line (file "~/Documents/org/cycling.org") table-line (file "~/Documents/org/cycling.org")
"| %t | boulot | %^{prompt|électrique|standard} | 26.2 |"))) "| %t | boulot | %^{prompt|électrique|standard} | 26.2 |")))
#+end_src #+end_src
** Tree slide ** Tree slide
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org-tree-slide (use-package org-tree-slide
:config :config
(define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode) (define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode)
) )
#+end_src #+end_src
** Export configuration ** Export configuration
I use =org-mode= to export to LaTeX, (beamer and article) markdown and to HTML I use =org-mode= to export to LaTeX, (beamer and article) markdown and to HTML
using bootstrap template. using bootstrap template.
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; Add Beamer to export list ;; Add Beamer to export list
(require 'ox-beamer) (require 'ox-beamer)
;; And markdown ;; And markdown
...@@ -702,42 +671,42 @@ using bootstrap template. ...@@ -702,42 +671,42 @@ using bootstrap template.
;; Export using pandoc ;; Export using pandoc
(use-package ox-pandoc) (use-package ox-pandoc)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
Configure code highlighting using [[https://www.ctan.org/pkg/minted][minted]] (which uses Configure code highlighting using [[https://www.ctan.org/pkg/minted][minted]] (which uses
[[https://pygments.org/][Pygments]] as an external tool) for latex export [[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 ;; Configure ox-latex to export source block using minted
;; Setting minted cache to false as cache seems to fail when changing the output-directory ;; 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")) (add-to-list 'org-latex-packages-alist '("cache=false" "minted"))
(setq org-latex-listings '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) (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) (setq org-html-validation-link nil)
#+end_src #+end_src
** Source code evaluation ** Source code evaluation
So that source code blocks can be evaluated inside =org-mode=, we add 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 it to babel languages. =org-babel= is what executes code and outputs
its result in your org file. its result in your org file.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package gnuplot) (use-package gnuplot)
(use-package gnuplot-mode) (use-package gnuplot-mode)
(use-package ob-rust) (use-package ob-rust)
...@@ -758,78 +727,78 @@ its result in your org file. ...@@ -758,78 +727,78 @@ its result in your org file.
(shell . t) (shell . t)
(rust . t) (rust . t)
)) ))
#+END_SRC #+END_SRC
Preserve indentation in source block (useful for makefiles to preserve tabs for example) Preserve indentation in source block (useful for makefiles to preserve tabs for example)
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-src-preserve-indentation t) (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) (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) (use-package graphviz-dot-mode)
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) (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) (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") (setq org-babel-python-command "python3")
#+end_src #+end_src
Set line count limit before using =begin_example= blocs in code evaluation results Set line count limit before using =begin_example= blocs in code evaluation results
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-babel-min-lines-for-block-output 10) (setq org-babel-min-lines-for-block-output 10)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
: 10 : 10
** Transform json results to org-table ** Transform json results to org-table
I found a nice way to use json results in org mode by transforming a 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: json output to an org table. The emacs module can be found here:
https://github.com/noonker/json-to-org-table https://github.com/noonker/json-to-org-table
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'json-to-org-table nil t) (require 'json-to-org-table nil t)
#+end_src #+end_src
* Markdown mode * Markdown mode
I use pandoc to generate html output from markdown file. In order to 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 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") (setq markdown-command "pandoc --standalone --mathjax")
#+end_src #+end_src
* Completion setup * Completion setup
I use [[http://company-mode.github.io/][company]] mode for completion. It provides a visual completion 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 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. LSP, with which it provides semantic completion for code editing.
First, install and configure company and enable it for First, install and configure company and enable it for
all buffers. I also set =M-/= to trigger =company-complete= all buffers. I also set =M-/= to trigger =company-complete=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company (use-package company
:ensure company-box :ensure company-box
:ensure company-php :ensure company-php
...@@ -844,90 +813,90 @@ all buffers. I also set =M-/= to trigger =company-complete= ...@@ -844,90 +813,90 @@ all buffers. I also set =M-/= to trigger =company-complete=
(company-show-quick-access "off") (company-show-quick-access "off")
(company-quick-access-hint-function (lambda (param) " unknown")) (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 =company-box= adds icons to company complete list. It is useful when
completing symbols in source code. completing symbols in source code.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company-box (use-package company-box
:ensure frame-local :ensure frame-local
:hook (company-mode . company-box-mode)) :hook (company-mode . company-box-mode))
#+end_src #+end_src
Now some backends I use. Mainly php and web Now some backends I use. Mainly php and web
related. related.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company-php) (use-package company-php)
(use-package company-web) (use-package company-web)
#+end_src #+end_src
* Code navigation * Code navigation
** Treemacs ** Treemacs
I use [[https://github.com/Alexander-Miller/treemacs][Treemacs]] for code navigation. You can use it to define 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 /projects/ (a project is a folder actually) from which you can easily
navigate. You can have several workspaces that are simply a list of navigate. You can have several workspaces that are simply a list of
projects. I bind =C-c t= to toggle treemacs panel. projects. I bind =C-c t= to toggle treemacs panel.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package treemacs (use-package treemacs
:custom :custom
(treemacs--icon-size 16) (treemacs--icon-size 16)
:bind ("C-c t" . treemacs-select-window) :bind ("C-c t" . treemacs-select-window)
) )
#+end_src #+end_src
** Projectile ** Projectile
Projectile allows for easy file navigation inside Projectile allows for easy file navigation inside
projects. Projects are automatically detected by projectile projects. Projects are automatically detected by projectile
whenever a =.git= folder or a =.projectile= file is in a foler. 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 (use-package projectile
:config :config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode t)) (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) (use-package treemacs-projectile)
#+end_src #+end_src
* Snippets * Snippets
I use =yasnippet= for defining and using snippets for several modes. I 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). 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 (use-package yasnippet
:init :init
(yas-global-mode)) (yas-global-mode))
(use-package yasnippet-snippets) (use-package yasnippet-snippets)
#+end_src #+end_src
* Developpement * Developpement
Here, I setup all packages for developping in several languages. This 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 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 information from a language server dedicated to the programming
language currently in use. language currently in use.
** LSP ** LSP
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lsp-mode (use-package lsp-mode
:hook ( :hook (
(c++-mode . lsp) (c++-mode . lsp)
...@@ -940,86 +909,86 @@ language currently in use. ...@@ -940,86 +909,86 @@ language currently in use.
(lsp-headerline-breadcrumb-mode t) (lsp-headerline-breadcrumb-mode t)
:commands lsp :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 (use-package lsp-ui
:commands lsp-ui-mode) :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") (setq lsp-keymap-prefix "s-l")
#+end_src #+end_src
*** LSP through TRAMP *** LSP through TRAMP
For rust For rust
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; (lsp-register-client ;; (lsp-register-client
;; (make-lsp-client :new-connection (lsp-tramp-connection "rust-analyzer") ;; (make-lsp-client :new-connection (lsp-tramp-connection "rust-analyzer")
;; :major-modes '(rust-mode) ;; :major-modes '(rust-mode)
;; :remote? t ;; :remote? t
;; :server-id 'rust-analyzer-remote)) ;; :server-id 'rust-analyzer-remote))
(with-eval-after-load "tramp" (add-to-list 'tramp-remote-path "~/.cargo/bin")) (with-eval-after-load "tramp" (add-to-list 'tramp-remote-path "~/.cargo/bin"))
#+end_src #+end_src
*** Integration with treemacs *** 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 (use-package lsp-treemacs
:custom :custom
(lsp-treemacs-sync-mode 1)) (lsp-treemacs-sync-mode 1))
#+end_src #+end_src
** Flycheck ** Flycheck
[[https://www.flycheck.org/][Flycheck]] allow synthax checking in the source code buffer. LSP uses [[https://www.flycheck.org/][Flycheck]] allow synthax checking in the source code buffer. LSP uses
flycheck if available to show code diagnosis. flycheck if available to show code diagnosis.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package flycheck) (use-package flycheck)
#+end_src #+end_src
** Language specific configuration ** Language specific configuration
*** C *** C
Set indentation size and parameters Set indentation size and parameters
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq c-default-style "linux" (setq c-default-style "linux"
c-basic-offset 4) c-basic-offset 4)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
*** Rust *** 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 (use-package rust-mode
:custom :custom
(lsp-rust-server 'rust-analyzer) (lsp-rust-server 'rust-analyzer)
; (rust-format-on-save t) ; (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 ]] if [[ "$OSTYPE" =~ ^darwin ]]
then then
echo "Installing for macos" echo "Installing for macos"
...@@ -1030,54 +999,54 @@ else ...@@ -1030,54 +999,54 @@ else
fi fi
curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/$binary -o ~/.cargo/bin/rust-analyzer curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/$binary -o ~/.cargo/bin/rust-analyzer
chmod +x ~/.cargo/bin/rust-analyzer chmod +x ~/.cargo/bin/rust-analyzer
#+end_src #+end_src
#+RESULTS: #+RESULTS:
: Installing for macos : 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)) (setq exec-path (cons "~/.cargo/bin" exec-path))
#+end_src #+end_src
*** Lua *** Lua
Simply add =lua-mode= Simply add =lua-mode=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lua-mode) (use-package lua-mode)
#+end_src #+end_src
*** Docker *** 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 dockerfile-mode)
(use-package docker-compose-mode) (use-package docker-compose-mode)
(use-package docker) (use-package docker)
;(use-package docker-tramp) ;(use-package docker-tramp)
(use-package docker-api) (use-package docker-api)
(use-package docker-cli) (use-package docker-cli)
#+end_src #+end_src
*** Web *** Web
Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web editing. Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web editing.
- =web-mode= is a major mode for web template editing. We - =web-mode= is a major mode for web template editing. We
associate the mode with web files associate the mode with web files
- =rainbow-mode= colorizes color names in buffers - =rainbow-mode= colorizes color names in buffers
- =simple-httpd= is an http server implemented in =elisp= that can - =simple-httpd= is an http server implemented in =elisp= that can
serve local directory and even remote directory if associated serve local directory and even remote directory if associated
with tramp with tramp
- =impatient-mode= serves buffers dynamically with - =impatient-mode= serves buffers dynamically with
=simple-httpd=. What you edit in emacs is immediatly visible on =simple-httpd=. What you edit in emacs is immediatly visible on
the web browser the web browser
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package web-mode (use-package web-mode
:config :config
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) (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 ...@@ -1092,179 +1061,179 @@ Add =web-mode=, =rainbow-mode=, =simple-httpd= and =impatient-mode= for web edit
(use-package rainbow-mode) (use-package rainbow-mode)
(use-package simple-httpd) (use-package simple-httpd)
(use-package impatient-mode) (use-package impatient-mode)
#+end_src #+end_src
*** LaTeX *** 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) (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 (use-package auctex
:ensure auctex-latexmk :ensure auctex-latexmk
:defer t :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) (when (eq system-type 'darwin)
(setq exec-path (cons "/Library/TeX/texbin" exec-path))) (setq exec-path (cons "/Library/TeX/texbin" exec-path)))
#+end_src #+end_src
*** Ningx configuration *** 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) (use-package nginx-mode)
#+end_src #+end_src
*** Terraform *** 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-mode)
(use-package terraform-doc) (use-package terraform-doc)
(use-package company-terraform) (use-package company-terraform)
#+end_src #+end_src
*** Slint *** Slint
[[https://slint.dev/][Slint]] is a UI framework usable in Rust. It is based on a DSL to [[https://slint.dev/][Slint]] is a UI framework usable in Rust. It is based on a DSL to
describe the UI element. 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) (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 cargo install slint-lsp
#+end_src #+end_src
** Magit ** 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 + Bind =C-x g= to pop up the magit status buffer
+ configure magit to automatically revert buffers that are opened + configure magit to automatically revert buffers that are opened
if they are modified by a magit action (such as changing branch, if they are modified by a magit action (such as changing branch,
merging...) merging...)
+ Save buffers that visit a file that belongs to a repository if + Save buffers that visit a file that belongs to a repository if
needed needed
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package magit (use-package magit
:config :config
(magit-auto-revert-mode t) (magit-auto-revert-mode t)
(magit-save-repository-buffers t) (magit-save-repository-buffers t)
:bind ("C-x g" . magit-status) :bind ("C-x g" . magit-status)
) )
#+end_src #+end_src
*** Protocol buffers *** Protocol buffers
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package protobuf-mode) (use-package protobuf-mode)
#+end_src #+end_src
* Spell checking * 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") (setq ispell-program-name "aspell")
#+end_src #+end_src
#+RESULTS: #+RESULTS:
: aspell : 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 () (defun mh/spellcheck ()
(interactive) (interactive)
(flyspell-mode t) (flyspell-mode t)
(flyspell-buffer) (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) (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 Binding to fix a word /then/ go to the next error. Special syntax
=[?\C-\$]= is used to protect the =$= sign =[?\C-\$]= is used to protect the =$= sign
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun mh/cycle-spellcheck () (defun mh/cycle-spellcheck ()
(interactive) (interactive)
(flyspell-goto-next-error) (flyspell-goto-next-error)
(ispell-word)) (ispell-word))
(global-set-key (kbd "C-$") 'mh/cycle-spellcheck) (global-set-key (kbd "C-$") 'mh/cycle-spellcheck)
#+end_src #+end_src
** Grammalecte ** Grammalecte
Using grammalecte with flycheck Using grammalecte with flycheck
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package flycheck-grammalecte) (use-package flycheck-grammalecte)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
* Misc. * 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)) (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 Starts Emacs server so that we can use =emacsclient= for opening new
files. files.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(server-start) (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 ... emacsclient -a emacs ...
#+end_src #+end_src
This will attempt to connect to Emacs server and run Emacs if the This will attempt to connect to Emacs server and run Emacs if the
server is not started yet. 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) (use-package ssh-config-mode)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
: t : t
* To check later * To check later
...@@ -1276,10 +1245,10 @@ Add synthax highlighting for ssh_config files ...@@ -1276,10 +1245,10 @@ Add synthax highlighting for ssh_config files
* Performances tweaks (part. 2, profiling) * 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 This will print emacs start time as well as the count of GC calls
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(message "Emacs ready in %s with %d garbage collections." (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 ...@@ -1287,41 +1256,41 @@ This will print emacs start time as well as the count of GC calls
(float-time (float-time
(time-subtract after-init-time before-init-time))) (time-subtract after-init-time before-init-time)))
gcs-done))) 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 (use-package esup
:ensure t :ensure t
;; To use MELPA Stable use ":pin mepla-stable", ;; To use MELPA Stable use ":pin mepla-stable",
:pin melpa :pin melpa
:commands (esup)) :commands (esup))
#+end_src #+end_src
#+RESULTS: #+RESULTS:
* Performances tweaks (part. 3, the end) * 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)) (setq gc-cons-threshold (* 2 1024 1024))
#+end_src #+end_src
* Acknowledgment * Acknowledgment
I learned a great deal of how to use =org-mode= for emacs 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 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 a great [[https://www.youtube.com/watch?v=SzA2YODtgK4][talk]] on emacs =org-mode=. Parts of my configuration are
directly copied from his. 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 [[https://www.youtube.com/watch?v=gfZDwYeBlO4][Alain M. Lafon]] also gave a great talk on how emacs can be /played
like an instrument/. 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment