From 5ab09ef043fec4c362f7b16d9b9d207e43268204 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Tue, 10 Apr 2018 15:19:40 -0400 Subject: [PATCH] Split the tex-mode stuff --- global.org | 89 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/global.org b/global.org index 6619958..110bf55 100644 --- a/global.org +++ b/global.org @@ -528,29 +528,35 @@ (advice-add 'org-babel-tangle-single-block :around #'org-babel-tangle-single-block-handle-tangle-list) #+END_SRC ** TODO split --- LaTeX - - #+BEGIN_SRC emacs-lisp +*** Require + Load auctex, reftex and set up related hooks + #+BEGIN_SRC emacs-lisp (load "auctex.el" nil t t) + (require 'reftex) + (add-hook 'LaTeX-mode-hook 'turn-on-reftex) + #+END_SRC +*** Set default TeX options + #+BEGIN_SRC emacs-lisp + (setq-default TeX-master nil) (setq TeX-auto-save t TeX-parse-self t TeX-insert-braces nil) - (setq-default TeX-master nil) - (setq font-latex-fontify-script nil) - (setq LaTeX-equation-label "e_") - (setq LaTeX-section-label "s_") - (setq LaTeX-figure-label "f_") - (setq TeX-fold-ellipsis " …") - (require 'reftex) - (defun my-LaTeX-mode-dollars () - (font-lock-add-keywords - nil - `((,(rx "$") (0 'success t))) - t)) - (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-dollars) - (add-hook 'LaTeX-mode-hook 'turn-on-reftex) - - ;; * Do not spell-check inside the following commands - ;; see [https://tex.stackexchange.com/questions/117204/skip-spelling-in-emacs-for-the-content-of-a-user-macro] + #+END_SRC +*** Appearance + No fontification for sub and superscripts + #+BEGIN_SRC emacs-lisp + (setq font-latex-fontify-script nil) + #+END_SRC +*** Default labels + #+BEGIN_SRC emacs-lisp + (setq LaTeX-equation-label "e_" + LaTeX-section-label "s_" + LaTeX-figure-label "f_") + #+END_SRC +*** Spell checking help + Do not spell-check inside the following commands. See + [https://tex.stackexchange.com/questions/117204/skip-spelling-in-emacs-for-the-content-of-a-user-macro] + #+BEGIN_SRC emacs-lisp (setq ispell-tex-skip-alists (list (append @@ -561,25 +567,42 @@ ("\\\\address" ispell-tex-arg-end) )) (cadr ispell-tex-skip-alists))) + #+END_SRC +*** Specialty functions + This function adds a pair of delimiters or surrounds the active region + with the given delimiters. +**** TODO it breaks when there is no mark + #+BEGIN_SRC emacs-lisp + (defun add-delimiter (delim-begin delim-end r-begin r-end) + "Add the pair of delimiters given in delim at the ends of the + region if it is activated" + (interactive "cBegin delimiter: \ncEnd delimiter: \nr") + (if (use-region-p) + (progn + (save-excursion + (goto-char r-end) (insert delim-end) + (goto-char r-begin) (insert delim-begin))) + (progn + (save-excursion + (insert delim-end)) + (insert delim-begin)))) + #+END_SRC +*** TODO Leftovers + #+BEGIN_SRC emacs-lisp + (setq TeX-fold-ellipsis " …") + + ;; I lost track of what does this guy do? + (defun my-LaTeX-mode-dollars () + (font-lock-add-keywords + nil + `((,(rx "$") (0 'success t))) + t)) + (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-dollars) (defun dabbrev-expand-helper () (interactive) (call-interactively 'dabbrev-expand)) - - (defun add-delimiter (delim-begin delim-end r-begin r-end) - "Add the pair of delimiters given in delim at the ends of the region if it is activated" - (interactive "cBegin delimiter: \ncEnd delimiter: \nr") - (if (use-region-p) - (progn - (save-excursion - (goto-char r-end) (insert delim-end) - (goto-char r-begin) (insert delim-begin))) - (progn - (save-excursion - (insert delim-end)) - (insert delim-begin)))) - (add-hook 'LaTeX-mode-hook (lambda () (turn-on-auto-fill)