;;; J. Stolfi's emacs macros for teX/LaTeX editing ;;; Last edited on 2021-06-16 23:45:09 by jstolfi (defvar stolfi-tex-keymap (let ( (map (make-sparse-keymap)) ) ; (define-key map "\C-c\C-c" 'stolfi-tex-run-make) ; (define-key map "\C-c\C-a" 'stolfi-tex-run-make) ; (define-key map "\C-c`" 'next-error) ; also (usually) on "\C-x`" map ) "Stolfi's keymap for TeX/LaTeX editing" ) (defvar stolfi-tex-syntax-table (let ( (tbl (make-syntax-table)) ) (modify-syntax-entry ?$ "_" tbl) (modify-syntax-entry ?_ "_" tbl) (modify-syntax-entry ?^ "_" tbl) tbl ) "Stolfi's syntax table for TeX/LaTeX editing" ) (defun stolfi-tex-mode-higlight () (font-lock-add-keywords nil ' ( ( "\\\\stuff{([^\\n]*)}" 1 font-lock-warning-face t ) ) ) ) (defun stolfi-tex-mode () "Stolfi's mode for editing TeX/LaTeX files. \\{stolfi-tex-keymap}." (interactive) (kill-all-local-variables) ; (setq debug-on-error t) ; DEBUG (use-local-map stolfi-tex-keymap) (set-syntax-table stolfi-tex-syntax-table) (setq major-mode 'stolfi-tex-mode) (setq mode-name "STeX") (setq indent-tabs-mode nil) (make-local-variable 'require-final-newline) (setq require-final-newline t) (make-local-variable 'comment-start) (setq comment-start "% ") (make-local-variable 'comment-end) (setq comment-end "") (make-local-variable 'comment-column) (setq comment-column 1) (make-local-variable 'comment-start-skip) (setq comment-start-skip "\\*+ *") (make-local-variable 'comment-indent-hook) (setq comment-indent-hook nil) (make-local-variable 'parse-sexp-ignore-comments) (setq parse-sexp-ignore-comments t) (make-local-variable 'paragraph-start) (setq paragraph-start " *\\([\n\f]\\|\\\\\\(par\\|parag\\|begin\\|end\\|item\\|beq\\|eeq\\|beqs\\|eeqs\\|\\[\\|\\]\\)\\)") (make-local-variable 'paragraph-separate) (setq paragraph-separate paragraph-start) (make-local-variable 'paragraph-ignore-fill-prefix) (setq paragraph-ignore-fill-prefix t) ; Set to delete file stamps: (stolfi-time-stamp-buffer-setup t nil nil t "^[ %]*\\\\\\(newcommand{\\\\lastedit}\\|def\\\\lastedit\\){ *" "%04y-%02m-%02d %02H:%02M:%02S by %u" " *} *$" "\\def\\lastedit{DATE TIME by USER}" ) (add-hook 'local-write-file-hooks 'stolfi-time-stamp) (add-hook 'stolfi-tex-mode-hooks 'stolfi-tex-mode-higlight) (run-hooks 'stolfi-tex-mode-hooks) ) ;;; ;;; (fset 'PaTeX-mode 'patex-mode) ;;; ;;; (setq tex-dvi-view-command "xdvi") ;;; ;;; (defvar want-auctex nil ;;; "If not nil, use AUC TeX, instead of GNU's tex-mode.") ;;; (if want-auctex ;;; (progn ;;; (load "tex-site" t t) ;;; (defun patex-mode () ;;; "Major mode for editing files of input for PaTeX. ;;; ;;; Makes $ and } display the characters they match. ;;; Makes \" insert `` when it seems to be the beginning of a quotation, ;;; and '' when it appears to be the end; it inserts \" only after a \\. ;;; LFD and TAB indent lines as with programming modes. ;;; ;;; See under AUC TeX for full documentation. ;;; ;;; Special commands: ;;; \\{LaTeX-mode-map} ;;; ;;; Entering PaTeX mode calls the value of text-mode-hook, then the ;;; value of TeX-mode-hook, then the value of LaTeX-mode-hook. and ;;; then the value of PaTeX-mode-hook." ;;; (interactive) ;;; (require 'tex-init) ;;; (VirTeX-mode "PATEX"))) ;;; )