Add new snippets

This commit is contained in:
Samuel Ortion 2025-04-15 09:47:15 +02:00
parent 08e65589ef
commit 12a048253f
Signed by: sortion
GPG Key ID: 9B02406F8C4FB765
29 changed files with 361 additions and 33 deletions

View File

@ -4,34 +4,44 @@
* Doom theme
** Use nerd-font in Emacs (for better support in vterm to liquidprompt)
#+begin_src emacs-lisp :tangle yes
(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))
#+begin_src emacs-lisp
(setq doom-font (font-spec :family "FiraCode Nerd Font Mono" :size 12)
doom-big-font (font-spec :family "FiraCode Nerd Font Mono" :size 24)
doom-variable-pitch-font (font-spec :family "FiraCode Nerd Font Mono" :size 12)
doom-unicode-font (font-spec :family "FiraCode Nerd Font Mono")
doom-serif-font (font-spec :family "FiraCode Nerd Font Mono" :size 12 :weight 'light))
#+end_src
* UI
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(setq confirm-kill-emacs nil)
#+end_src
** Expand initial Frame
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(add-hook 'window-setup-hook 'toggle-frame-maximized t)
#+end_src
* Edition modes
** Quarto
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(require 'quarto-mode)
;;(add-to-list 'auto-mode-alist '("\\.Rmd\\'" . poly-quarto-mode))
#+end_src
** LaTeX
#+begin_src emacs-lisp :tangle yes
*** Enable LaTeX-mode by default
#+begin_src emacs-lisp
(setq TeX-default-mode #'LaTeX-mode ;; should already be the default mode
TeX-force-default-mode t)
#+end_src
#+begin_src emacs-lisp
(setq TeX-quote-after-quote t)
#+end_src
@ -40,12 +50,12 @@
I want my back quotes back.
#+end_quote
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(setq cdlatex-math-symbol-prefix [f12])
#+end_src
Add custom LaTeX classes to ox-latex class.
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(defun custom-latex-classes ()
(add-to-list 'org-latex-classes
'("scrartcl" "\\documentclass{scrartcl}"
@ -90,12 +100,12 @@ Add custom LaTeX classes to ox-latex class.
#'custom-latex-classes)
#+end_src
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(setq org-latex-compiler "lualatex")
#+end_src
Use minted for code listings:
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
@ -103,18 +113,24 @@ Use minted for code listings:
"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
#+begin_src emacs-lisp :tangle no
(setq org-startup-with-latex-preview nil)
#+end_src
#+begin_src emacs-lisp
(setq org-highlight-latex-and-related '(native))
#+end_src
*** Add a hook so that the org file is tangled before the build
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(add-hook 'org-export-before-processing-hook #'org-babel-tangle)
#+end_src
*** Syntax highlighting in Org-mode
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
; (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)
@ -124,10 +140,11 @@ Disable LateX preview in Org-mode by default
\(i \in \mathbf{N}\)
*** Proper indentation in algorithmic
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(with-eval-after-load 'latex
(add-to-list 'LaTeX-indent-environment-list '("algorithmic" current-indentation)))
#+end_src
** Enable conda environment in a Org-mode
#+begin_src emacs-lisp :tangle no
@ -191,7 +208,7 @@ systemctl --user enable --now emacs
* PlantUML
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(setq plantuml-default-exec-mode 'executable)
;; (setq plantuml-default-exec-mode 'jar)
(setq plantuml-executable-path "/usr/bin/plantuml")
@ -210,7 +227,7 @@ systemctl --user enable --now emacs
* Org-ref-acronyms
#+begin_src emacs-lisp :tangle yes
#+begin_src emacs-lisp
(after! org
(require 'org-ref)
(add-to-list 'org-latex-classes
@ -236,7 +253,7 @@ systemctl --user enable --now emacs
| 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
#+begin_src emacs-lisp
(after! org (org-add-link-type
"latex" nil
(lambda (path desc format)
@ -246,3 +263,12 @@ systemctl --user enable --now emacs
((eq format 'latex)
(format "\\%s{%s}" path desc))))))
#+end_src
#+begin_src emacs-lisp
(global-set-key [(meta up)] 'transpose-line-up)
(global-set-key [(meta down)] 'transpose-line-down)
#+end_src
#+RESULTS:
: transpose-line-down

26
custom.el Normal file
View File

@ -0,0 +1,26 @@
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(warning-suppress-log-types
'(((ox-latex))
((ox-latex))
((ox-latex))
((ox-latex))
((ox-latex))
(defvaralias)
(lexical-binding)))
'(warning-suppress-types
'(((ox-latex))
((ox-latex))
((ox-latex))
((ox-latex))
(defvaralias)
(lexical-binding))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

24
init.el
View File

@ -31,24 +31,24 @@
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
doom-quit ; DOOM quit-message prompts when you quit Emacs
(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra
indent-guides ; highlighted indent columns
;;ligatures ; ligatures and symbols to make your code pretty again
ligatures ; ligatures and symbols to make your code pretty again
;;minimap ; show a map of the code on the side
modeline ; snazzy, Atom-inspired modeline, plus API
;;nav-flash ; blink cursor line after big motions
;;neotree ; a project drawer, like NERDTree for vim
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
;;tabs ; a tab bar for Emacs
tabs ; a tab bar for Emacs
treemacs ; a project drawer, like neotree but cooler
unicode ; extended unicode support for various languages
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
;;window-select ; visually switch windows
window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
;;zen ; distraction-free coding or writing
@ -56,7 +56,7 @@
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
(format +onsave) ; automated prettiness
format ; automated prettiness
;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim
;;multiple-cursors ; editing in many places at once
@ -85,14 +85,14 @@
;;grammar ; tasing grammar mistake every you make
:tools
;;ansible
ansible
biblio ; Writes a PhD for you (citation needed)
;;collab ; buffers with friends
;;debugger ; FIXME stepping through code, to help you add bugs
;;direnv
;;docker
docker
editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs
ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
;;gist ; interacting with github gists
lookup ; navigate your code and its documentation
@ -107,7 +107,7 @@
;;terraform ; infrastructure as code
;;tmux ; an API for interacting with tmux
tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp
upload ; map local to remote projects via ssh/ftp
:os
;;(:if IS-MAC macos) ; improve compatibility with macOS
@ -136,7 +136,7 @@
;;fsharp ; ML stands for Microsoft's Language
;;fstar ; (dependent) types and (monadic) effects and Z3
;;gdscript ; the language you waited for
;;(go +lsp) ; the hipster dialect
(go +lsp) ; the hipster dialect
(graphql +lsp) ; Give queries a REST
(haskell +lsp) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python
@ -154,7 +154,7 @@
;;nim ; python + lisp at the speed of c
;;nix ; I hereby declare "nix geht mehr!"
(ocaml +lsp) ; an objective camel
(org +roam2 +hugo +pandoc +brain) ; organize your plain life in plain text
(org +hugo +pandoc +brain) ; organize your plain life in plain text
php ; perl's insecure younger brother
plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional
@ -175,7 +175,7 @@
;;terra ; Earth and Moon in alignment for performance.
web ; the tubes
yaml ; JSON, but readable
;;zig ; C, but simpler
zig ; C, but simpler
:email
;;(mu4e +org +gmail)

View File

@ -63,6 +63,10 @@
(package! ob-pasp
:recipe (:host github :repo "samuelortion/ob-pasp"))
(package! ob-hy
:recipe (:host github :repo "brantou/ob-hy"))
(package! hy-mode)
;; (package! ox-hugo)
(package! groovy-mode)
@ -75,3 +79,5 @@
;; (:host sourcehut :repo "meow_king/typst-ts-mode"))
(package! org-ref)
(package! cobol-mode)

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: begin
# key: \begin
# condition: t
# --
\begin{$1}
$2
\end{$1}

View File

@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# name: columns
# key: columns
# condition: t
# --
\begin{columns}
\begin{column}{0.5\textwidth}
$1
\end{column}
\begin{column}{0.5\textwidth}
$2
\end{column}
\end{columns}

View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: figure
# key: figure
# condition: t
# --
\begin{figure}[H]
\centering
\includegraphics[width=\columnwidth]{$1}
\caption{\label{fig:$2}$3}
\end{figure}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: ispellfrench
# key: ispellfrench
# condition: t
# --
% Local Variables:
% ispell-local-dictionary: "fr"
% End:

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: proof
# key: proof
# condition: t
# --
\begin{proof}
\end{proof}

View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: readfile
# key: readfile
# condition: t
# --
(with-open-file (in "$1")
(do ((line (read-line in nil)
(read-line in nil)))
((null line))
$2))

8
snippets/org-mode/R Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: R
# key: R
# condition: t
# --
#+begin_src R :session *R*
$0
#+end_src

7
snippets/org-mode/align* Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: align
# key: align
# --
\begin{align*}
$1
\end{align*}

8
snippets/org-mode/begin Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: begin
# key: \begin
# condition: t
# --
\begin{$1}
$2
\end{$1}

12
snippets/org-mode/cm Normal file
View File

@ -0,0 +1,12 @@
# -*- mode: snippet -*-
# name: cm
# key: cm
# condition: t
# --
#+title: $1
#+author: Samuel Ortion
#+date: 2024
#+LATEX_CLASS: scrartcl
#+LATEX_HEADER: \usepackage{mus}
* $2

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: definition
# key: definition
# --
\begin{definition}[$1]
\end{definition}

10
snippets/org-mode/figure Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: figure
# key: figure
# condition: t
# --
\begin{figure}[H]
\centering
\includegraphics[width=\columnwidth]{$1}
\caption{\label{fig:$2}$3}
\end{figure}

7
snippets/org-mode/frame Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: frame
# key: frame
# --
\begin{frame}{$1}
\end{frame}

12
snippets/org-mode/header Normal file
View File

@ -0,0 +1,12 @@
# -*- mode: snippet -*-
# name: header
# key: header
# condition: t
# --
#+PROPERTY: HEADER-ARGS+ :eval no-export
#+title: $1
#+author: Samuel Ortion
#+date: $2
#+latex_class: scrartcl
#+latex_header: \usepackage{mus}
#+bibliography: ../references.bib

View File

@ -0,0 +1,17 @@
# -*- mode: snippet -*-
# name: r image-ggplot
# key: r-imgg
# --
#+begin_src R :session *R* :results output graphics file :file notebooks/plots/${1:file}.png
library(ggplot2)
library(scales)
data <- $2
theme_set(theme_gray(base_size = 6))
gg <- ggplot(data, aes())
gg <- gg + <type of plot>
gg <- gg + scale_x_discrete("X title")
gg <- gg + scale_y_continuous("Y title")
gg <- gg + ggtitle("")
gg <- gg + theme(plot.title = element_text(hjust = 0.5))
gg
#+end_src

View File

@ -0,0 +1,14 @@
# -*- mode: snippet -*-
# name: image-python
# key: image-python
# condition: t
# --
#+begin_src python :session *Python* :results graphics file output :file "./plots/`(format-time-string "%Y%m%d")`_$1" :exports results
fig, ax = plt.subplots()
data = $2
ax.plot(data, '.b')
fig
#+end_src

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: ispellfrench
# key: ispellfrench
# condition: t
# --
# Local Variables:
# ispell-local-dictionary: "fr"
# End:

8
snippets/org-mode/proof Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: proof
# key: proof
# condition: t
# --
\begin{proof}
\end{proof}

View File

@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# name: pseudocode
# key: pseudocode
# --
\begin{algorithm}[H]
\caption{$1}
\begin{algorithmic}[1]
\Function{$2}{}
$3
\State \Return $4
\EndFunction
\end{algorithmic}
\end{algorithm}

View File

@ -0,0 +1,20 @@
# -*- mode: snippet -*-
# name: pyhead-lamme
# key: pyhead
# condition: t
# --
#+begin_src emacs-lisp :exports none
(pyvenv-activate "../.venv/lamme2025")
#+end_src
#+RESULTS:
#+begin_src python :session *Python* :results silent
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
#+end_src
#+begin_src python :session *Python* :results silent
plt.style.use("lamme2025")
#+end_src

8
snippets/org-mode/python Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: python
# key: python
# condition: t
# --
#+begin_src python :session *Python*
$0
#+end_src

View File

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: tabulate
# key: tabulate
# condition: t
# --
tabulate(
df,
headers=df.columns,
tablefmt="orgtbl")

10
snippets/org-mode/taocp Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: myexercise
# key: myexercise
# --
\begin{myexercise}{$1}{$2}
$4
\begin{myanswer}
$5
\end{myanswer}
\end{myexercise}

15
snippets/org-mode/tikzfig Normal file
View File

@ -0,0 +1,15 @@
# -*- mode: snippet -*-
# name: tikzfig
# key: tikzfig
# --
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
$0
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,20 @@
# -*- mode: snippet -*-
# name: Snakemake complete rule
# key: rule
# condition: t
# --
rule $1:
input:
$2
output:
$3
params:
$4
log:
stdout="logs/$5.stdout",
stderr="logs/$6.stderr"
shell:
"""
$7 > "{log.stdout}" 2> "{log.stderr}"
"""