summaryrefslogtreecommitdiff
path: root/tex-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'tex-conf.el')
-rw-r--r--tex-conf.el115
1 files changed, 115 insertions, 0 deletions
diff --git a/tex-conf.el b/tex-conf.el
index 45fd210..4c5211d 100644
--- a/tex-conf.el
+++ b/tex-conf.el
@@ -30,6 +30,121 @@
(setq TeX-auto-save t)
(setq TeX-parse-self t)
+(setq TeX-view-program-selection
+ '((output-dvi "open")
+ (output-pdf "PDF Tools")
+ (output-html "open")))
+
+;; I don't want to split the screen.
+
+;;;###autoload
+(defun durand-TeX-pdf-tools-sync-view-a ()
+ "Advice to `TeX-pdf-tools-sync-view', which won't pop buffers."
+ (unless (fboundp 'pdf-tools-install)
+ (error "PDF Tools are not available"))
+ (unless TeX-PDF-mode
+ (error "PDF Tools only work with PDF output"))
+ (add-hook 'pdf-sync-backward-redirect-functions
+ #'TeX-source-correlate-handle-TeX-region)
+ (if (and TeX-source-correlate-mode
+ (fboundp 'pdf-sync-forward-search))
+ (with-current-buffer (or (when TeX-current-process-region-p
+ (get-file-buffer (TeX-region-file t)))
+ (current-buffer))
+ (pdf-sync-forward-search))
+ (let ((pdf (TeX-active-master (TeX-output-extension))))
+ (switch-to-buffer (or (find-buffer-visiting pdf)
+ (find-file-noselect pdf))))))
+
+(advice-add #'TeX-pdf-tools-sync-view :override
+ #'durand-TeX-pdf-tools-sync-view-a)
+
+;;; Dollars
+
+(setq TeX-electric-math (cons "\\(" "\\)"))
+
+(define-key LaTeX-mode-map (vector ?\§) #'durand-insert-escape)
+
+;;;###autoload
+(defun durand-insert-escape ()
+ "Insert an escape character."
+ (interactive)
+ (insert "\\"))
+
+;;; Expansions
+
+(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
+
+(define-key LaTeX-math-mode-map (LaTeX-math-abbrev-prefix) t)
+
+(set-default 'LaTeX-math-abbrev-prefix "ù")
+
+(define-key LaTeX-math-mode-map
+ (LaTeX-math-abbrev-prefix) LaTeX-math-keymap)
+
+(cond ((boundp 'LaTeX-math-keymap))
+ ((defvar LaTeX-math-keymap)))
+
+(define-key LaTeX-math-keymap [?$] 'durand-insert-display-equation)
+(define-key LaTeX-math-keymap [?o] 'durand-insert-o-things)
+
+(setq LaTeX-math-list '((?$ durand-insert-display-equation)
+ (?o durand-insert-o-things)))
+
+;;;###autoload
+(defun durand-insert-display-equation ()
+ "Insert display equation symbols."
+ (interactive)
+ (insert "\\[\\]")
+ (goto-char (- (point) 2)))
+
+;;;###autoload
+(defvar durand-o-things-list nil
+ "A list of things associated with the \"o\" key.
+Each entry should have the form (key . macro),
+where the macro part is without the backslash.")
+
+(setq durand-o-things-list
+ (list
+ (cons "x" "otimes")
+ (cons "s" "sum")
+ (cons "p" "prod")
+ (cons "+" "oplus")
+ (cons "o" "circ")
+ (list "{" "{" "}")))
+
+;;;###autoload
+(defun durand-insert-o-things ()
+ "Insert a symbol associated with \"o\" key.
+The list is in the variable `durand-o-things-list'"
+ (interactive)
+ (let ((thing (minibuffer-with-setup-hook 'durand-headlong-minibuffer-setup-hook
+ (completing-read
+ "Chois une chose associée à \"o\":" (mapcar 'car durand-o-things-list)
+ nil t "^"))))
+ (let ((associated (alist-get thing durand-o-things-list nil nil #'string=)))
+ (cond
+ ((not (consp associated))
+ ;; length = 1
+ (insert (format "\\%s" (assoc-default thing durand-o-things-list #'string=))))
+ ((null (cddr associated))
+ ;; length = 2
+ (insert (format "\\left\\%s" (car associated)))
+ (save-excursion
+ (insert
+ (format "\\right\\%s" (cadr associated)))))
+ (t
+ (user-error "Weird associated: %S" associated))))))
+
+
+
+
+
+;; Automatic braces
+
+(setq TeX-electric-sub-and-superscript t)
+
+
;;; If I need to type nested documents frequently, the following will
;;; come in handy.