feat(emacs): add insert-frac
command for faster latex fractions
Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
parent
72a18f614d
commit
46e48e23d9
1 changed files with 21 additions and 0 deletions
|
@ -25,6 +25,26 @@
|
||||||
(insert "\\(\\)")
|
(insert "\\(\\)")
|
||||||
(backward-char 2)))))
|
(backward-char 2)))))
|
||||||
|
|
||||||
|
(defun insert-frac ()
|
||||||
|
"Insert a fraction in math mode."
|
||||||
|
(interactive)
|
||||||
|
(enter-math)
|
||||||
|
(backward-char)
|
||||||
|
(defconst bc (char-after))
|
||||||
|
(defconst bcs (char-to-string bc))
|
||||||
|
(forward-char)
|
||||||
|
(cond ((or (string-blank-p bcs)
|
||||||
|
(memq bc '(?\ ?( ?) ?{ ?} ?[ ?])))
|
||||||
|
(LaTeX-math-frac (not (texmathp))))
|
||||||
|
(t
|
||||||
|
(push-mark)
|
||||||
|
(backward-word)
|
||||||
|
(defconst content (buffer-substring (point) (mark)))
|
||||||
|
(delete-region (point) (mark))
|
||||||
|
(pop-mark)
|
||||||
|
(insert "\\frac{" content "}{}")
|
||||||
|
(backward-char))))
|
||||||
|
|
||||||
(defun configure-latex ()
|
(defun configure-latex ()
|
||||||
"Configure my custom LaTex environment."
|
"Configure my custom LaTex environment."
|
||||||
(electric-indent-mode -1)
|
(electric-indent-mode -1)
|
||||||
|
@ -37,6 +57,7 @@
|
||||||
(keymap-local-set "C-c C-z" #'custom-compile-latex)
|
(keymap-local-set "C-c C-z" #'custom-compile-latex)
|
||||||
(keymap-local-set "C-c C-b" #'latex-insert-block)
|
(keymap-local-set "C-c C-b" #'latex-insert-block)
|
||||||
(keymap-local-set "C-c C-h" #'enter-math)
|
(keymap-local-set "C-c C-h" #'enter-math)
|
||||||
|
(keymap-local-set "/" #'insert-frac)
|
||||||
(keymap-local-set "C-c C-/"
|
(keymap-local-set "C-c C-/"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue