2015-06-06 04:46:47 +00:00
|
|
|
;;; funcs.el --- Auctex Layer Functions File for Spacemacs
|
2015-05-04 06:29:34 +00:00
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2015-05-04 06:29:34 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-05-04 06:29:34 +00:00
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
(defun spacemacs//latex-setup-company ()
|
|
|
|
"Conditionally setup company based on backend."
|
2021-03-18 04:31:59 +00:00
|
|
|
(pcase latex-backend
|
2021-04-05 05:04:45 +00:00
|
|
|
('lsp
|
|
|
|
(spacemacs|add-company-backends ;; Activate lsp company explicitly to activate
|
|
|
|
:backends company-capf ;; standard backends as well
|
|
|
|
:modes LaTeX-mode))
|
|
|
|
('company-auctex
|
|
|
|
(when (configuration-layer/package-used-p 'company-auctex)
|
|
|
|
(if (configuration-layer/package-used-p 'company-math)
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-math-symbols-unicode
|
|
|
|
company-math-symbols-latex
|
|
|
|
company-auctex-macros
|
|
|
|
company-auctex-symbols
|
|
|
|
company-auctex-environments
|
|
|
|
:modes LaTeX-mode)
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-auctex-macros
|
|
|
|
company-auctex-symbols
|
|
|
|
company-auctex-environments
|
|
|
|
:modes LaTeX-mode)))
|
|
|
|
(when (configuration-layer/package-used-p 'company-reftex)
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-reftex-labels
|
|
|
|
company-reftex-citations
|
|
|
|
:modes LaTeX-mode)))))
|
2020-10-27 21:48:22 +00:00
|
|
|
|
|
|
|
(defun spacemacs//latex-setup-backend ()
|
|
|
|
"Conditionally setup latex backend."
|
2021-03-18 04:31:59 +00:00
|
|
|
(when (eq latex-backend 'lsp)
|
|
|
|
(require 'lsp-latex)
|
|
|
|
(lsp)))
|
2020-10-27 21:48:22 +00:00
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/build ()
|
2015-05-04 06:29:34 +00:00
|
|
|
(interactive)
|
|
|
|
(progn
|
|
|
|
(let ((TeX-save-query nil))
|
|
|
|
(TeX-save-document (TeX-master-file)))
|
2015-06-06 04:46:47 +00:00
|
|
|
(TeX-command latex-build-command 'TeX-master-file -1)))
|
2020-10-27 21:48:22 +00:00
|
|
|
;; (setq build-proc (TeX-command latex-build-command 'TeX-master-file -1))
|
|
|
|
;; ;; Sometimes, TeX-command returns nil causing an error in set-process-sentinel
|
|
|
|
;; (when build-proc
|
|
|
|
;; (set-process-sentinel build-proc 'latex//build-sentinel))))
|
2015-05-04 06:29:34 +00:00
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex//build-sentinel (process event)
|
2015-05-04 06:29:34 +00:00
|
|
|
(if (string= event "finished\n")
|
|
|
|
(TeX-view)
|
|
|
|
(message "Errors! Check with C-`")))
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex//autofill ()
|
2015-11-15 13:41:10 +00:00
|
|
|
"Check whether the pointer is currently inside one of the
|
2015-06-06 04:46:47 +00:00
|
|
|
environments described in `latex-nofill-env' and if so, inhibits
|
2015-05-04 06:29:34 +00:00
|
|
|
the automatic filling of the current paragraph."
|
|
|
|
(let ((do-auto-fill t)
|
|
|
|
(current-environment "")
|
|
|
|
(level 0))
|
|
|
|
(while (and do-auto-fill (not (string= current-environment "document")))
|
|
|
|
(setq level (1+ level)
|
|
|
|
current-environment (LaTeX-current-environment level)
|
2015-06-06 04:46:47 +00:00
|
|
|
do-auto-fill (not (member current-environment latex-nofill-env))))
|
2015-05-04 06:29:34 +00:00
|
|
|
(when do-auto-fill
|
|
|
|
(do-auto-fill))))
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/auto-fill-mode ()
|
2015-11-15 13:41:10 +00:00
|
|
|
"Toggle auto-fill-mode using the custom auto-fill function."
|
2015-05-04 06:29:34 +00:00
|
|
|
(interactive)
|
|
|
|
(auto-fill-mode)
|
2015-06-06 04:46:47 +00:00
|
|
|
(setq auto-fill-function 'latex//autofill))
|
2015-11-25 14:44:43 +00:00
|
|
|
|
|
|
|
;; Rebindings for TeX-font
|
|
|
|
(defun latex/font-bold () (interactive) (TeX-font nil ?\C-b))
|
|
|
|
(defun latex/font-medium () (interactive) (TeX-font nil ?\C-m))
|
|
|
|
(defun latex/font-code () (interactive) (TeX-font nil ?\C-t))
|
|
|
|
(defun latex/font-emphasis () (interactive) (TeX-font nil ?\C-e))
|
|
|
|
(defun latex/font-italic () (interactive) (TeX-font nil ?\C-i))
|
|
|
|
(defun latex/font-clear () (interactive) (TeX-font nil ?\C-d))
|
|
|
|
(defun latex/font-calligraphic () (interactive) (TeX-font nil ?\C-a))
|
|
|
|
(defun latex/font-small-caps () (interactive) (TeX-font nil ?\C-c))
|
|
|
|
(defun latex/font-sans-serif () (interactive) (TeX-font nil ?\C-f))
|
|
|
|
(defun latex/font-normal () (interactive) (TeX-font nil ?\C-n))
|
|
|
|
(defun latex/font-serif () (interactive) (TeX-font nil ?\C-r))
|
|
|
|
(defun latex/font-oblique () (interactive) (TeX-font nil ?\C-s))
|
|
|
|
(defun latex/font-upright () (interactive) (TeX-font nil ?\C-u))
|