doomemacs/modules/lang/latex/autoload.el
2019-10-03 20:49:04 -04:00

49 lines
2 KiB
EmacsLisp

;;; lang/latex/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +latex/LaTeX-indent-item ()
"Provide proper indentation for LaTeX \"itemize\",\"enumerate\", and
\"description\" environments.
\"\\item\" is indented `LaTeX-indent-level' spaces relative to the the beginning
of the environment.
Continuation lines are indented either twice `LaTeX-indent-level', or
`LaTeX-indent-level-item-continuation' if the latter is bound."
(save-match-data
(let* ((offset LaTeX-indent-level)
(contin (or (and (boundp '+latex-indent-level-item-continuation)
+latex-indent-level-item-continuation)
(* 4 offset)))
(re-beg "\\\\begin{")
(re-end "\\\\end{")
(re-env "\\(itemize\\|\\enumerate\\|description\\)")
(indent (save-excursion
(when (looking-at (concat re-beg re-env "}"))
(end-of-line))
(LaTeX-find-matching-begin)
(current-column))))
(cond ((looking-at (concat re-beg re-env "}"))
(or (save-excursion
(beginning-of-line)
(ignore-errors
(LaTeX-find-matching-begin)
(+ (current-column)
(if (looking-at (concat re-beg re-env "}"))
contin
offset))))
indent))
((looking-at (concat re-end re-env "}"))
indent)
((looking-at "\\\\item")
(+ offset indent))
((+ contin indent))))))
;;;###autoload
(defun +latex-symbols-company-backend (command &optional arg &rest _ignored)
"A wrapper backend for `company-mode' that either uses
`company-math-symbols-unicode' or `company-math-symbols-latex'. If
`+latex-enable-unicode-math' is non-nil use the former, otherwise the latter."
(if +latex-enable-unicode-math
(company-math-symbols-unicode command arg)
(company-math-symbols-latex command arg)))