Notes about math, research, and more.

(require ’yasnippet) (yas-global-mode 1)

(setq my-simple-alist ’( (“HH” . “\\mathcal{H}$0”) (“align” . “\n\\begin{align*}\n $1 \n\\end{align*}\n”) (“;o-” . “ō”) (“;i-” . “ī”) (“;a-” . “ā”) (“;u-” . “ū”) (“;e-” . “ē”) (“mk” . “\[1\]0”) (“HH” . “\(\\mathcal{H}\)”) (“TT” . “\(T\)”) (“FF” . “\(\\mathbb{F}\)”) (“C*-algebras ” . “\(C^\\ast\\text{-algebras}\) ”) (“C*-algebras.” . “\(C^\\ast\\text{-algebras.}\)”) (“C*-algebras\”“ . ”$C^\∗\\text{-algebras.}$\“”) (“C*-algebra ” . “\(C^\\ast\\text{-algebra}\) ”) (“C*-algebra.” . “\(C^\\ast\\text{-algebra.}\)”) (“C*-algebra\”“ . ”$C^\∗\\text{-algebra.}$\“”) (“k-graph” . “$k$-graph”) (“k-theory” . “$K$-theory”) (“C*-identity” . “\(C^\\ast\\text{-identity}\)”) (“roealgebra” . “\(C^*_{u}\)”) (“coarseembeddingfunctions” . “\(\\rho_{-}, \\rho_{+}:[0,\\infty) \\to [0,\\infty)\)”) (“cembedfunctions” . “\(\\rho_{-}, \\rho_{+}:[0,\\infty) \\to [0,\\infty)\) ”) (“cg0” . “$c > 0\[0") ("kg0" . "$k > 0\]0”) (“Cg0” . “$C > 0\[0") ("Kg0" . "$K > 0\]0”) (“dg0” . “$\δ > 0\[0") ("eg0" . "$\\epsilon > 0\]0”) (“rg0” . “$R > 0\[0") ("sg0" . "$S > 0\]0”) (“qisoms” . “quasiisometries $0”) (“yiny” . “$y \∈ Y\[0") ("xinx" . "$x \\in X\]0”) (“xyinx” . “$x,y \∈ X\[0") ("BB" . "$B\]0”) (“YY” . “$Y\[0") ("yy" . "$y\]0”) (“xx” . “$x\[0") ("zz" . "$z\]0”) (“ZZ” . “$\\mathbb{Z}\[0") ("AA" . "$A\]0”) (“XX” . “$X$$0”) (“dm” . “\n\\[\n $1 \n\\]$0”) ) )

(setq my-math-alist ’( (“omax” . “\⊗\max”) (“rho” . “\ρ”) (“odt” . “\o”) (“odot” . “\o”) (“max” . “\max”) (“min” . “\min”) (“otimes” . “\⊗”) (“forall” . “\∀”) (“perp” . “\⊥”) (“x0” . “x0”) (“x1” . “x1”) (“y0” . “y0”) (“y1” . “y1”) (“vphi” . “\ϕ”) (“ell” . “\ℓ”) (“leq” . “\≤”) (“geq” . “\≥”) (“ox” . “\⊗”) (“o+” . “\⊕”) (“span” . “\\text{span}”) (“pi” . “\π”) (“nimplies” . “\\centernot\\implies”) (“implies” . “\\implies”) (“rangle” . “\⟩”) (“ip” . “\⟨( $1 \⟩)$0”) (“paren” . “\\left( $1 \\right)$0”) (“pmat” . “\\begin{pmatrix}\n$0\n\\end{pmatrix}”) (“bmat” . “\\begin{bmatrix}\n$0\n\\end{bmatrix}”) (“Bmat” . “\\begin{Bmatrix}\n$0\n\\end{Bmatrix}”) (“vmat” . “\\begin{vmatrix}\n$0\n\\end{vmatrix}”) (“Vmat” . “\\begin{Vmatrix}\n$0\n\\end{Vmatrix}”) (“matrix” . “\\begin{matrix}\n$0\n\\end{matrix}”) (“pmat” . “\\begin{pmatrix}$0\\end{pmatrix}”) (“vmat” . “\\begin{vmatrix}$0\\end{vmatrix}”) (“Vmat” . “\\begin{Vmatrix}$0\\end{Vmatrix}”) (“matrix” . “\\begin{matrix}$0\\end{matrix}”) (“ol” . “\\overline{$1}$0”) (“TT” . “\\mathcal{T}”) (“bxy” . “\\mathcal{B}(X,Y)”) (“FF” . “\\mathbb{F}”) (“bofh” . “\\mathcal{B}(\\mathcal{H})”) (“ o ” . “ \ˆ ”) (“#” . “\\#”) (“cal” . “\\mathcal{$1}$0”) (“langle” . “\⟨”) (“symdif” . “{$2}~\Δ~{$1}$0”) (“xinx” . “x \∈ X$0”) (“0inf” . “[0, \∞)$0”) (“#” . “\\#$0”) (“diam” . “\\text{diam}$0”) (“ms” . “\\mathscr{$1} $0”) (“asdim” . “\\text{asdim } $0”) (“ in ” . “ \∈ $0”) (“maps” . “\\mapsto”) (“to ” . “ \→ $0”) (“nrm” . “\\left\\| $1 \\right\\|$0”) (“dist” . “\\text{dist}$1 $0”) (“cnrm” . “\\|\⋅\\|”) (“sm” . “\∖”) (“beg” . “\\begin{$0}\n$1\n\\end{$0}”) (“@v” . “\ϕ”) (“@p” . “\φ”) (“@a” . “\α”) (“@b” . “\β”) (“@g” . “\γ”) (“@G” . “\Γ”) (“@d” . “\δ”) (“@D” . “\Δ”) (“@e” . “\ε”) (“:e” . “\ε”) (“@z” . “\ζ”) (“@t” . “\θ”) (“@T” . “\Θ”) (“:t” . “\ϑ”) (“@i” . “\ι”) (“@k” . “\κ”) (“@l” . “\λ”) (“@L” . “\Λ”) (“@s” . “\σ”) (“@S” . “\Σ”) (“@u” . “\υ”) (“@U” . “\Υ”) (“@o” . “\ω”) (“@O” . “\Ω”) (“@m” . “\μ”) (“@n” . “\ν”) (“text” . “\\text{$1}$0”) (“txt” . “\\text{$1}$0”) (“\”“ . ”\\text{$1}$0“) (”sr“ . ”2“) (”cb“ . ”3“) (”rd“ . ”$1$0“) (”“ . ”$1$0“) (”sts“ . ”\\text{$0}“) (”sqc“ . ”\\sqcup“) (”Sq“ . ”\\sqrt{ $1 }$0“) (”//“ . ”\\frac{$1}{$2}$0“) (”ee“ . ”e $1 $0“) (”-1“ . ’(yas ”-1“)) (”conj“ . ”*“) (”Re“ . ”\\mathrm{Re}“) (”Im“ . ”\\mathrm{Im}“) (”bf“ . ”\\mathbf{$1}$0“) (”bb“ . ”\\mathbb{$1}$0“) (”rm“ . ”\\mathrm{$1}$0“) (”trace“ . ”\\mathrm{Tr}“) (”hat“ . ”\\hat{$1}$0“) (”bar“ . ”\\bar{$1}$0“) (”dot“ . ”\\dot{$1}$0“) (”ddot“ . ”\\ddot{$1}$0“) (”cdot“ . ”\⋅“) (”tilde“ . ”\~{$1}$0“) (”und“ . ”\\underline{$1}$0“) (”vec“ . ”\\vec{$1}$0“) (”ann“ . ”an“) (”bnn“ . ”bn“) (”cnn“ . ”cn“) (”xnn“ . ”xn“) (”xii“ . ”xi“) (”xjj“ . ”xj“) (”xp1“ . ”xn+1“) (”ynn“ . ”yn“) (”yii“ . ”yi“) (”yjj“ . ”yj“) (”ooo“ . ”\∞“) (”sum“ . ”\∑“) (”prod“ . ”\∏“) (”\∑“ . ”\∑$1=$2$3 $0“) (”\∏“ . ”\∏$1=$2$3 $0“) (”lim“ . ”\lim $1 \→ $2 $0“) (”-“ . ”\±“) (”-“ . ”\\mp“) (”nabl“ . ”\∇“) (”del“ . ”\∇“) (”xx“ . ”\ד) (”**“ . ”\⋅“) (”=“ . ”\≡“) (” neq “ . ”\≠ $0“) (”>=“ . ”\≥“) (”<=“ . ”\≤“) (”>>“ . ”\≫“) (”<<“ . ”\≪“) (”simm“ . ”\∼“) (”sim=“ . ”\≅“) (”prop“ . ”\∝“) (”<->“ . ”\↔ “) (”->“ . ”\→“) (”!>“ . ”\\mapsto“) (”>" . "\\implies") ("=<" . "\\impliedby") ("and" . "\\cap") ("orr" . "\\cup") ("notin" . "\\not\\in") ("subs" . "\\subset") ("sub“ . ”\\subseteq“) (”sup=“ . ”\\supseteq“) (”eset“ . ”\∅“) (”in“ . ”\∈“) (”rt“ . ”\\rtimes“) (”mxrt“ . ”\\rtimes\max“) (”mnrt“ . ”\\rtimes\min“) (”hkarr“ . ”\\hookrightarrow“) (”hookarr“ . ”\\hookrightarrow“) (”surj“ . ”\\twoheadrightarrow“) (”…“ . ”\\ldots“) (”set“ . ”\\\\{ $1 \\\\}$0“) (”LL“ . ”\\mathcal{L}“) (”HH“ . ”\\mathcal{H}“) (”UU“ . ”\\mathcal{U}“) (”cc“ . ”\\mathbb{C}“) (”RR“ . ”\\mathbb{R}“) (”ZZ“ . ”\\mathbb{Z}“) (”NN“ . ”\\mathbb{N}“) (”\∫“ . ”\∫ $1 \\, d$2 $0“) (”\∫“ . ”\∫ $1 \\, d$2 $0“) (”dint“ . ”\∫$4$3 $2 \\, d$1 $0“) (”oint“ . ”\\oint“) (”iint“ . ”\\iint“) (”iiint“ . ”\\iiint“) (”oinf“ . ”\∫0\∞ $2 \\, d$1 $0“) (”cases“ . ”\n\\begin{cases}\n$0\n\\end{cases}“) (”amin“ . ”\\argmin$1“) ; YASnippet snippet shorthand form ) )

(defun merge-alists (simple-alist math-alist) (let ((merged-alist ’())) (dolist (pair simple-alist) (let ((key (car pair)) (value (cdr pair))) (if (assoc key math-alist) (let ((value-math (cdr (assoc key math-alist)))) (push (cons key `(if (texmathp) ,value-math ,value)) merged-alist)) (push (cons key value) merged-alist)))) (dolist (pair math-alist) (let ((key (car pair)) (value (cdr pair))) (unless (assoc key simple-alist) (push (cons key `(if (texmathp) ,value ,key)) merged-alist)))) (nreverse merged-alist)))

(setq my-merged-alist (merge-alists my-simple-alist my-math-alist))

(defun convert-to-yasnippet-template (value) “Convert a string with $-markers to a yasnippet template.” (let ((template value) (counter 0)) (while (string-match “\\\(\\([0-9]+\\)" template) (setq template (replace-match (format "\){%s}” (match-string 1 template)) t nil template))) template) )

(defun create-new-alist (alist) “Create a new alist from ALIST based on the last character of the keys.” (let ((new-alist ’())) (dolist (pair alist) (let* ((key (car pair)) (last-char (substring key -1)) (existing-entry (assoc last-char new-alist))) (if existing-entry (setcdr existing-entry (append (cdr existing-entry) (list pair))) (setq new-alist (append new-alist (list (cons last-char (list pair)))))))) new-alist) )

(defun my-auto-expand () (when-let (words (alist-get (char-to-string last-command-event) my-autoexpand-alist nil nil #’string=)) (while words (let* ((def (car words)) (word (car def)) (start (- (point) (length word))) (end (point))) (cond ((string= (buffer-substring-no-properties start end) word) (let ((new-pattern (convert-to-yasnippet-template (eval (cdr def))))) (delete-region start end) (yas-expand-snippet new-pattern start start)) (setq words nil)) (t (setq words (cdr words))))))) )

(setq my-autoexpand-alist (create-new-alist my-merged-alist))

(add-hook ’LaTeX-mode-hook (lambda () (add-hook ’post-self-insert-hook #’my-auto-expand nil t))) (add-hook ’org-mode-hook (lambda () (add-hook ’post-self-insert-hook #’my-auto-expand nil t)))

(provide ’init-pat)