diff --git a/modules/lang/latex/autoload.el b/modules/lang/latex/autoload.el index c63b7b6be..d7176754e 100644 --- a/modules/lang/latex/autoload.el +++ b/modules/lang/latex/autoload.el @@ -2,14 +2,14 @@ ;;;###autoload (defun +latex/LaTeX-indent-item () - "Provide proper indentation for LaTeX \"itemize\",\"enumerate\", and \"description\" environments. + "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. +\"\\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." +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) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 1279b51d7..58e3417dc 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -93,9 +93,19 @@ If no viewers are found, `latex-preview-pane' is used.") LaTeX-item-indent 0) (when +latex--company-backends (set-company-backend! 'latex-mode +latex--company-backends)) - ;; Set custom item indentation + + ;; Provide proper indentation for LaTeX "itemize","enumerate", and + ;; "description" environments. See + ;; http://emacs.stackexchange.com/questions/3083/how-to-indent-items-in-latex-auctex-itemize-environments (dolist (env '("itemize" "enumerate" "description")) - (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item)))) + (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))) + ;; Fix #1849: allow fill-paragraph in itemize/enumerate + (defadvice! +latex--dont-indent-itemize-and-enumerate-a (orig-fn &rest args) + :around #'LaTeX-fill-region-as-paragraph + (let ((LaTeX-indent-environment-list LaTeX-indent-environment-list)) + (delq! "itemize" LaTeX-indent-environment-list 'assoc) + (delq! "enumerate" LaTeX-indent-environment-list 'assoc) + (apply orig-fn args)))) (use-package! preview