diff options
-rw-r--r-- | init.el | 4 | ||||
-rw-r--r-- | skeleton-conf.el | 83 | ||||
-rw-r--r-- | tex-conf.el | 115 | ||||
-rw-r--r-- | view-conf.el | 6 |
4 files changed, 206 insertions, 2 deletions
@@ -115,6 +115,8 @@ no effect." (prepare-in-hook-once prepare-elisp emacs-lisp-mode-hook "elisp.el") +(prepare-in-hook-once prepare-skeleton emacs-lisp-mode-hook "skeleton-conf.el") + (prepare-in-hook-once prepare-org org-mode-hook "org-conf.el") (add-hook 'org-mode-hook #'prepare-org) @@ -267,6 +269,8 @@ no effect." (list (read-string prompt nil 'eww-prompt-history uris) (prefix-numeric-value current-prefix-arg))))) +(define-key global-map (vector 3 ?v ?w) #'eww) + ;;; Viewing things (load-config "view-conf.el") diff --git a/skeleton-conf.el b/skeleton-conf.el index a1dfaaf..6c6bcd0 100644 --- a/skeleton-conf.el +++ b/skeleton-conf.el @@ -35,5 +35,88 @@ '(recursive-edit) ")") +;;;###autoload +(define-skeleton insert-defun "Insert a defun statement." + "defun" + "(defun " + '(recursive-edit) + " (" + '(recursive-edit) + ")" + \n + (cond ((y-or-n-p "interactive?") + "(interactive)")) + & ?\n + > _ ")") + +;;;###autoload +(define-skeleton insert-tex "Insert a LaTeX skeleton." + "LaTeX" + "\\documentclass[12pt]{article} +\\usepackage[utf8]{inputenc} +\\usepackage[T1]{fontenc} +\\usepackage{graphicx} +\\usepackage{grffile} +\\usepackage{longtable} +\\usepackage{wrapfig} +\\usepackage{rotating} +\\usepackage[normalem]{ulem} +\\usepackage{amsmath} +\\usepackage{mathrsfs} +\\usepackage{textcomp} +\\usepackage{amssymb} +\\usepackage{capt-of} +\\usepackage{hyperref} +\\usepackage{amsfonts, amsthm} +\\usepackage{enumitem} +\\usepackage{tikz} +\\author{" + (let ((author (read-string "Author: " "Durand"))) + (cond ((string-empty-p author) + (prog1 "\\vspace{-1ex}" + (setq v1 ""))) + ((setq v1 author)))) + "}\n" + "\\date{" + (let ((date (read-string + "Date: " + (format-time-string "%Y-%m-%d")))) + (cond ((string-empty-p date) + "\\vspace{-1ex}") + (date))) + "}\n" + "\\title{\\vspace{-5ex}" + (setq v2 (read-string "Title: ")) "}\n" + "\\hypersetup{\n" + " pdfauthor={" v1 "},\n" + " pdftitle={" v2 "},\n" + " pdfkeywords={},\n" + " pdfsubject={},\n" + " pdfcreator={" v1 "},\n" + " pdflang={English}}\n\n" + "\\newtheorem{lem}{Lemma}[section] +\\newtheorem{coro}[lem]{Corollary} +\\newtheorem{thm}{Theorem}[section] +\\newtheorem{prop}{Proposition}[section] +\\newtheorem{ex}{Exercise}[section] +\\theoremstyle{definition} +\\newtheorem*{rmk}{Remark} +\\newtheorem{defn}{Definition}[section] + +\\newcommand{\\n}{\\mathbb{N}} +\\newcommand{\\z}{\\mathbb{Z}} +\\newcommand{\\q}{\\mathbb{Q}} +\\begin{document} +\\maketitle +\\vspace{-10ex}\n" + > _ + "\n\\end{document}") + +(cond ((assoc 'latex-mode auto-insert-alist) + (setcdr (assoc 'latex-mode auto-insert-alist) + #'insert-tex)) + ((add-to-list 'auto-insert-alist + (cons 'latex-mode #'insert-tex)))) + (provide 'skeleton-conf) ;;; skeleton-conf.el ends here 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. diff --git a/view-conf.el b/view-conf.el index 9d1ea5f..f41a6d1 100644 --- a/view-conf.el +++ b/view-conf.el @@ -103,6 +103,7 @@ If ARG is '(16), view the battery information." (define-key map (vector ?e) #'eshell) (define-key map (vector ?p) #'durand-chercher-pdf) (define-key map (vector ?o) #'olivetti-mode) + (define-key map (vector ?c) #'calendar) (define-key map (vector ?r) #'choose-recent-file) map) "The keymap that is related to my custom functions about viewing.") @@ -339,13 +340,14 @@ If ARG is non-nil, do the same for Bluetooth." ;;;###autoload (define-minor-mode durand-focus - "Focus mode." nil "Foc" nil + "Focus mode." nil " Foc" nil (cond (durand-focus (setq olivetti-body-width 65) (olivetti-mode 1) (text-scale-increase 2) - (variable-pitch-mode 1)) + (variable-pitch-mode 1) + (cond (current-prefix-arg (view-mode 1)))) ((setq olivetti-body-width 80) (variable-pitch-mode -1) (view-mode -1) |