2023-09-29 19:55:17 +02:00
|
|
|
#+title: My Org-mode Emacs Config
|
|
|
|
#+author: Samuel ORTION
|
|
|
|
#+date: 2023-08-10
|
|
|
|
|
|
|
|
* Doom theme
|
|
|
|
** Use nerd-font in Emacs (for better support in vterm to liquidprompt)
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
2023-12-12 16:46:10 +01:00
|
|
|
(setq doom-font (font-spec :family "Fira Code Nerd Font" :size 12)
|
|
|
|
doom-big-font (font-spec :family "Fira Code Nerd Font" :size 24)
|
|
|
|
doom-variable-pitch-font (font-spec :family "Fira Code Nerd Font" :size 12)
|
|
|
|
doom-unicode-font (font-spec :family "Fira Code Nerd Font")
|
|
|
|
doom-serif-font (font-spec :family "Fira Code Nerd Font" :size 12 :weight 'light))
|
2023-09-29 19:55:17 +02:00
|
|
|
#+end_src
|
|
|
|
* UI
|
2024-03-29 17:38:18 +01:00
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq confirm-kill-emacs nil)
|
|
|
|
#+end_src
|
|
|
|
** Expand initial Frame
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(add-hook 'window-setup-hook 'toggle-frame-maximized t)
|
|
|
|
#+end_src
|
2023-09-29 19:55:17 +02:00
|
|
|
|
|
|
|
* Edition modes
|
|
|
|
|
|
|
|
** Quarto
|
2024-05-17 18:39:38 +02:00
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(require 'quarto-mode)
|
|
|
|
;;(add-to-list 'auto-mode-alist '("\\.Rmd\\'" . poly-quarto-mode))
|
|
|
|
#+end_src
|
2023-09-29 19:55:17 +02:00
|
|
|
|
|
|
|
** LaTeX
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq TeX-quote-after-quote t)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
*** Fix =cdlatex= back quote binding
|
|
|
|
#+begin_quote
|
|
|
|
I want my back quotes back.
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq cdlatex-math-symbol-prefix [f12])
|
|
|
|
#+end_src
|
|
|
|
|
2023-12-12 16:46:10 +01:00
|
|
|
Add custom LaTeX classes to ox-latex class.
|
2023-09-29 19:55:17 +02:00
|
|
|
#+begin_src emacs-lisp :tangle yes
|
2023-12-12 16:46:10 +01:00
|
|
|
(defun custom-latex-classes ()
|
|
|
|
(add-to-list 'org-latex-classes
|
2023-09-29 19:55:17 +02:00
|
|
|
'("scrartcl" "\\documentclass{scrartcl}"
|
2023-12-12 16:46:10 +01:00
|
|
|
("\\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-classes
|
|
|
|
'("scrbook" "\\documentclass{scrbook}"
|
|
|
|
("\\part{%s}" . "\\part*{%s}")
|
|
|
|
("\\chapter{%s}" . "\\chapter*{%s}")
|
2023-09-29 19:55:17 +02:00
|
|
|
("\\section{%s}" . "\\section*{%s}")
|
|
|
|
("\\subsection{%s}" . "\\subsection*{%s}")
|
|
|
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
|
|
|
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
2024-03-29 17:38:18 +01:00
|
|
|
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
|
|
|
|
(add-to-list 'org-latex-classes
|
|
|
|
'("scrreprt" "\\documentclass{scrreprt}"
|
|
|
|
("\\part{%s}" . "\\part*{%s}")
|
|
|
|
("\\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-classes
|
|
|
|
'("lamme2024" "\\documentclass{scrartcl}
|
|
|
|
[NO-DEFAULT-PACKAGES]
|
|
|
|
[NO-PACKAGES]
|
|
|
|
[EXTRA]
|
|
|
|
"
|
|
|
|
("\\part{%s}" . "\\part*{%s}")
|
|
|
|
("\\section{%s}" . "\\section*{%s}")
|
|
|
|
("\\subsection{%s}" . "\\subsection*{%s}")
|
|
|
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
|
|
|
("\\subsubsubsection{%s}" . "\\subsubsubsection*{%s}")
|
|
|
|
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
2023-09-29 19:55:17 +02:00
|
|
|
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
|
2023-12-12 16:46:10 +01:00
|
|
|
|
|
|
|
(eval-after-load "ox-latex"
|
|
|
|
#'custom-latex-classes)
|
2023-09-29 19:55:17 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq org-latex-compiler "lualatex")
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Use minted for code listings:
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq org-latex-listings 'minted
|
|
|
|
org-latex-packages-alist '(("" "minted"))
|
|
|
|
org-latex-pdf-process
|
|
|
|
'("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
|
|
|
|
"lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
|
|
|
|
#+end_src
|
|
|
|
Disable LateX preview in Org-mode by default
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq org-startup-with-latex-preview nil)
|
|
|
|
#+end_src
|
|
|
|
|
2023-12-12 16:46:10 +01:00
|
|
|
*** Add a hook so that the org file is tangled before the build
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(add-hook 'org-export-before-processing-hook #'org-babel-tangle)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
*** Syntax highlighting in Org-mode
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
2024-03-29 17:38:18 +01:00
|
|
|
; (setq org-highlight-latex-and-related '(latex script entities))
|
|
|
|
(setq org-highlight-latex-and-related '(native))
|
|
|
|
;; (add-hook 'org-mode-hook #'turn-on-org-cdlatex)
|
|
|
|
|
2023-12-12 16:46:10 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
\(i \in \mathbf{N}\)
|
|
|
|
|
2024-03-29 17:38:18 +01:00
|
|
|
*** Proper indentation in algorithmic
|
2023-09-29 19:55:17 +02:00
|
|
|
#+begin_src emacs-lisp :tangle yes
|
2024-03-29 17:38:18 +01:00
|
|
|
(with-eval-after-load 'latex
|
|
|
|
(add-to-list 'LaTeX-indent-environment-list '("algorithmic" current-indentation)))
|
2023-09-29 19:55:17 +02:00
|
|
|
#+end_src
|
|
|
|
** Enable conda environment in a Org-mode
|
|
|
|
|
2024-01-26 13:55:14 +01:00
|
|
|
#+begin_src emacs-lisp :tangle no
|
2023-09-29 19:55:17 +02:00
|
|
|
(require 'conda)
|
|
|
|
(conda-env-initialize-interactive-shells)
|
|
|
|
#+end_src
|
2023-12-12 16:46:10 +01:00
|
|
|
** Org-roam
|
|
|
|
Set the roam directory
|
|
|
|
#+begin_src emacs-lisp
|
2024-03-29 17:38:18 +01:00
|
|
|
(setq org-roam-directory "~/Documents/org/roam/")
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** =typst=
|
|
|
|
#+begin_src emacs-lisp :tangle no
|
|
|
|
(add-to-list 'treesit-language-source-alist
|
|
|
|
'(typst "https://github.com/uben0/tree-sitter-typst"))
|
|
|
|
(treesit-install-language-grammar 'typst)
|
2023-12-12 16:46:10 +01:00
|
|
|
#+end_src
|
2023-09-29 19:55:17 +02:00
|
|
|
|
|
|
|
* Emacs Server & Emacs Client
|
|
|
|
|
|
|
|
Emacs can be a little slow to startup: it might come useful to use Emacs server to share the initialization cost between instances.
|
|
|
|
|
|
|
|
|
|
|
|
Let's add an entry to our applications launcher, in client mode:
|
|
|
|
#+begin_src desktop :tangle no
|
|
|
|
# In ~/.local/share/applications/emacs-client.desktop
|
|
|
|
[Desktop Entry]
|
|
|
|
Name=Emacs (Client)
|
|
|
|
GenericName=Text Editor
|
|
|
|
Comment=Edit text
|
|
|
|
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
|
|
|
|
Exec=emacsclient -fs -c -a "emacs" %F
|
|
|
|
Icon=emacs
|
|
|
|
Type=Application
|
|
|
|
Terminal=false
|
|
|
|
Categories=Development;TextEditor;Utility;
|
|
|
|
StartupWMClass=Emacs
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
the =-fs= option enable to launch Emacs in full-screen mode at startup.
|
|
|
|
|
|
|
|
Then we start the Emacs daemon:
|
|
|
|
#+begin_src bash :tangle no
|
|
|
|
systemctl --user enable --now emacs
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+RESULTS:
|
|
|
|
|
2023-12-12 16:46:10 +01:00
|
|
|
* Escape from vim in libvterm while in evil-mode
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle no
|
|
|
|
(defun vim-save ()
|
|
|
|
":wd this unfortunate vim window in my terminal"
|
|
|
|
(interactive)
|
|
|
|
(send-))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+RESULTS:
|
|
|
|
: vim-save
|
2024-01-26 13:55:14 +01:00
|
|
|
|
|
|
|
* PlantUML
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(setq plantuml-default-exec-mode 'executable)
|
|
|
|
;; (setq plantuml-default-exec-mode 'jar)
|
|
|
|
(setq plantuml-executable-path "/usr/bin/plantuml")
|
|
|
|
;; setup plantuml for org-babel
|
2024-03-29 17:38:18 +01:00
|
|
|
;; (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
|
2024-01-26 13:55:14 +01:00
|
|
|
(setq org-plantuml-exec-mode 'executable)
|
|
|
|
(setq org-plantuml-executable-path plantuml-executable-path)
|
|
|
|
;; (require 'ob-plantuml) ; OBSOLETED
|
|
|
|
(setq org-plantuml-jar-path "/usr/share/java/plantuml.jar")
|
|
|
|
;; (setq plantuml-jar-args '())
|
|
|
|
;; Enable puml-mode for PlantUML files
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.puml\\'" . plantuml-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
|
|
|
|
#+end_src
|
2024-03-29 17:38:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
* Org-ref-acronyms
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(after! org
|
|
|
|
(require 'org-ref)
|
|
|
|
(add-to-list 'org-latex-classes
|
|
|
|
'("scientific-project"
|
|
|
|
"\\documentclass{scrreprt}
|
|
|
|
[NO-DEFAULT-PACKAGES]
|
|
|
|
[EXTRA]
|
|
|
|
\\makeindex
|
|
|
|
\\makeglossaries "
|
|
|
|
|
|
|
|
; ("\\part{%s}" . "\\part*{%s}")
|
|
|
|
("\\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-hook 'org-export-before-parsing-hook #'org-ref-acronyms-before-parsing)
|
|
|
|
(add-hook 'org-export-before-parsing-hook #'org-ref-glossary-before-parsing))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+RESULTS:
|
|
|
|
| org-ref-glossary-before-parsing | org-ref-acronyms-before-parsing | org-attach-expand-links |
|
|
|
|
| org-ref-glossary-before-parsing | org-ref-acronyms-before-parsing | org-attach-expand-links |
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle yes
|
|
|
|
(after! org (org-add-link-type
|
|
|
|
"latex" nil
|
|
|
|
(lambda (path desc format)
|
|
|
|
(cond
|
|
|
|
((eq format 'html)
|
|
|
|
(format "<span class=\"%s\">%s</span>" path desc))
|
|
|
|
((eq format 'latex)
|
|
|
|
(format "\\%s{%s}" path desc))))))
|
|
|
|
#+end_src
|