 ;; Backup behaviour: store everything in single location
 (defvar danylo/backup-dir "~/.emacs.d/backups/")
 (setq backup-directory-alist (list (cons "." danylo/backup-dir)))
+(setq auto-save-file-name-transforms `((".*" ,danylo/backup-dir t)))
 
 (defun danylo/byte-compile-init-dir ()
   "Byte-compile Emacs config."


(defface danylo/latex-equation-face-main
  '((t (:foreground "orange"
		    :weight bold
		    :inherit default)))
  "Face for org-mode equation delimiters."
  :group 'danylo)

(define-minor-mode danylo/latex-font-lock-mode
  "LaTeX equation font locking."
  :lighter " latex-highlight"
  ;; Highlight $...$ and $$...$$
  (font-lock-add-keywords
   nil `((,(concat "\\(?:\\$\\$?\\)"
		   "\\(\\(?:[^$]*\n\\)*?[^$]*\\)"
		   "\\(?:\\$?\\$\\)")
	  (0 'danylo/latex-equation-face-main t))
	 (,(format "\\(\\$\\)" arg)
	  (0 'danylo/latex-equation-face-faded t))))
  ;; Highlight \begin{...}...\end{...}
  (mapcar
   (lambda (arg)
     (font-lock-add-keywords
      nil `((,(concat "\\(?:\\\\begin{" arg "[\\*]?}\\)"
		      "\\(\\(?:.*\n\\)*?.*\\)"
		      "\\(?:\\\\end{" arg "[\\*]?}\\)")
	     (0 'danylo/latex-equation-face-main t))
	    (,(format "\\(\\\\begin{%s[\\*]?}\\)" arg)
	     (0 'danylo/latex-equation-face-faded t))
	    (,(format "\\(\\\\end{%s[\\*]?}\\)" arg)
	     (0 'danylo/latex-equation-face-faded t)))))
   '("equation" "align" "alignat" "gather"
     "subequations" "multline" "optimization"))
  ;; Enable multiline fontification
  (set (make-local-variable 'font-lock-multiline) t))

;;; ..:: Syntax checking ::..

