Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

  1. ;;; prelude-latex.el --- Emacs Prelude: Sane setup for LaTeX writers.
  2. ;;
  3. ;; Copyright © 2011-2020 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; This file is not part of GNU Emacs.
  8. ;;; Commentary:
  9. ;; Nice defaults for the premium LaTeX editing mode auctex.
  10. ;;; License:
  11. ;; This program is free software; you can redistribute it and/or
  12. ;; modify it under the terms of the GNU General Public License
  13. ;; as published by the Free Software Foundation; either version 3
  14. ;; of the License, or (at your option) any later version.
  15. ;;
  16. ;; This program is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;;
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  23. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. ;; Boston, MA 02110-1301, USA.
  25. ;;; Code:
  26. (prelude-require-packages '(auctex cdlatex))
  27. (require 'smartparens-latex)
  28. ;; for case
  29. (require 'cl-lib)
  30. (with-eval-after-load "company"
  31. (prelude-require-packages '(company-auctex))
  32. (company-auctex-init))
  33. (defcustom prelude-latex-fast-math-entry 'LaTeX-math-mode
  34. "Method used for fast math symbol entry in LaTeX."
  35. :link '(function-link :tag "AUCTeX Math Mode" LaTeX-math-mode)
  36. :link '(emacs-commentary-link :tag "CDLaTeX" "cdlatex.el")
  37. :group 'prelude
  38. :type '(choice (const :tag "None" nil)
  39. (const :tag "AUCTeX Math Mode" LaTeX-math-mode)
  40. (const :tag "CDLaTeX" cdlatex)))
  41. ;; AUCTeX configuration
  42. (setq TeX-auto-save t)
  43. (setq TeX-parse-self t)
  44. (setq TeX-close-quote "")
  45. (setq TeX-open-quote "")
  46. (setq-default TeX-master nil)
  47. ;; use pdflatex
  48. (setq TeX-PDF-mode t)
  49. ;; sensible defaults for macOS, other OSes should be covered out-of-the-box
  50. (when (eq system-type 'darwin)
  51. (setq TeX-view-program-selection
  52. '((output-dvi "DVI Viewer")
  53. (output-pdf "PDF Viewer")
  54. (output-html "HTML Viewer")))
  55. (setq TeX-view-program-list
  56. '(("DVI Viewer" "open %o")
  57. ("PDF Viewer" "open %o")
  58. ("HTML Viewer" "open %o"))))
  59. (defun prelude-latex-mode-defaults ()
  60. "Default Prelude hook for `LaTeX-mode'."
  61. (turn-on-auto-fill)
  62. (abbrev-mode +1)
  63. (smartparens-mode +1)
  64. (cl-case prelude-latex-fast-math-entry
  65. (LaTeX-math-mode (LaTeX-math-mode 1))
  66. (cdlatex (turn-on-cdlatex))))
  67. (setq prelude-latex-mode-hook 'prelude-latex-mode-defaults)
  68. (add-hook 'LaTeX-mode-hook (lambda ()
  69. (run-hooks 'prelude-latex-mode-hook)))
  70. (provide 'prelude-latex)
  71. ;;; prelude-latex.el ends here