diff --git a/dotfiles/doom/.gitignore b/dotfiles/doom/.gitignore deleted file mode 100644 index 2b57c07..0000000 --- a/dotfiles/doom/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -snippets/ -config.el diff --git a/dotfiles/doom/bin/appt-notification b/dotfiles/doom/bin/appt-notification deleted file mode 100755 index bc15dac..0000000 --- a/dotfiles/doom/bin/appt-notification +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -TIME="$1"TODO -MSG="$2" - -dunstify --replace=85401 "Event in $TIME minutes" "$MSG" diff --git a/dotfiles/doom/config.org b/dotfiles/doom/config.org deleted file mode 100644 index 1725dae..0000000 --- a/dotfiles/doom/config.org +++ /dev/null @@ -1,2783 +0,0 @@ -#+TITLE: Doom Emacs Configuration -:DRAWER: -#+STARTUP: overview - -#+LANGUAGE: en -#+EMAIL: dehaeze.thomas@gmail.com -#+AUTHOR: Dehaeze Thomas - -#+HTML_LINK_HOME: ./index.html -#+HTML_LINK_UP: ./index.html - -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: - -#+PROPERTY: header-args :tangle yes :results none :padline no -:END: - -https://medium.com/urbint-engineering/emacs-doom-for-newbies-1f8038604e3b -https://noelwelsh.com/posts/2019-01-10-doom-emacs.html -https://dotdoom.netlify.com/config.html - -Documentation: -- https://github.com/hlissner/doom-emacs/blob/develop/docs/index.org - -* Useful Bindings -| =spc := | Execute command | -| =spc <= | Switch to buffer | -| =spc X= | org-capture | -|-------------+------------------------------| -| =spc s s= | Search in buffer with swiper | -| =spc s p= | Search in project | -|-------------+------------------------------| -| =spc p p= | Switch project | -| =spc p t= | TODOs in project | -|-------------+------------------------------| -| =spc o f= | Create frame | -| =spc o e= | Toggle Eshell | -|-------------+------------------------------| -| =spc n l= | Store link | -|-------------+------------------------------| -| =spc g g= | Magit status | -|-------------+------------------------------| -| =spc f r= | Open recent file | -|-------------+------------------------------| -| =spc b B= | Switch to buffer | -| =spc b d= | Kill current buffer | -| =spc b i= | ibuffer | -|-------------+------------------------------| -| =spc tab .= | Switch to workspace | -| =spc tab n= | New workspace | -| =spc tab r= | Rename workspace | -|-------------+------------------------------| -| =spc m A= | org-archive-subtree | -| =spc m I= | org-toggle-inline-images | -| =spc m d= | org-deadline | -| =spc m e= | org-export-dispatch | -| =spc m o= | org-set-property | -| =spc m s= | org-schedule | -| =spc m t= | org-todo | - - -| C-c C-v p | org-babel-previous-src-block | -| C-c C-v n | org-babel-next-src-block | -| C-c C-v e | org-babel-execute-maybe | -| C-c C-v o | org-babel-open-src-block-result | -| C-c C-v v | org-babel-expand-src-block | -| C-c C-v u | org-babel-goto-src-block-head | -| C-c C-v g | org-babel-goto-named-src-block | -| C-c C-v r | org-babel-goto-named-result | -| C-c C-v b | org-babel-execute-buffer | -| C-c C-v s | org-babel-execute-subtree | -| C-c C-v d | org-babel-demarcate-block | -| C-c C-v t | org-babel-tangle | -| C-c C-v f | org-babel-tangle-file | -| C-c C-v c | org-babel-check-src-block | -| C-c C-v j | org-babel-insert-header-arg | -| C-c C-v l | org-babel-load-in-session | -| C-c C-v i | org-babel-lob-ingest | -| C-c C-v I | org-babel-view-src-block-info | -| C-c C-v z | org-babel-switch-to-session-with-code | -| C-c C-v a | org-babel-sha1-hash | -| C-c C-v h | org-babel-describe-bindings | -| C-c C-v x | org-babel-do-key-sequence-in-edit-buffer | - -* Personal Information -#+begin_src emacs-lisp -;; These are used for a number of things, particularly for GPG configuration, -;; some email clients, file templates and snippets. -(setq user-full-name "Dehaeze Thomas" - user-mail-address "dehaeze.thomas@gmail.com") -#+end_src - -* Doom Config -#+begin_src emacs-lisp - (setq doom-font (font-spec :family "Hack Nerd Font Mono" :size 12 :weight 'semi-light) - doom-variable-pitch-font (font-spec :family "Hack Nerd Font Mono") - doom-unicode-font (font-spec :family "Hack Nerd Font Mono" :size 12) - doom-big-font (font-spec :family "Hack Nerd Font Mono" :size 19)) -#+end_src - -#+begin_src emacs-lisp - ;; There are two ways to load a theme. Both assume the theme is installed and - ;; available. You can either set `doom-theme' or manually load a theme with the - ;; `load-theme' function. These are the defaults. - (setq doom-theme 'doom-gruvbox) -#+end_src - -#+begin_src emacs-lisp - (setq display-line-numbers-type t) -#+end_src - -* Evil -#+begin_src emacs-lisp -(after! evil - (map! :m "-" #'dired-jump)) -#+end_src - -#+begin_src emacs-lisp -(map! - (:after evil - :en "C-h" #'evil-window-left - :en "C-j" #'evil-window-down - :en "C-k" #'evil-window-up - :en "C-l" #'evil-window-right)) -#+end_src - -#+begin_src emacs-lisp -(after! which-key - (setq which-key-idle-delay 0.5 - which-key-idle-secondary-delay 0.01 - which-key-sort-order 'which-key-key-order-alpha)) -#+end_src - -* Basic -** Visual -Automatic line wrap. -#+begin_src emacs-lisp - (global-visual-line-mode t) -#+end_src - -Turn off auto-fill mode that add line breaks. -#+begin_src emacs-lisp - (auto-fill-mode -1) -#+end_src - -** Change default alert backend -#+begin_src emacs-lisp - (setq alert-default-style 'libnotify) -#+end_src - -** Lockfiles -#+begin_src emacs-lisp - (setq create-lockfiles nil) -#+end_src - -* Magit -#+begin_src emacs-lisp - (setenv "GIT_ASKPASS" "git-gui--askpass") - - (setq magit-diff-refine-hunk 'all) -#+end_src - -* Org Mode -- http://cachestocaches.com/2016/9/my-workflow-org-agenda/ -- http://doc.norang.ca/org-mode.html#TodoKeywords -- https://emacs.cafe/emacs/orgmode/gtd/2017/06/30/orgmode-gtd.html - -** Make sure to load Org -#+begin_src emacs-lisp - (require 'org) -#+end_src - -** Org General Config -#+begin_src emacs-lisp - (setq org-directory "~/Cloud/org/") - - (setq org-default-notes-file "~/Cloud/org/refile.org") - - ;; Highligh latex parts in org mode - (setq org-highlight-latex-and-related '(native)) - - ;; The following setting hides blank lines between headings which keeps folded view nice and compact. - (setq org-cycle-separator-lines 0) - - ;; Indent according to the outline structure - (setq org-startup-indented t) - - ;; Record the information of when the task was marked as DONE - (setq org-log-done 'time) -#+end_src - -TAB was changed to toggle only the visibility state of the current subtree, rather than cycle through it recursively. This can be reversed with: -#+begin_src emacs-lisp - (after! evil-org - (remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h)) -#+end_src - -** Org latex fragment -#+begin_src emacs-lisp - (setq org-highlight-latex-and-related '(native)) -#+end_src - -#+begin_src emacs-lisp - (defvar tdh/org-latex-fragment-last nil - "Holds last fragment/environment you were on.") - - (defun tdh/org-in-latex-fragment-p () - "Return the point where the latex fragment begins, if inside - a latex fragment. Else return false" - (let* ((el (org-element-context)) - (el-type (car el))) - (and (or (eq 'latex-fragment el-type) (eq 'latex-environment el-type)) - (org-element-property :begin el)))) - - (defun tdh/org-latex-fragment-toggle () - "Toggle a latex fragment image " - (and (eq 'org-mode major-mode) - (let ((begin (tdh/org-in-latex-fragment-p))) - (cond - ;; were on a fragment and now on a new fragment - ((and - ;; fragment we were on - tdh/org-latex-fragment-last - ;; and are on a fragment now - begin - - ;; but not on the last one this is a little tricky. as you edit the - ;; fragment, it is not equal to the last one. We use the begin - ;; property which is less likely to change for the comparison. - (not (and tdh/org-latex-fragment-last - (= begin - tdh/org-latex-fragment-last)))) - ;; go back to last one and put image back, provided there is still a fragment there - (save-excursion - (goto-char tdh/org-latex-fragment-last) - (when (tdh/org-in-latex-fragment-p) (org-preview-latex-fragment)) - - ;; now remove current image - (goto-char begin) - (let ((ov (loop for ov in (org--list-latex-overlays) - if - (and -r (<= (overlay-start ov) (point)) - (>= (overlay-end ov) (point))) - return ov))) - (when ov - (delete-overlay ov))) - ;; and save new fragment - (setq tdh/org-latex-fragment-last begin))) - - ;; were on a fragment and now are not on a fragment - ((and - ;; not on a fragment now - (not begin) - ;; but we were on one - tdh/org-latex-fragment-last) - ;; put image back on, provided that there is still a fragment here. - (save-excursion - (goto-char tdh/org-latex-fragment-last) - (when (tdh/org-in-latex-fragment-p) (org-preview-latex-fragment))) - - ;; unset last fragment - (setq tdh/org-latex-fragment-last nil)) - - ;; were not on a fragment, and now are - ((and - ;; we were not one one - (not tdh/org-latex-fragment-last) - ;; but now we are - begin) - ;; remove image - (save-excursion - (goto-char begin) - (let ((ov (loop for ov in (org--list-latex-overlays) - if - (and - (<= (overlay-start ov) (point)) - (>= (overlay-end ov) (point))) - return ov))) - (when ov - (delete-overlay ov)))) - (setq tdh/org-latex-fragment-last begin)))))) -#+end_src - -** Org Links -#+begin_src emacs-lisp - (map! :map org-mode-map "C-c l" 'org-store-link) -#+end_src - -** Org Tagging -#+begin_src emacs-lisp - ;; Align Tags and flush right - (setq org-tags-column -80) - ;; Tags with fast selection keys - (setq org-tag-alist (quote (("@home" . ?h) - ("@work" . ?w) - ("@christophe" . ?c) - ("@veijo" . ?v)))) -#+end_src - -** Org Refile -#+begin_src emacs-lisp - (setq org-refile-targets '((org-agenda-files . (:maxlevel . 6)))) -#+end_src - -** Org TODO -#+begin_src emacs-lisp - ;; Tags with fast selection keys - (setq org-todo-keywords '( - (sequence "TODO(t)" "NEXT(n)" "MAIL(m)" "|" "DONE(d)") - (sequence "READ(r)" "BKMK(b)" "EXER(x)" "|" "DONE(d)") - (sequence "WAIT(w@/!)" "SDAY(s)" "|" "CANC(c@/!)") - (sequence "QUES(q)" "|" "ANSW(a)") - (sequence "EXAM(e)" "IDEA(i)" "|") - )) - - ;; Display of the keywords - (setq org-todo-keyword-faces - '(("TODO" . (:foreground "#cc241d" :weight bold)) ;; red - ("EXER" . (:foreground "#cc241d" :weight bold)) ;; red - ("NEXT" . (:foreground "#cc241d" :weight bold)) ;; red - ("MAIL" . (:foreground "#cc241d" :weight bold)) ;; red - ("READ" . (:foreground "#cc241d" :weight bold)) ;; red - ("ANSW" . (:foreground "#689d6a" :weight bold)) ;; aqua - ("DONE" . (:foreground "#689d6a" :weight bold)) ;; aqua - ("WAIT" . (:foreground "#d65d0e" :weight bold)) ;; orange - ("QUES" . (:foreground "#d79921" :weight bold)) ;; yellow - ("CANC" . (:foreground "#a89984" :weight bold)) ;; grey - ("SDAY" . (:foreground "#98971a" :weight bold)) ;; green - ("BKMK" . (:foreground "#98971a" :weight bold)) ;; green - ("IDEA" . (:foreground "#98971a" :weight bold)) ;; green - ("EXAM" . (:foreground "#98971a" :weight bold)))) ;; green -#+end_src - -** Archive subtrees under the same hierarchy as original in the archive files -https://gist.github.com/Fuco1/e86fb5e0a5bb71ceafccedb5ca22fcfb - -#+begin_src emacs-lisp - (defadvice org-archive-subtree (around fix-hierarchy activate) - (let* ((fix-archive-p (and (not current-prefix-arg) - (not (use-region-p)))) - (location (org-archive--compute-location org-archive-location)) - (afile (car location)) - (offset (if (= 0 (length (cdr location))) - 1 - (1+ (string-match "[^*]" (cdr location))))) - (buffer (or (find-buffer-visiting afile) (find-file-noselect afile)))) - ad-do-it - (when fix-archive-p - (with-current-buffer buffer - (goto-char (point-max)) - (while (> (org-current-level) offset) (org-up-heading-safe)) - (let* ((olpath (org-entry-get (point) "ARCHIVE_OLPATH")) - (path (and olpath (split-string olpath "/"))) - (level offset) - tree-text) - (when olpath - (org-mark-subtree) - (setq tree-text (buffer-substring (region-beginning) (region-end))) - (let (this-command) (org-cut-subtree)) - (goto-char (point-min)) - (save-restriction - (widen) - (-each path - (lambda (heading) - (if (re-search-forward - (rx-to-string - `(: bol (repeat ,level "*") (1+ " ") ,heading)) nil t) - (org-narrow-to-subtree) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert (make-string level ?*) - " " - heading - "\n")) - (cl-incf level))) - (widen) - (org-end-of-subtree t t) - (org-paste-subtree level tree-text)))))))) -#+end_src - -** Org Agenda -*** General configuration -#+begin_src emacs-lisp - (map! :map org-mode-map "C-c a" 'org-agenda) - - ;; File to save todo items - (setq org-agenda-files (list "~/Cloud/org/")) - - ;; Include archived files - (setq org-agenda-archives-mode t) - - ;; Set priority range from A to C with default A - (setq org-highest-priority ?A) - (setq org-lowest-priority ?C) - (setq org-default-priority ?C) - - ;; Set colours for priorities - (setq org-priority-faces '((?A . (:foreground "#CC241D")) - (?B . (:foreground "#D65D0E")) - (?C . (:foreground "#D79921")))) - - ;; Open agenda in current window - (setq org-agenda-window-setup 'current-window) - - (setq org-agenda-prefix-format - '((agenda . " %-12:c %?-12t% s") - (todo . "") ;; Don't show the filename for reading agenda - (tags . " %-12:c") - (search . " %-12:c")) - ) -#+end_src -#+begin_src emacs-lisp - (map! :map org-mode-map "C-c a" 'org-agenda) - - ;; File to save todo items - (setq org-agenda-files (list "~/Cloud/org/")) - - ;; Include archived files - (setq org-agenda-archives-mode t) - - ;; Set priority range from A to C with default A - (setq org-highest-priority ?A) - (setq org-lowest-priority ?C) - (setq org-default-priority ?C) - - ;; Set colours for priorities - (setq org-priority-faces '((?A . (:foreground "#CC241D")) - (?B . (:foreground "#D65D0E")) - (?C . (:foreground "#D79921")))) - - ;; Open agenda in current window - (setq org-agenda-window-setup 'current-window) - - (setq org-agenda-prefix-format - '((agenda . " %-12:c %?-12t% s") - (todo . "") ;; Don't show the filename for reading agenda - (tags . " %-12:c") - (search . " %-12:c"))) -#+end_src - -*** Org Agenda Custom Views -https://blog.aaronbieber.com/2016/09/24/an-agenda-for-life-with-org-mode.html - -#+begin_src emacs-lisp - (defun tdh/org-agenda-skip-scheduled () - (org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>")) - - (setq org-agenda-custom-commands - '(("w" "Work" tags-todo "@work") ;; All todos related to work - ("h" "Home" tags-todo "@home") ;; All todos not related to work - ("q" . "Questions to ask") - ("qc" "Questions to Cristophe" tags "@christophe/QUES" ((org-agenda-overriding-header "Questions to Christophe"))) - ("qm" "Questions to Muriel" tags "@muriel/QUES" ((org-agenda-overriding-header "Questions to Muriel"))) - ("qo" "Questions to Olivier" tags "@olivier/QUES" ((org-agenda-overriding-header "Questions to Olivier"))) - ("qq" "All questions" tags "/QUES" ((org-agenda-overriding-header "Other questions"))) - ("n" "Next things to do" - ((tags "+PRIORITY+\"A\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "High-priority unfinished tasks:"))) - (agenda "") - (todo "NEXT" ((org-agenda-skip-function 'tdh/org-agenda-skip-scheduled)(org-agenda-overriding-header "Next thing to do that are not scheduled"))) - (todo "MAIL" ((org-agenda-overriding-header "Email to write/reply"))) - (todo "WAIT" ((org-agenda-overriding-header "Things Waiting"))))) - ("u" "Unscheduled tasks" todo "TODO" - ((org-agenda-skip-function 'tdh/org-agenda-skip-scheduled) - (org-agenda-overriding-header "Unscheduled TODO entries: "))) - ("r" "Things to read" - ((todo "READ" ((org-agenda-overriding-header "Things to read")))) - ((org-agenda-files '("~/Cloud/thesis/ressources/notes/"))))) - ) -#+end_src - -** Org Notification based on calendar event -https://emacs.stackexchange.com/questions/3844/good-methods-for-setting-up-alarms-audio-visual-triggered-by-org-mode-events - -#+begin_src emacs-lisp - (setq appt-message-warning-time 5) - (defun my-org-agenda-to-appt () - (interactive) - (setq appt-time-msg-list nil) - (org-agenda-to-appt)) - - (my-org-agenda-to-appt) - ; Display appointments as a window manager notification - (setq appt-disp-window-function 'my-appt-display) - (setq appt-delete-window-function (lambda () t)) - - (setq my-appt-notification-app (concat (getenv "HOME") "/bin/appt-notification")) - (defun my-appt-display (min-to-app new-time msg) - (if (atom min-to-app) - (start-process "my-appt-notification-app" nil my-appt-notification-app min-to-app msg) - (dolist (i (number-sequence 0 (1- (length min-to-app)))) - (start-process "my-appt-notification-app" nil my-appt-notification-app (nth i min-to-app) (nth i msg))))) -#+end_src - -*** appt-notification script -:PROPERTIES: -:header-args: :tangle ~/.config/doom/bin/appt-notification -:header-args+: :comments none :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash - TIME="$1"TODO - MSG="$2" - - dunstify --replace=85401 "Event in $TIME minutes" "$MSG" -#+end_src - -** Org Structure Template -#+begin_src emacs-lisp - (setq org-structure-template-alist - '(("c" . "center") - ("C" . "comment") - ("i" . "important") - ("e" . "example") - ("q" . "quote") - ("s" . "src")) - ) -#+end_src - -** Org Capture -Documentation: -- Template elements: https://orgmode.org/manual/Template-elements.html#Template-elements -- Template expansion: https://orgmode.org/manual/Template-expansion.html#Template-expansion -- Capture protocol: https://orgmode.org/manual/capture-protocol.html - -#+begin_src emacs-lisp - (map! :map org-mode-map "C-c c" 'org-capture) -#+end_src - -#+begin_src emacs-lisp - (setq org-capture-templates - (quote (("t" ; key - "todo" ; name - entry ; type - (file+headline "~/Cloud/org/work-notebook.org" "Inbox") ; target - "** TODO %?\n%U\n" ; template - ) - ("M" ; key - "Meeting" ; name - entry ; type - (file+headline "~/Cloud/org/work-notebook.org" "Meetings") ; target - "** %?\n%(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n" ; template - ) - ("m" ; key - "mail" ; name - entry ; type - (file+headline "~/Cloud/org/work-notebook.org" "Mails") ; target - "** TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n" ; template - ) - ("pm" - "Org-Protocol Mail" - entry - (file+headline "~/Cloud/org/work-notebook.org" "Mails") - "* MAIL %:description [[message:%:link][link]]\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n\n" - :immediate-finish t - ) - ("pu" - "Org-Protocol Url" - entry - (file+headline "~/Cloud/org/work-notebook.org" "Inbox") - "* [[%:link][%:description]]\nCaptured On: %U\n\n" - :immediate-finish t - ) - ("pt" - "Org-Protocol text" - entry - (file+headline "~/Cloud/org/work-notebook.org" "Inbox") - "* %:description\nSource: %:link\nCaptured On: %U\n\n#+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n" - :immediate-finish t - ) - ))) -#+end_src - -** Org Export -*** Basic -#+begin_src emacs-lisp - ;; How many levels of headline to export - (setq org-export-headline-levels 4) - - ;; Authorize BIND to set local variables - (setq org-export-allow-bind-keywords t) - - (setq org-odt-preferred-output-format "doc") - - ;; Used to not export headings with :ignore: tag - (require 'ox-extra) - (ox-extras-activate '(ignore-headlines)) -#+end_src - -*** Ox Latex Subfigure package -#+begin_src emacs-lisp - (use-package! ox-latex-subfigure - :config (require 'ox-latex-subfigure)) -#+end_src - -*** Clear page before heading -https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-heading/30892 - -#+begin_src emacs-lisp - (defun org/get-headline-string-element (headline backend info) - (let ((prop-point (next-property-change 0 headline))) - (if prop-point (plist-get (text-properties-at prop-point headline) :parent)))) - - (defun org/ensure-latex-clearpage (headline backend info) - (when (org-export-derived-backend-p backend 'latex) - (let ((elmnt (org/get-headline-string-element headline backend info))) - (when (and elmnt (org-element-property :CLEARPAGE elmnt)) - (concat "\\clearpage\n" headline))))) - - (add-to-list 'org-export-filter-headline-functions - 'org/ensure-latex-clearpage) -#+end_src - -*** TODO HTML Export -**** MathJax -#+begin_src emacs-lisp - (setq org-html-mathjax-template - " - ") -#+end_src - -**** Export with css class instead of inline css -#+begin_src emacs-lisp - (setq org-html-htmlize-output-type 'css) -#+end_src - -**** TODO MP4 movies -#+begin_src emacs-lisp :tangle no - (setq org-html-html5-fancy t) - (setq org-html-doctype "xhtml-strict") -#+end_src - -** Org LaTeX -*** Org CdLatex -https://orgmode.org/manual/CDLaTeX-mode.html#CDLaTeX-mode -#+begin_src emacs-lisp - (push "~/.config/doom/local/" load-path) - (require 'cdlatex) - (add-hook 'org-mode-hook 'turn-on-org-cdlatex) -#+end_src - -*** LaTeX Classes -#+begin_src emacs-lisp - ;; Custom classes to use when exporting to latex - (add-to-list 'org-latex-classes - `("beamer" - ,(concat "\\documentclass[presentation]{beamer}\n" - "[DEFAULT-PACKAGES]" - "[PACKAGES]" - "[EXTRA]\n") - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) - (add-to-list 'org-latex-classes - '("clean-cheatsheet" - "\\documentclass{clean-cheatsheet}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) - ) - (add-to-list 'org-latex-classes - '("clean-beamer" - "\\documentclass{clean-beamer}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) - ) - (add-to-list 'org-latex-classes - '("cleanreport" - "\\documentclass{cleanreport}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) - ) - (add-to-list 'org-latex-classes - '("scrreprt" - "\\documentclass{scrreprt}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) - ) - (add-to-list 'org-latex-classes - '("biblioreport" - "\\documentclass{biblioreport}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) - ) -#+end_src - -*** Basic -#+begin_src emacs-lisp - ;; Add packages by default - (add-to-list 'org-latex-packages-alist '("" "siunitx" t)) - (add-to-list 'org-latex-packages-alist '("" "array" t)) - (add-to-list 'org-latex-packages-alist '("" "tabularx" t)) - (add-to-list 'org-latex-packages-alist '("" "booktabs" t)) - (add-to-list 'org-latex-packages-alist '("" "bm" t)) - (add-to-list 'org-latex-packages-alist '("most" "tcolorbox" t)) - - ;; Setup default option for image size when exporting to LaTeX - (setq org-latex-image-default-option "scale=1") - (setq org-latex-image-default-width nil) - - ;; Use define labels instead of automatic generated ones - (setq org-latex-prefer-user-labels t) - - ;; Captions above the table - (setq org-latex-caption-above '(table)) - - ;; Settings to export code with `minted' instead of `verbatim'. - (setq org-latex-listings 'minted) - - ;; Command used when exporting to pdf - (setq org-latex-pdf-process - '("latexmk -cd -pdflatex=\"pdflatex -synctex=1 -shell-escape -interaction nonstopmode -output-directory %o\" -pdf -bibtex -f %f")) -#+end_src - -*** Beamer -Bold Text -#+begin_src emacs-lisp - (defun tdh/my-beamer-bold (contents backend info) - (when (eq backend 'beamer) - (replace-regexp-in-string - (concat "\\`\\\\" "[A-Za-z0-9]+") ;; If not, orgmode is crazy... - "\\\\textbf" - contents))) - - (add-to-list 'org-export-filter-bold-functions 'tdh/my-beamer-bold) -#+end_src - - -Special Environments -- [ ] Make some comment those special environments -#+begin_src emacs-lisp - (add-to-list 'org-beamer-environments-extra - '("cbox" ;; Name of environment - "m" ;; Selection key - "\\onslide%a{\\begin{cbox}[%h]%O" - "\\end{cbox}}\\vspace{0.5em}")) - (add-to-list 'org-beamer-environments-extra - '("csubbox" ;; Name of environment - "M" ;; Selection key - "\\onslide%a{\\tcbsubtitle{%h}" - "}")) -#+end_src - -*** TODO Latex Fragments -- [ ] The remove hook does not seems to work -http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/ - -#+begin_src emacs-lisp - (map! :map org-mode-map - ;; Activate Automatic LaTeX fragment - :n ",ol" '(lambda () (interactive) (add-hook 'post-command-hook 'tdh/org-latex-fragment-toggle t)) - ;; ;; Disable Automatic LaTeX fragment - :n ",oL" '(lambda () (interactive) (remove-hook 'post-command-hook 'tdh/org-latex-fragment-toggle))) - -;; Use F9 to globally generate all the latex fragments - (map! :map org-mode-map :n "" (lambda () (interactive) (org-preview-latex-fragment 16))) - - ;; Put all the preview images in some directory - (setq org-preview-latex-image-directory "~/.ltximg/") - - ;; Define backends to preview LaTeX fragments - (setq org-preview-latex-process-alist '((imagemagick - :programs ("latex" "convert") - :description "pdf > png" - :message "you need to install the programs: latex and imagemagick." - :image-input-type "pdf" - :image-output-type "png" - :image-size-adjust (0.6 . 0.6) - :latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f") - :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")) - (pdf2svg - :programs ("latex" "pdf2svg") - :description "pdf > svg" - :message "you need to install the programs: pdflatex and pdf2svg." - :image-input-type "pdf" - :image-output-type "svg" - :image-size-adjust (1.0 . 1.0) - :latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f") - :image-converter ("pdfcrop %f %f && pdftocairo -svg %f %O")) - ;; :image-converter ("pdf2svg %f %O")) - (dvisvgm - :programs ("latex" "dvisvgm") - :description "dvi > svg" - :message "you need to install the programs: latex and dvisvgm." - :image-input-type "dvi" - :image-output-type "svg" - :image-size-adjust (0.8 . 0.8) - :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") - :image-converter ("dvisvgm %f -n -b min -c %S -o %O")) - )) - - ;; Use imagemagick/dvisvgm to generate png from pdf - (setq org-preview-latex-default-process 'dvisvgm) -#+end_src - -*** TODO Custom Export - Add Page and Label for LaTeX export -https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbitrary-org-property-into-an-arbitrary-string-na?rq=1 - -#+begin_src emacs-lisp :tangle no - (defcustom tdehaeze/org-property-mapping - '((latex ("CUSTOM_PAGE" . tdehaeze/insert-org-page-latex) - ("CUSTOM_LABEL" . tdehaeze/insert-org-label-latex))) - "List of mappings from org property to arbitrary strings. - Each element is a list: - (BACKEND (PROPERTY1 . FUNCTION1) (PROPERTY2 . FUNCTION2) ...) - FUNCTION are functions which get called with a single - argument (the value of PROPERTY) and are responsible for doing - whatever should be done." - :type '(repeat (cons symbol (repeat (cons string string))))) -#+end_src - -#+begin_src emacs-lisp :tangle no - (defun tdehaeze/replace-org-property (backend) - "Convert org properties using `tdehaeze/org-property-mapping'. - Lookup BACKEND in `tdehaeze/org-property-mapping' for a list of - (PROPERTY REPLACEMENT). For each healine being exported, if it has a - PROPERTY listed insert a string immediately after the healine given by - (format REPLACEMENT PROPERTY-VALUE)" - (let ((map (cdr (assoc backend tdehaeze/org-property-mapping))) - value replacement) - (when map - (org-map-entries - (lambda () - (dolist (it map) - (save-excursion - (when (setq value (org-entry-get (point) (car it))) - (funcall (cdr it) value))))))))) - - (add-hook 'org-export-before-processing-hook #'tdehaeze/replace-org-property) -#+end_src - -#+begin_src emacs-lisp :tangle no - (defun tdehaeze/insert-org-label-latex (label) - "Insert \"\\\\label{LABEL}\\n\" after the :PROPERTY: drawer." - (search-forward-regexp org-property-end-re) - (forward-char 1) - (insert (format "\\label{%s}\n" label))) - (defun tdehaeze/insert-org-page-latex (page) - "Insert \"\\\\page{PAGE}\\n\" after the :PROPERTY: drawer." - (search-forward-regexp org-property-end-re) - (forward-char 1) - (insert (format "\\page{%s}\n" page))) -#+end_src - -#+begin_src emacs-lisp :tangle no - (defun org-latex-format-headline-default-function (todo _todo-type priority text tags _info) - "Default format function for a headline. - See `org-latex-format-headline-function' for details." - (concat - (and todo (format "{\\bfseries\\sffamily %s} " todo)) - (and priority (format "\\framebox{\\#%c} " priority)) - text - (and tags - (format "\\hfill{}\\textsc{%s}" - (mapconcat #'org-latex--protect-text tags ":"))) - (and todo (format "{\n\\page{%s} " todo))) -#+end_src - -*** Number Equations -#+begin_src emacs-lisp - (defun org-renumber-environment (orig-func &rest args) - "A function to inject numbers in LaTeX fragment previews." - (let ((results '()) - (counter -1) - (numberp)) - - (setq results (loop for (begin . env) in - (org-element-map (org-element-parse-buffer) 'latex-environment - (lambda (env) - (cons - (org-element-property :begin env) - (org-element-property :value env)))) - collect - (cond - ((and (string-match "\\\\begin{equation}" env) - (not (string-match "\\\\tag{" env))) - (incf counter) - (cons begin counter)) - ((string-match "\\\\begin{align}" env) - (prog2 - (incf counter) - (cons begin counter) - (with-temp-buffer - (insert env) - (goto-char (point-min)) - ;; \\ is used for a new line. Each one leads to a number - (incf counter (count-matches "\\\\$")) - ;; unless there are nonumbers. - (goto-char (point-min)) - (decf counter (count-matches "\\nonumber"))))) - (t - (cons begin nil))))) - - (when (setq numberp (cdr (assoc (point) results))) - (setf (car args) - (concat - (format "\\setcounter{equation}{%s}\n" numberp) - (car args))))) - - (apply orig-func args)) - - (advice-add 'org-create-formula-image :around #'org-renumber-environment) -#+end_src - -** TODO [#A] View PDF in org mode -#+begin_src emacs-lisp :tangle no -(defun tdh/org-include-img-from-pdf (&rest _) - "Convert pdf files to image files in org-mode bracket links. - # ()convertfrompdf:t # This is a special comment; tells that the upcoming - # link points to the to-be-converted-to file. - # If you have a foo.pdf that you need to convert to foo.png, use the - # foo.png file name in the link. - [[./foo.png]] -" - (interactive) - (if (executable-find "convert") - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^[ \t]*#\\s-+()convertfrompdf\\s-*:\\s-*t" - nil :noerror) - ;; Keep on going to the next line till it finds a line with bracketed - ;; file link. - (while (progn - (forward-line 1) - (not (looking-at org-bracket-link-regexp)))) - ;; Get the sub-group 1 match, the link, from `org-bracket-link-regexp' - (let ((link (match-string-no-properties 1))) - (when (stringp link) - (let* ((imgfile (expand-file-name (file-name-sans-extension link))) - (pdffile (expand-file-name - (concat imgfile - "." "pdf"))) - (cmd (concat "pdftocairo -png -transp -singlefile " - pdffile " " imgfile))) - - (message "%s" imgfile) - (when (and (file-readable-p pdffile) - (file-newer-than-file-p pdffile imgfile)) - ;; This block is executed only if pdffile is newer than - ;; imgfile or if imgfile does not exist. - (shell-command cmd) - (message "%s" cmd))))))) - (user-error "`convert' executable (part of Imagemagick) is not found"))) - (add-hook 'org-export-before-processing-hook #'tdh/org-include-img-from-pdf) -#+end_src - -#+begin_src emacs-lisp :tangle no - (add-to-list 'image-type-file-name-regexps '("\\.pdf\\'" . imagemagick)) - (add-to-list 'image-file-name-extensions "pdf") - (setq imagemagick-types-inhibit (remove 'PDF imagemagick-types-inhibit)) - (setq org-image-actual-width 600) -#+end_src - -#+begin_src emacs-lisp :tangle no - (defun my-latex-filter-nobreaks (text backend info) - "Ensure \" \" are properly handled in LaTeX export." - (when (org-export-derived-backend-p backend 'latex) - (replace-regexp-in-string " " "~" text))) - - (add-to-list 'org-export-filter-plain-text-functions - 'my-latex-filter-nobreaks) -#+end_src - -#+begin_src emacs-lisp :tangle no -(setq image-file-name-extensions - (quote - ("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg" "pdf" "bmp"))) - -(setq org-image-actual-width 600) - -(setq org-imagemagick-display-command "convert -density 600 \"%s\" -thumbnail \"%sx%s>\" \"%s\"") -(defun org-display-inline-images (&optional include-linked refresh beg end) - "Display inline images. -Normally only links without a description part are inlined, because this -is how it will work for export. When INCLUDE-LINKED is set, also links -with a description part will be inlined. This -can be nice for a quick -look at those images, but it does not reflect what exported files will look -like. -When REFRESH is set, refresh existing images between BEG and END. -This will create new image displays only if necessary. -BEG and END default to the buffer boundaries." - (interactive "P") - (unless refresh - (org-remove-inline-images) - (if (fboundp 'clear-image-cache) (clear-image-cache))) - (save-excursion - (save-restriction - (widen) - (setq beg (or beg (point-min)) end (or end (point-max))) - (goto-char beg) - (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?" - (substring (org-image-file-name-regexp) 0 -2) - "\\)\\]" (if include-linked "" "\\]"))) - old file ov img) - (while (re-search-forward re end t) - (setq old (get-char-property-and-overlay (match-beginning 1) - 'org-image-overlay) - file (expand-file-name - (concat (or (match-string 3) "") (match-string 4)))) - (when (file-exists-p file) - (let ((file-thumb (format "%s%s_thumb.png" (file-name-directory file) (file-name-base file)))) - (if (file-exists-p file-thumb) - (let ((thumb-time (nth 5 (file-attributes file-thumb 'string))) - (file-time (nth 5 (file-attributes file 'string)))) - (if (time-less-p thumb-time file-time) - (shell-command (format org-imagemagick-display-command - file org-image-actual-width org-image-actual-width file-thumb) nil nil))) - (shell-command (format org-imagemagick-display-command - file org-image-actual-width org-image-actual-width file-thumb) nil nil)) - (if (and (car-safe old) refresh) - (image-refresh (overlay-get (cdr old) 'display)) - (setq img (save-match-data (create-image file-thumb))) - (when img - (setq ov (make-overlay (match-beginning 0) (match-end 0))) - (overlay-put ov 'display img) - (overlay-put ov 'face 'default) - (overlay-put ov 'org-image-overlay t) - (overlay-put ov 'modification-hooks - (list 'org-display-inline-remove-overlay)) - (push ov org-inline-image-overlays)))))))))) -#+end_src - -Two options: -- work with =.png= file extension and only replace with =.pdf= when exporting to LaTeX if the corresponding file exists -- work with =.pdf= file, add a special function to display =.pdf= files (using =convert= or =pdftocairo=). Change to =.png= when exporting to html - -Let's try the first solution. - -#+begin_src emacs-lisp :tangle no -(defun tdh/change-png-to-pdf (text backend info) - "Change png images to pdf images when existing" - (when (org-export-derived-backend-p backend 'latex) - (let ((text (replace-regexp-in-string "[^\\w]\\(:\\)[^\n\t\r]+\\(:\\)[^\\w]" "" text nil nil 1 nil))) - (replace-regexp-in-string "[^\\w]\\(\\)[^\n\t\r]+\\(:\\)[^\\w]" "" text nil nil 2 nil)))) - -(add-to-list 'org-export-filter-plain-text-fucntions 'my-html-mark-tag) -#+end_src - -#+begin_src emacs-lisp :tangle no -(save-excursion - (goto-char (point-min)) - (while (re-search-forward "^[ \t]*#\\s-+()convertfrompdf\\s-*:\\s-*t" - nil :noerror) - ;; Keep on going to the next line till it finds a line with bracketed - ;; file link. - (while (progn - (forward-line 1) - (not (looking-at org-bracket-link-regexp)))) - ;; Get the sub-group 1 match, the link, from `org-bracket-link-regexp' - (let ((link (match-string-no-properties 1))) - (when (stringp link) - (let* ((imgfile (expand-file-name link)) - (pdffile (expand-file-name - (concat (file-name-sans-extension imgfile) - "." "pdf"))) - (cmd (concat "convert -density 96 -quality 85 " - pdffile " " imgfile))) - (when (and (file-readable-p pdffile) - (file-newer-than-file-p pdffile imgfile)) - ;; This block is executed only if pdffile is newer than - ;; imgfile or if imgfile does not exist. - (shell-command cmd) - (message "%s" cmd))))))) -#+end_src - -** Org Ref -Ressources: -- https://github.com/tmalsburg/helm-bibtex -- https://github.com/jkitchin/org-ref -- https://www.reddit.com/r/emacs/comments/4gudyw/help_me_with_my_orgmode_workflow_for_notetaking/ - -#+begin_src emacs-lisp - ;; Folder where the notes files are located (or file if just one Note file) - (setq org-ref-notes-directory "~/Cloud/thesis/ressources/notes") - (setq org-ref-bibliography-notes "~/Cloud/thesis/ressources/notes") - - ;; Bibliography File - (setq reftex-default-bibliography '("~/Cloud/thesis/ressources/references.bib")) - (setq org-ref-default-bibliography '("~/Cloud/thesis/ressources/references.bib")) - - ;; Folder where all the pdf are located - (setq org-ref-pdf-directory "~/Cloud/thesis/ressources/pdfs") - - ;; Tell org-ref to let helm-bibtex find notes for it - (setq org-ref-notes-function - (lambda (thekey) - (let ((bibtex-completion-bibliography (org-ref-find-bibliography))) - (bibtex-completion-edit-notes - (list (car (org-ref-get-bibtex-key-and-file thekey))))))) - - ;; Problem with speed: don't display broken links - (setq org-ref-show-broken-links nil) - ;; Display information on the citation - (setq org-ref-show-citation-on-enter t) -#+end_src - -** Org Noter -- https://github.com/weirdNox/org-noter - -#+begin_src emacs-lisp - (setq org-noter-always-create-frame nil) - (setq org-noter-kill-frame-at-session-end nil) - ;; Fraction of the frame that the document window will occupy when split - (setq org-noter-doc-split-fraction '(0.6 . 0.6)) - ;; Save the last visited location automatically; when starting a new session, go to that location - (setq org-noter-auto-save-last-location t) - ;; Add an empty line between each note's heading and content - (setq org-noter-separate-notes-from-heading t) - ;; List of paths to check (non recursively) when searching for a notes file - (setq org-noter-notes-search-path "~/Cloud/thesis/ressources/notes") -#+end_src - -** Custom key bindings -Export to LaTeX -#+begin_src emacs-lisp - (map! :map org-mode-map :n ",l" 'org-latex-export-to-latex) -#+end_src - -Open pdf externally. -#+begin_src emacs-lisp - (defun tdh/open-org-pdf-externally () - (interactive) - (call-process "xdg-open" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".pdf")) - ) - - (map! :map org-mode-map :n ",vp" 'tdh/open-org-pdf-externally) -#+end_src - -Open HTML externally. -#+begin_src emacs-lisp - (defun tdh/open-org-html-externally () - (interactive) - (call-process "xdg-open" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".html")) - ) - - (map! :map org-mode-map :n ",vh" 'tdh/open-org-html-externally) -#+end_src - -** TODO Org-Contacts -#+begin_src emacs-lisp :tangle no - (setq org-contacts-files (list "~/Cloud/org/contacts.org")) -#+end_src - -** TODO Org-Wunderlist -#+begin_src emacs-lisp :tangle no - (setq org-wunderlist-client-id "6799d9caeb2f5d8bd641" - org-wunderlist-token "fd5965cde436c2587850a7c517d366561d8a1cbf7b6d96ab62f3fc8c9930" - org-wunderlist-file "~/Cloud/thesis/todos/wunderlist.org" - org-wunderlist-dir "~/.emacs.d/org-wunderlist/") -#+end_src - -** Automatically run =startblock= when opening org-mode files -#+begin_src emacs-lisp - (defun tdh/eval-startblock () - (if (member "startblock" (org-babel-src-block-names)) - (save-excursion - (org-babel-goto-named-src-block "startblock") - (org-babel-execute-src-block)) - nil - ) - ) - - (add-hook 'org-mode-hook 'tdh/eval-startblock) -#+end_src - -** TODO Insert ScreenShot or Picture from Phone -http://pragmaticemacs.com/emacs/a-workflow-to-quickly-add-photos-to-org-mode-notes/ - -- [ ] One function to move file from =~/Picture/= folder (where the screenshots are taken) to current directory and then insert and org link to the picture. Maybe ask if it should be copied in a sub directory (figs folder for instance). -- [ ] One function to copy file from =~/Cloud/Photos/= folder (where the pictures from phone are taken) to current directory (and ask for the new name of the picture) and insert org link. - -#+begin_src emacs-lisp :tangle no - ;; required libraries - (require 'dash) - ;; (require 'swiper) - (require 's) - - ;; start directory - (defvar tdh/image-dir (expand-file-name "/home/thomas/Pictures")) - - (defun tdh/insert-conference-image () - "Insert image from conference directory, rename and add link in current file. - - The file is taken from a start directory set by `tdh/image-dir' and moved to the current directory, renamed and embedded at the point as an org-mode link. The user is presented with a list of files in the start directory, from which to select the file to move, sorted by most recent first." - (interactive) - (let (file-list target-dir file-list-sorted start-file start-file-full file-ext end-file end-file-base end-file-full file-number) - ;; Clean directories from list but keep times - (setq file-list - (-remove (lambda (x) (nth 1 x)) - (directory-files-and-attributes tdh/image-dir))) - - ;; Get target directory - (setq target-dir (file-name-directory (buffer-file-name))) - - ;; Sort list by most recent - (setq file-list-sorted - (mapcar #'car - (sort file-list - #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))) - - ;; Use ivy to select start-file - (setq start-file (ivy-read - (concat "Move selected file to " target-dir ":") - file-list-sorted - :re-builder #'ivy--regex - :sort nil - :initial-input nil)) - - ;; add full path to start file and end-file - (setq start-file-full - (expand-file-name start-file tdh/image-dir)) - - ;; final file name including path - (setq end-file-full - (expand-file-name start-file target-dir)) - - ;; rename file - (rename-file start-file-full end-file-full) - (message "moved %s to %s" start-file-full start-file) - - ;; insert link - (insert (org-make-link-string (format "file:%s" start-file))) - - ;; display image - (org-display-inline-images t t))) -#+end_src - -** TODO [#B] Render Tables -https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_chapter_2_it/ - -#+begin_src emacs-lisp - (defun my-render-org-table-at-point () - (interactive) - (save-excursion - (beginning-of-line) - ;; removes the overlay is already there - (if (overlays-at (point)) - (delete-overlay (car (overlays-at (point)))) - - (let* ((element-type (org-element-type (org-element-at-point)))) - (if (and (not (eq element-type 'table)) - (not (eq element-type 'table-row))) - (error "not at an org table") - - (while (not (eq 'table (org-element-type (org-element-at-point)))) - (forward-line -1)) - (my-render-org-table (org-element-at-point)) - ))))) - - - (defun my-render-org-table (table) - (interactive) - (let* ((begin (org-element-property :begin table)) - (end (let ((pos (org-element-property :end table))) - (goto-char pos) - (beginning-of-line) - ;; skip possible space after table - (while (not (looking-at " *[|#]")) - (setq pos (point)) - (forward-line -1)) - pos)) - (tabletxt (buffer-substring-no-properties begin end)) - (img (with-temp-buffer - (insert tabletxt) - (mark-whole-buffer) - (org-latex-convert-region-to-latex) - (org-latex-preview) - (goto-char (point-min)) - (overlay-get (car (overlays-at (point))) 'display))) - (overlay (make-overlay begin end))) - (overlay-put overlay 'display img) - (forward-line -1)) - ) - - - (defun my-render-org-tables-in-buffer () - (save-excursion - (org-element-map (org-element-parse-buffer) 'table 'my-render-org-table))) - - ;; Use F9 to globally generate tables - (map! :map org-mode-map :n "" (lambda () (interactive) (my-render-org-table-at-point))) -#+end_src - -** Org Gcal -- https://cestlaz.github.io/posts/using-emacs-26-gcal/#.WIqBud9vGAk - -#+begin_src emacs-lisp - (setq org-gcal-client-id "396102378658-dcmbcmrnthbe925519otsjbd921otq0v.apps.googleusercontent.com" - org-gcal-client-secret "4M5PWrbhQjwYEMXGK85lDYX9" - org-gcal-file-alist '(("dehaeze.thomas@gmail.com" . "~/Cloud/org/gcal.org") - ("8kjmhe2ar0abnm054ill1fb0gc@group.calendar.google.com" . "~/Cloud/org/gcal_phd.org"))) - ;; Automatic fetch of the new events - (add-hook 'org-agenda-mode-hook (lambda () (org-gcal-fetch) )) -#+end_src - -* Org Babel -** Main configuration -#+begin_src emacs-lisp - ;; Don't ask for confirmation when evalutating latex blocs - (defun my-org-confirm-babel-evaluate (lang body) - (not (member lang '("emacs-lisp" "latex" "matlab" "sh")))) - (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) -#+end_src - -#+begin_src emacs-lisp - ;; Use the current window for C-c ' source editing - (setq org-src-window-setup 'current-window) -#+end_src - -** Special Shortcuts -https://emacs.stackexchange.com/questions/13869/how-to-toggle-org-mode-source-code-block-eval-no-status - -Remap =ctrl-ret= to execute the source block and go to the next source block -when inside a source block. Otherwise, keep the normal behavior for ctrl-ent. - -#+begin_src emacs-lisp - (defun tdh/ctrl-ret () - (interactive) - (defun in-src-block-p () - "Returns t when the point is inside a source code block" - (string= "src" (org-in-block-p '("src")))) - - (defun in-src-block-function () - "Function to do when inside the src block" - (progn - (org-babel-execute-src-block) - (org-babel-next-src-block))) - - (if (in-src-block-p) - (in-src-block-function) - (+org--insert-item 'below))) - - (map! :map evil-org-mode-map - :n "" #'tdh/ctrl-ret) -#+end_src - -#+begin_src emacs-lisp - ;; (evil-define-minor-mode-key 'normal 'org-src-mode "q" 'org-edit-src-exit) -#+end_src - -Remap =C-c C-c=: -https://emacs.stackexchange.com/questions/22430/rebind-org-babel-execute-src-block-maybe-to-c-c-c-c/22530#22530 - -** Library of Babel -Add all named source blocks to =org-babel-library-of-babel=. - -#+begin_src emacs-lisp - (org-babel-lob-ingest "~/Cloud/thesis/org-mode/org-babel-tutorial/org-babel-library.org") -#+end_src - -** Org-Babel Matlab -#+begin_src emacs-lisp - (setq org-babel-matlab-shell-command "/home/thomas/bin/matlab -nodesktop -nosplash") - - (setq org-babel-matlab-emacs-link-wrapper-method - "%s - if ischar(ans); - echo('test'); - fid = fopen('%s', 'w'); - fprintf(fid, '%s', ans); - fclose(fid); - else; - save -ascii %s ans; - end - delete('%s'); - ") -#+end_src - -** Default options for Matlab code -#+begin_src emacs-lisp - (setq org-babel-default-header-args:matlab - '((:results . "none") - (:session . "*MATLAB*") - (:comments . "org") - (:exports . "both") - (:cache . "no") - (:noweb . "no") - (:hlines . "no") - (:tangle . "no") - (:mkdir . "yes") - (:eval . "no-export"))) -#+end_src - -** TODO Asynchronous execution -#+begin_src emacs-lisp - ;; (push "~/.emacs.d/private/ob-session-async/lisp/" load-path) - ;; (require 'ob-session-async) -#+end_src - -#+begin_src emacs-lisp - ;; (with-eval-after-load "ob" - ;; (require 'org-babel-eval-in-repl)) -#+end_src - -#+begin_src emacs-lisp - ;; (with-eval-after-load "eval-in-repl" - ;; (setq eir-jump-after-eval nil)) -#+end_src - -** TODO Theme -#+begin_src emacs-lisp - ;; (after! org - ;; (require 'color) - ;; (set-face-attribute 'org-block nil :background (color-darken-name (face-attribute 'default :background) 3)) - ;; ) -#+end_src - -** Indentation -#+begin_src emacs-lisp - (setq org-edit-src-content-indentation 2 - org-src-tab-acts-natively nil - org-src-preserve-indentation nil) -#+end_src - -** Some functions for using Matlab with Org Babel -*** =whos= matlab function -#+begin_src emacs-lisp - (defun tdh/matlab-whos (&optional start end) - "Get what is in the Matlab workspace" - (interactive) - (if (use-region-p) - (let ((regionp (buffer-substring (region-beginning) (region-end)))) - (process-send-string "*MATLAB*" (concat "whosEmacs " regionp "\n"))) - (process-send-string "*MATLAB*" (concat "whosEmacs" "\n")))) -#+end_src - -*** =help= matlab function -#+begin_src emacs-lisp - (defun tdh/matlab-help (start end) - "Get help on the selected function" - (interactive "r") - (let ((regionp (buffer-substring start end))) - (process-send-string "*MATLAB*" (concat "help " regionp "\n")))) -#+end_src - -*** Execute selected text -#+begin_src emacs-lisp - (defun tdh/matlab-execute-selected (start end) - "Execute selected text in the *MATLAB* buffer" - (interactive "r") - (let ((regionp (buffer-substring start end))) - (process-send-string "*MATLAB*" regionp))) -#+end_src - -*** Specify a Matlab command to run -#+begin_src emacs-lisp -(defun tdh/matlab-run-command () - "Prompt user to enter a matlab command" - (interactive) - (process-send-string "*MATLAB*" (concat (read-string "Matlab Command: ") "\n"))) -#+end_src - -*** Execute the current source block with no output -#+begin_src emacs-lisp - (defun tdh/org-babel-execute (&optional arg info params) - (interactive) - (let* ((org-babel-current-src-block-location - (or org-babel-current-src-block-location - (nth 5 info) - (org-babel-where-is-src-block-head))) - (info (if info (copy-tree info) (org-babel-get-src-block-info)))) - ;; Merge PARAMS with INFO before considering source block - ;; evaluation since both could disagree. - (cl-callf org-babel-merge-params (nth 2 info) params) - (when (org-babel-check-evaluate info) - (cl-callf org-babel-process-params (nth 2 info)) - (let* ((params (nth 2 info)) - (cache (let ((c (cdr (assq :cache params)))) - (and (not arg) c (string= "yes" c)))) - (new-hash (and cache (org-babel-sha1-hash info :eval))) - (old-hash (and cache (org-babel-current-result-hash))) - (current-cache (and new-hash (equal new-hash old-hash)))) - (cond - (current-cache - (save-excursion ;Return cached result. - (goto-char (org-babel-where-is-src-block-result nil info)) - (forward-line) - (skip-chars-forward " \t") - (let ((result (org-babel-read-result))) - (message (replace-regexp-in-string "%" "%%" (format "%S" result))) - result))) - ((org-babel-confirm-evaluate info) - (let* ((lang (nth 0 info)) - (result-params (cdr (assq :result-params params))) - ;; Expand noweb references in BODY and remove any - ;; coderef. - (body - (let ((coderef (nth 6 info)) - (expand - (if (org-babel-noweb-p params :eval) - (org-babel-expand-noweb-references info) - (nth 1 info)))) - (if (not coderef) expand - (replace-regexp-in-string - (org-src-coderef-regexp coderef) "" expand nil nil 1)))) - (dir (cdr (assq :dir params))) - (mkdirp (cdr (assq :mkdirp params))) - (default-directory - (cond - ((not dir) default-directory) - ((member mkdirp '("no" "nil" nil)) - (file-name-as-directory (expand-file-name dir))) - (t - (let ((d (file-name-as-directory (expand-file-name dir)))) - (make-directory d 'parents) - d)))) - (cmd (intern (concat "org-babel-execute:" lang))) - result) - ;; (message "%s" body) - (process-send-string "*MATLAB*" (concat body "\n")) - result)) - ))) - ) - ) -#+end_src - -*** Execute the source block and go to the next one -#+begin_src emacs-lisp - (defun tdh/org-babel-execute-goto-next (&optional arg info params) - (interactive) - (tdh/org-babel-execute arg info params) - (org-babel-next-src-block) - ) -#+end_src - -*** Org-Babel Tangle Subtree -#+begin_src emacs-lisp - (defun tdh/org-babel-tangle-subtree () - "Tangle the current subtree" - (interactive) - (progn - (org-narrow-to-subtree) - (org-babel-tangle) - (widen)) - ) -#+end_src - -#+begin_src emacs-lisp - (map! :map org-mode-map :n ",bT" 'tdh/org-babel-tangle-subtree) -#+end_src - -*** Org-Babel Jump to Tangle File -Actually this tangle the file and then go to the file. Maybe I would like to ignore the tangling phase. - -#+begin_src emacs-lisp -(defun tdh/org-babel-jump-to-tangle-file () - "Jump to tangle file for the source block at point." - (interactive) - (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook) - (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore) - (setq file filename))) - ((symbol-function 'delete-file) #'ignore)) - (org-babel-tangle '(4))) - (when file - (setq file (expand-file-name file)) - (if (file-readable-p file) - (find-file file) - (error "Cannot open tangle file %S" file))))) -#+end_src - -#+begin_src emacs-lisp - (map! :map org-mode-map :n ",bF" 'tdh/org-babel-jump-to-tangle-file) -#+end_src - -*** Org-Babel Tangle File and Execute -#+begin_src emacs-lisp -(defun tdh/org-babel-execute-tangle-file () - "Jump to tangle file for the source block at point." - (interactive) - (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook) - (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore) - (setq file filename))) - ((symbol-function 'delete-file) #'ignore)) - (org-babel-tangle '(4))) - (when file - (setq file (expand-file-name file)) - (if (file-readable-p file) - (process-send-string "*MATLAB*" (concat "run " file "\n")) - (error "Cannot open tangle file %S" file))))) -#+end_src - -* LaTeX -- https://tex.stackexchange.com/questions/52179/what-is-your-favorite-emacs-and-or-auctex-command-trick -- https://tex.stackexchange.com/questions/20843/useful-shortcuts-or-key-bindings-or-predefined-commands-for-emacsauctex - -** Basic LaTeX configuration -#+begin_src emacs-lisp - (defun latex/clean () - "Clean LaTeX output using latexmk" - (interactive) - (async-shell-command - ;; command and parameters - "latexmk -c " - (shell-quote-argument buffer-file-name) - " &" - )) - - (map! :map LaTeX-mode-map :n ",C" 'latex/clean) - - (add-hook 'TeX-mode-hook #'TeX-fold-mode) -#+end_src - -** Master file -#+begin_src emacs-lisp - (setq-default TeX-master nil) -#+end_src - -** Pdf Viewer -#+begin_src emacs-lisp - (setq TeX-view-program-selection '((output-pdf "Zathura"))) - (setq TeX-source-correlate-mode t) - (setq TeX-source-correlate-start-server t) - (setq TeX-source-correlate-method 'synctex) - (setq TeX-view-program-list - '(("PDF Tools" TeX-pdf-tools-sync-view))) -#+end_src - -* Helm-Bibtex -** General Config -#+begin_src emacs-lisp - ;; Use "tags" field when looking for bib entries - (setq helm-bibtex-additional-search-fields '(keywords)) - - ;; Display of bibtex entries with helm - (setq bibtex-completion-display-formats - '((t . "${author:36} ${title:*} ${year:4} ${=type=:7} ${=has-note=:1}"))) - - ;; Special symbols for notes and pdf - (setq bibtex-completion-pdf-symbol "⌘") - (setq bibtex-completion-notes-symbol "✎") - - ;; Bibliography file - (setq bibtex-completion-bibliography "~/Cloud/thesis/ressources/references.bib") - - ;; Directory with all the pdfs - (setq bibtex-completion-library-path "~/Cloud/thesis/ressources/pdfs") - - ;; Directory with notes files - (setq bibtex-completion-notes-path "~/Cloud/thesis/ressources/notes") - - ;; Template used when creating new Note file - (setq bibtex-completion-notes-template-multiple-files (concat "#+TITLE: ${title}\n" - ":DRAWER:\n" - "#+LATEX_CLASS: biblioreport\n" - "\n" - "#+OPTIONS: toc:nil title:nil\n" - "#+OPTIONS: ':t -:t\n" - "\n" - "#+LATEX_HEADER: \\newcommand{\\refType}{${=type=}}\n" - "#+LATEX_HEADER: \\newcommand{\\refKey}{${=key=}}\n" - "#+LATEX_HEADER: \\newcommand{\\refTitle}{${title}}\n" - "#+LATEX_HEADER: \\newcommand{\\refAuthor}{${author-or-editor}}\n" - "#+LATEX_HEADER: \\newcommand{\\refJournal}{${journal}}\n" - "#+LATEX_HEADER: \\newcommand{\\refYear}{${year}}\n" - "#+LATEX_HEADER: \\newcommand{\\refDoi}{${DOI}}\n" - "#+LATEX_HEADER: \\newcommand{\\refUrl}{${url}}\n" - "#+LATEX_HEADER: \\newcommand{\\refKeywords}{${keywords}}\n" - "#+LATEX_HEADER: \\input{config.tex}\n" - "#+LATEX_HEADER: \\graphicspath{{./figs/${=key=}/}}\n" - "# #+TOC: headlines 2\n" - ":END:\n" - "\n" - "#+BEGIN_abstract\n" - "\n" - "#+END_abstract\n" - "\n" - "* ${title} :ignore:\n" - ":PROPERTIES:\n" - ":CUSTOM_ID: ${=key=}\n" - ":AUTHOR: ${author}\n" - ":TYPE: ${=type=}\n" - ":JOURNAL: ${journal}\n" - ":YEAR: ${year}\n" - ":VOLUME: ${volume}\n" - ":PAGES: ${pages}\n" - ":DOI: ${DOI}\n" - ":URL: ${url}\n" - ":NOTER_DOCUMENT: ../pdfs/${=key=}.pdf\n" - ":END:\n" - "\n")) - - ;; Make "Edit notes" the default action - (after! helm-bibtex - (helm-delete-action-from-source "Edit notes" helm-source-bibtex) - (helm-add-action-to-source "Edit notes" 'helm-bibtex-edit-notes helm-source-bibtex 0) - ) -#+end_src - -** Open pdf externally -#+begin_src emacs-lisp - (defun tdehaeze/open-pdf-externally (key) - (call-process "zathura" nil 0 nil (nth 0 (-cons-to-list (bibtex-completion-find-pdf key))))) - - ;; Action to open the pdf with Zathura - (after! helm-bibtex - (helm-delete-action-from-source "Open PDF Externally" helm-source-bibtex) - (helm-add-action-to-source "Open PDF Externally" 'tdehaeze/open-pdf-externally helm-source-bibtex 1) - ) -#+end_src - -** Special Commands -#+begin_src emacs-lisp - (defun helm-bibtex-favorites (&optional arg) - "Search Favorite BibTeX entries" - (interactive "P") - (helm-bibtex arg nil "favorite ")) -#+end_src - -** List all element of the bibliography without pdf associated -#+begin_src emacs-lisp - (defun list-bib-without-pdf-associated () - (interactive) - (bibtex-completion-init) - (setq candidates (bibtex-completion-candidates)) - - (defun canditate-is-pdf-present (candidate) - (bibtex-completion-find-pdf-in-library (cdr (assoc "=key=" candidate))) - ) - - (setq candidates-without-pdf (remove-if #'canditate-is-pdf-present candidates)) - - (setq candidate-without-pdf-names (mapcar - (lambda (x) (cdr (assoc "title" x))) - candidates-without-pdf)) - - (with-output-to-temp-buffer "*bib-without-pdf*" (princ (string-join candidate-without-pdf-names "\n"))) - (switch-to-buffer-other-window "*bib-without-pdf*") - ) -#+end_src - -* TODO [#B] Matlab -- https://github.com/yuhonglin/matlab-mode -- https://github.com/pronobis/matlab-mode - -** Setup Matlab Mode -#+begin_src emacs-lisp - (setq matlab-shell-command "/home/thomas/bin/matlab") - (setq matlab-shell-command-switches (list "-nodesktop -nosplash")) - (setq mlint-programs '("mlint" "/home/thomas/bin/mlint")) -#+end_src - -** Setup Flycheck -#+begin_src emacs-lisp - (defvar mlint-executable "/home/thomas/bin/mlint") - - (flycheck-define-command-checker 'matlab-mlint - "A Matlab checker based on mlint." - :command `(,mlint-executable source) - :error-patterns - '((warning line-start "L " line " (C " (1+ digit) "): " (message) line-end)) - :modes '(matlab-mode)) - - (add-to-list 'flycheck-checkers 'matlab-mlint) - - ;; Automatic startup of flycheck for matlab - (add-hook 'matlab-mode-hook 'flycheck-mode) -#+end_src - -#+begin_src emacs-lisp :tangle no - (defadvice org-edit-src-code (around set-buffer-file-name activate compile) - (let ((file-name (buffer-file-name))) ;; (1) - ad-do-it ;; (2) - (setq buffer-file-name file-name))) ;; (3) -#+end_src - -** TODO Setup Company - not working -#+begin_src emacs-lisp - ;; (add-to-list 'company-backends 'company-matlab) -#+end_src - -** TODO Beautify code -#+begin_src emacs-lisp - (defun matlab-beautify-buffer () - "Beautify Current Buffer" - (interactive) - (save-buffer) - (matlab-shell-run-command (concat "MBeautify.formatFile(\"" (buffer-file-name) "\")")) - ) -#+end_src - -** Key Bindings -#+begin_src emacs-lisp - (defun matlab-add-breakpoint () - (interactive) - (matlab-shell-run-command (concat "dbstop in " (buffer-name) " at " (number-to-string (line-number-at-pos nil))))) - (defun matlab-remove-breakpoint () - (interactive) - (matlab-shell-run-command (concat "dbclear in " (buffer-name) " at " (number-to-string (line-number-at-pos nil))))) - (defun matlab-list-breakpoints () - (interactive) - (matlab-shell-run-command (concat "dbstatus " (buffer-name)))) - (defun matlab-clear-breakpoints () - (interactive) - (matlab-shell-run-command (concat "dbclear in " (buffer-name)))) - (defun matlab-go-to-file-directory () - (interactive) - (matlab-shell-run-command (concat "cd " (file-name-directory buffer-file-name)))) -#+end_src - -#+begin_src emacs-lisp - (map! :map matlab-mode-map - :n ",g" 'matlab-go-to-file-directory - :n ",da" 'matlab-add-breakpoint - :n ",dr" 'matlab-remove-breakpoint - :n ",dL" 'matlab-list-breakpoints - :n ",dc" 'matlab-clear-breakpoints - :n ",dl" 'gud-cont - :n ",ds" 'gud-step - :n ",dn" 'gud-next - :n ",dq" 'gud-finish) -#+end_src - -** Wrong highlight of comments -#+begin_src emacs-lisp :tangle no - (add-hook 'matlab-mode-hook - ;; `highlight-numbers-mode' breaks MATLAB comment coloring -- - ;; `highlight-numbers-mode' is mostly redundant with - ;; `rainbow-identifiers-mode' anyway - (lambda () - (highlight-numbers-mode -1)) - ;; We must append the above *after* `spacemacs/run-prog-mode-hooks' - ;; in `matlab-mode-hook', since the former hook enables - ;; `highlight-numbers-mode'. Note that - ;; `spacemacs/run-prog-mode-hooks' is manually added to - ;; `matlab-mode-hook' by Spacemacs since the upstream `matlab-mode' - ;; package does not derive `matlab-mode' from `prog-mode' (oddly -- - ;; IIRC the author refused to do so for compatibility with XEmacs). - 'append) -#+end_src - -* TODO [#B] Mails With Mu4e -:PROPERTIES: -:header-args:emacs-lisp+: :tangle no -:END: -- https://github.com/kzar/davemail -- http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/ -- http://spacemacs.org/layers/+email/mu4e/README.html -- http://www.djcbsoftware.nl/code/mu/mu4e/index.html#Top -- https://notanumber.io/2016-10-03/better-email-with-mu4e/ -- https://vxlabs.com/2017/02/07/mu4e-0-9-18-e-mailing-with-emacs-now-even-better/ -- http://www.brool.com/post/using-mu4e/ -- https://www.reddit.com/r/emacs/comments/8q84dl/tip_how_to_easily_manage_your_emails_with_mu4e/ -- https://vxlabs.com/2017/02/07/mu4e-0-9-18-e-mailing-with-emacs-now-even-better/ - -** Set default mail user agent to mu4e - #+begin_src emacs-lisp - (setq mail-user-agent 'mu4e-user-agent) - #+end_src - -** Default config -*** Default behavior -#+begin_src emacs-lisp - (setq mu4e-maildir "~/.mail" - mu4e-update-interval nil - mu4e-compose-signature-auto-include t - mu4e-view-show-images t - mu4e-view-show-addresses t) -#+end_src - -*** Default folders -#+begin_src emacs-lisp - (setq mu4e-sent-folder "/gmail/Sent" - mu4e-drafts-folder "/gmail/Drafts" - mu4e-trash-folder "/gmail/Trash" - mu4e-refile-folder "/gmail/Archive" - mu4e-compose-signature "Thomas Dehaeze\n" - user-mail-address "dehaeze.thomas@gmail.com") -#+end_src - -*** Default signature and email address -#+begin_src emacs-lisp - (setq mu4e-compose-signature "Thomas Dehaeze\n" - user-mail-address "dehaeze.thomas@gmail.com") -#+end_src - -*** Saving the attachment to Downloads directory -#+begin_src emacs-lisp - (setq mu4e-attachment-dir "~/Downloads") -#+end_src - -*** A list of user's e-mail addresses -#+begin_src emacs-lisp - (setq mu4e-user-mail-address-list '("dehaeze.thomas@gmail.com" "thomas.dehaeze@esrf.fr" "thomas.dehaeze@doct.ulg.ac.be")) -#+end_src - -*** Mail directory shortcuts -#+begin_src emacs-lisp - (setq mu4e-maildir-shortcuts - '( - ("/gmail/Inbox" . ?g) - ("/esrf/Inbox" . ?e) - ("/ulg/Inbox" . ?u) - )) -#+end_src - -** TODO Contexts - Email accounts -#+begin_src emacs-lisp :tangle no - (setq mu4e-contexts - `( ,(make-mu4e-context - :name "gmail" - :enter-func (lambda () (mu4e-message "Entering Gmail context")) - :leave-func (lambda () (mu4e-message "Leaving Gmail context")) - :match-func (lambda (msg) - (when msg - (string-match-p "^/gmail" (mu4e-message-field msg :maildir)))) - :vars '( - (mu4e-sent-messages-behavior . (delete)) - (user-mail-address . "dehaeze.thomas@gmail.com") - (mu4e-sent-folder . "/gmail/Sent") - (mu4e-trash-folder . "/gmail/Trash") - (mu4e-drafts-folder . "/gmail/Drafts") - (mu4e-refile-folder . "/gmail/Archive") - (mu4e-compose-signature . - (concat - "Thomas Dehaeze\n" - "\n")) - )) - ,(make-mu4e-context - :name "esrf" - :enter-func (lambda () (mu4e-message "Entering ESRF context")) - :leave-func (lambda () (mu4e-message "Leaving ESRF context")) - :match-func (lambda (msg) - (when msg - (string-match-p "^/esrf" (mu4e-message-field msg :maildir)))) - :vars '( - (user-mail-address . "thomas.dehaeze@esrf.fr") - (mu4e-sent-folder . "/esrf/Sent") - (mu4e-trash-folder . "/esrf/Trash") - (mu4e-drafts-folder . "/esrf/Drafts") - (mu4e-refile-folder . "/esrf/Archive") - (mu4e-compose-signature . - (concat - "Thomas Dehaeze\n" - "\n")) - )) - ,(make-mu4e-context - :name "ulg" - :enter-func (lambda () (mu4e-message "Entering ULG context")) - :leave-func (lambda () (mu4e-message "Leaving ULG context")) - :match-func (lambda (msg) - (when msg - (string-match-p "^/ulg" (mu4e-message-field msg :maildir)))) - :vars '( - (user-mail-address . "thomas.dehaeze@doct.ulg.ac.be") - (mu4e-sent-folder . "/ulg/Sent") - (mu4e-trash-folder . "/ulg/Trash") - (mu4e-drafts-folder . "/ulg/Drafts") - (mu4e-refile-folder . "/ulg/Archive") - (mu4e-compose-signature . - (concat - "Thomas Dehaeze\n" - "\n")) - )) - )) - (setq mu4e-context-policy 'pick-first) -#+end_src - -** Receiving emails - Mbsync -Let systemd get the mail, then pressing =U= will just run =mu= to reindex everything. -#+begin_src emacs-lisp - (setq mu4e-get-mail-command "true") -#+end_src - -Fix for mbsync found [[http://pragmaticemacs.com/emacs/fixing-duplicate-uid-errors-when-using-mbsync-and-mu4e/][here]]. -#+begin_src emacs-lisp - (setq mu4e-change-filenames-when-moving t) -#+end_src - -** Sending emails - Msmtp -#+begin_src emacs-lisp - (setq smtpmail-default-smtp-server "smtp.gmail.com" - smtpmail-smtp-server "smtp.gmail.com" - smtpmail-smtp-service 587) - - (setq message-send-mail-function 'message-send-mail-with-sendmail - sendmail-program "msmtp" - user-full-name "Thomas Dehaeze") -#+end_src - -** Bookmarks -#+begin_src emacs-lisp :tangle no - (setq mu4e-bookmarks - `(("flag:unread AND NOT flag:trashed" "Unread messages" ?u) - ("date:today..now" "Today's messages" ?t) - ("date:7d..now" "Last 7 days" ?w) - ("mime:image/*" "Messages with images" ?p) - (,(mapconcat 'identity - (mapcar - (lambda (maildir) - (concat "maildir:" (car maildir))) - mu4e-maildir-shortcuts) " OR ") - "All inboxes" ?i))) -#+end_src - -** TODO Notifications -#+begin_src emacs-lisp - (with-eval-after-load 'mu4e-alert - (mu4e-alert-set-default-style 'libnotify)) - (mu4e-alert-enable-notifications) -#+end_src - -Mode-line notifications -#+begin_src emacs-lisp - (setq mu4e-enable-mode-line t) -#+end_src - -** Use Org-Mode Tables In Emails -#+begin_src emacs-lisp - (add-hook 'message-mode-hook 'turn-on-orgtbl) - (add-hook 'message-mode-hook 'turn-on-orgstruct++) -#+end_src - -** TODO Integration with Org-Mode -Store link to message if in header view, not to header query -#+begin_src emacs-lisp - (setq org-mu4e-link-query-in-headers-mode nil) -#+end_src - -** TODO [#A] When putting something on the Trash, it will be in the archive folder on gmail -Even when totally deleting it. It will stay on gmail. How to fix that? - -** TODO Verify that sending mails with gmail account works and that there is no duplicate - -Should check this variable: mu4e-sent-messages-behavior -#+begin_src emacs-lisp :tangle no - (setq mu4e-sent-messages-behavior 'delete) -#+end_src - -And [[https://www.djcbsoftware.nl/code/mu/mu4e/Gmail-configuration.html][here]]. -If I put it to delete, it works for gmail but not for the other ones... -Check [[https://github.com/djcb/mu/issues/179][here]]. - -** TODO Cheatsheet -| Command | Usage | -|---------+-----------------------| -| =C-j= | Next mail | -| =C-k= | Previous mail | -| =R/C/F= | Reply/Compose/Forward | -| =t= | Move to Archive | -| =d= | Move to Trash | - -* PDF-Tools -#+begin_src emacs-lisp - (add-hook 'pdf-view-mode-hook (lambda() (linum-mode -1))) -#+end_src - -* Custom command and leader keys -** Watch LaTeX file using latexmk -#+begin_src emacs-lisp - (defun tdh/latex/watch () - "Watch LaTeX file using latexmk" - (interactive) - (start-process-shell-command "latexmk-watch" "*latexmk-watch-output*" - "latexmk" (format "-pdflatex=\"xelatex -synctex=1 -shell-escape -interaction nonstopmode -output-directory='%s'\" -pdf -pvc -bibtex -f %s.tex" - (file-name-directory buffer-file-name) - (file-name-base buffer-file-name)))) - (defun tdh/latex/watch/kill () - "Kill the currently running TeX job." - (interactive) - (delete-process "latexmk-watch") - ) - - (map! :map org-mode-map - :n ",ow" 'tdh/latex/watch - :n ",ok" 'tdh/latex/watch/kill) -#+end_src - -** Helm-Bibtex -#+begin_src emacs-lisp - (map! :map org-mode-map - :n ",ob" 'helm-bibtex - :n ",of" 'helm-bibtex-favorites - :n ",or" 'helm-resume) -#+end_src - -** Open terminal in current directory -#+begin_src emacs-lisp - (defun tdh/open-terminal-in-workdir () - (interactive) - (call-process-shell-command - (concat "termite --directory=" default-directory) nil 0)) - - (map! :map org-mode-map :n ",ot" 'tdh/open-terminal-in-workdir) -#+end_src - -** Open ranger in current directory -#+begin_src emacs-lisp - (defun open-ranger-in-workdir () - (interactive) - (call-process-shell-command - (concat "termite --directory=" default-directory " --exec=ranger") nil 0)) - - (map! :map org-mode-map :n ",oo" 'open-ranger-in-workdir) -#+end_src - -* Yassnippets -#+begin_src emacs-lisp - (push "~/.config/doom/snippets" yas-snippet-dirs) - (yas-global-mode 1) -#+end_src - -* Path for Shell -#+begin_src emacs-lisp - ;; (when (memq window-system '(mac ns x)) - ;; (exec-path-from-shell-initialize)) -#+end_src - -* Proxy -#+begin_src emacs-lisp :tangle no - (setq url-proxy-services - '(("http" . "proxy.esrf.fr:3128") - ("https" . "proxy.esrf.fr:3128") - ("no_proxy" . "^.*esrf.fr"))) -#+end_src - -* TODO [#B] Slack -:PROPERTIES: -:header-args:emacs-lisp+: :tangle no -:END: -#+begin_src emacs-lisp - (slack-register-team - :name "emacs-slack" - :default t - :client-id "299050134212.316863429523" - :client-secret "7168a660375090e517fe812ea2d136e5" - :token "xoxp-299050134212-299063259042-715794254097-7c319fdd63315620e86f1fad42c126a2" - :subscribed-channels '()) -#+end_src - -#+begin_src emacs-lisp - (advice-add 'slack-counts-update :override #'ignore) -#+end_src - -#+begin_src emacs-lisp - (setq slack-prefer-current-team t) -#+end_src - -* TODO [#C] Neomutt connection -https://mentat.za.net/blog/2018/10/31/using-org-mode-with-neomutt/ - -#+begin_src emacs-lisp - (require 'org-protocol) - ;; Call this function, which spawns neomutt, whenever org-mode - ;; tries to open a link of the form mutt:message-id+goes_here@mail.gmail.com - - (defun tdh/mutt-open-message (message-id) - "In neomutt, open the email with the the given Message-ID" - (let* - ((message-id (replace-regexp-in-string "^/*" "" message-id)) - (mail-file - (replace-regexp-in-string - "\n$" "" (shell-command-to-string - (format "mu find -n 1 -f l i:%s" message-id)))) - (mail-dir (replace-regexp-in-string "/\\(cur\\|new\\|tmp\\)/$" "" - (file-name-directory mail-file))) - (message-id-escaped (regexp-quote message-id)) - (mutt-keystrokes - (format "L~i %s\n\n" (shell-quote-argument message-id-escaped))) - (mutt-command (list "neomutt" "-R" "-f" mail-dir - "-e" (format "push '%s'" mutt-keystrokes)))) - - (message "Launching neomutt for message %s" message-id) - (call-process "setsid" nil nil - "-f" "termite" "-e" - (concat "neomutt -R -f " mail-dir " -e \"" (format "push '%s a l'\"" mutt-keystrokes))))) - - ;; Hook up `message:...` style URLs - (org-add-link-type "message" 'tdh/mutt-open-message) -#+end_src - -* Abbreviations -Type the abbreviation and use =C-x a -= to create a new abbreviation. - -#+begin_src emacs-lisp - (setq-default abbrev-mode t) - ;; save abbreviations upon exiting xemacs - (setq save-abbrevs t) - ;; set the file storing the abbreviations - (setq abbrev-file-name "~/.config/doom/my-abbreviations.el") - ;; reads the abbreviations file on startup - (quietly-read-abbrev-file) -#+end_src - -* Other -Here are some additional functions/macros that could help you configure Doom: - -- `load!' for loading external *.el files relative to this one -- `use-package' for configuring packages -- `after!' for running code after a package has loaded -- `add-load-path!' for adding directories to the `load-path', where Emacs - looks when you load packages with `require' or `use-package'. -- `map!' for binding new keys - -To get information about any of these functions/macros, move the cursor over -the highlighted symbol at press 'K' (non-evil users must press 'C-c g k'). -This will open documentation for it, including demos of how they are used. - -You can also try 'gd' (or 'C-c g d') to jump to their definition and see how -they are implemented. - -* Snippets -:PROPERTIES: -:header-args:conf+: :comments none -:header-args:conf+: :mkdirp yes -:END: -** LaTeX -*** Coordinate -#+begin_src conf :tangle ~/.config/doom/snippets/latex/coordinate -#contributor : Thomas Dehaeze -#name :coordinate -# -- -\coordinate[${1:->}] (${2:name}) at (${3:pointcoordinate}); -$0 -#+end_src - -*** Draw -#+begin_src conf :tangle ~/.config/doom/snippets/latex/draw -#contributor : Thomas Dehaeze -#name :draw -# -- -\draw[${1:->}] (${2:point1}) -- (${3:point2}); -$0 -#+end_src - -*** Node -#+begin_src conf :tangle ~/.config/doom/snippets/latex/node -#contributor : Thomas Dehaeze -#name :node -# -- -node[${1:below right}] (${2:name}) {${3:label}}; -$0 -#+end_src - -*** Path -#+begin_src conf :tangle ~/.config/doom/snippets/latex/path -#contributor : Thomas Dehaeze -#name :path -# -- -\path[${1}] (${2:point1}) -- (${3:point2}); -$0 -#+end_src - -** Matlab -*** Clear -#+begin_src conf :tangle ~/.config/doom/snippets/matlab/clear -#contributor : Thomas Dehaeze -#name :clear and close all -# -- -clear; close all; clc; -$0 -#+end_src - -*** Function -#+begin_src conf :tangle ~/.config/doom/snippets/matlab/function -#contributor : Thomas Dehaeze -#name :function -# -- -function [${4:outputs}] = ${1:functionName}(${2:inputs}, ${3:opts_param}) -% $1 - Description -% -% Syntax: $1($2, $3) -% -% Inputs: -% - $2 - -% - $3 - Optionals parameters: structure with the following fields: -% - -% -% Outputs: -% - $4 - - -%% Default value for opts -opts = struct(... - '${5:outputs}', ${6:default_value} ... -); - -if exist('opts_param','var') - for opt = fieldnames($3)' - if sum(strcmp(fieldnames(opts), opt{1})) == 1 - opts.(opt{1}) = $3.(opt{1}); - else - warning(sprintf('%s is not a valid option.', opt{1})); - end - end -end - -$0 -#+end_src - -** Org Mode -*** Begin -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/begin -#contributor : Thomas Dehaeze -#name :LaTeX Environment -# -- -\begin{${1:equation}} - $0 -\end{$1} -#+end_src - -*** Block -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/block -#contributor : Thomas Dehaeze -#name :Org-Mode Block -#key: block -# -- -,#+begin_${1:$$(let ((type (yas-choose-value '("src" "example" "quote" "verse" "center" "latex" "html" "ascii")))) - (if type (concat type (if (equal type "src") - (concat " " (yas-choose-value '("emacs-lisp" "latex" "python" "sh" "matlab")))))))} -$0 -#+end_${1:$(car (split-string yas-text))} -#+end_src - -*** Custom Box -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/cbox -#contributor : Thomas Dehaeze -#name :Custom Box -# -- -#+attr_latex: :options [$1]{${2:blue}}{${3:ams nodisplayskip}} -#+begin_cbox -$0 -#+end_cbox -#+end_src - -*** Latex Class -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/latex-class -#name: latex-class -#key: lc -#expand-env: ((classes (mapcar 'car org-latex-classes))) -# -- -#+latex_class: ${1:$$(yas-choose-value classes)} -$0 -#+end_src - -*** Name Caption Figure -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/name-caption-figure -#name: name-caption-figure -#key: ncf -# -- -#+name: fig:${1:name} -#+caption: ${2:Caption} -[[${3:`(read-file-name "File: ")`}]] - -$0 -#+end_src - -*** Bibliography with completion -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/bib -#name: bibliography with completion -#key: bib -# -- -bibliography:${1:$$(yas-choose-value (org-ref-find-bibliography))} -#+end_src - -*** Cite -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/cite -#name: org-ref cite link -#key: cite -# -- -cite:${1:$$(completing-read - "bibtex key: " - (let ((bibtex-files (org-ref-find-bibliography)))(bibtex-global-key-alist)))} -#+end_src - -*** Ref -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/ref -#name: org-ref ref link with completion -#key: ref -# -- -ref:${1:$$(completing-read "label: " (org-ref-get-labels))} -#+end_src - -*** Beamer - CBOX -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/bcbox -#contributor : Thomas Dehaeze -#name :Beamer Custom Box -# -- -,*** ${1:@@latex:@@} :B_cbox: -,:PROPERTIES: -:BEAMER_env: cbox -:BEAMER_opt: {${2:blue}}{${3:ams nodisplayskip}} -:END: - -$0 -#+end_src - -*** Code -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/code -#contributor : Thomas Dehaeze -#name :Code -# -- -#+caption: ${1:Listing Caption} -#+label: lst:${2:listing_name} -,#+begin_src ${3:listing_language} -$0 -,#+end_src -#+end_src - -*** Equation -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/equation -#contributor : Thomas Dehaeze -#name :Equation -# -- -#+name: eq:${1:equation_name} -\begin{equation} -$0 -\end{equation} -#+end_src - -*** Figure -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/figure -#contributor : Thomas Dehaeze -#name :Figure -# -- -#+name: fig:${1:figure_name} -#+caption: ${2:Figure caption} -#+attr_latex: :${3:scale 1} -[[file:${4:figs/}$1.${5:pdf}]] -$0 -#+end_src - -*** Frac -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/frac -#contributor : Thomas Dehaeze -#name :LaTeX Fraction -# -- -\frac{$1}{$2} $0 -#+end_src - -*** Left -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/left -#contributor : Thomas Dehaeze -#name :Left Right mathematical delimitations -# -- -\left$1 $0 \right$2 -#+end_src - -*** Mconfig -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mconfig -#contributor : Thomas Dehaeze -#name :Matlab-Configuration-Header -# -- -#+PROPERTY: header-args:matlab :session *MATLAB* -#+PROPERTY: header-args:matlab+ :tangle ${1:filename}.m -#+PROPERTY: header-args:matlab+ :comments org -#+PROPERTY: header-args:matlab+ :exports both -#+PROPERTY: header-args:matlab+ :results none -#+PROPERTY: header-args:matlab+ :eval no-export -#+PROPERTY: header-args:matlab+ :noweb yes -#+PROPERTY: header-args:matlab+ :mkdirp yes -#+PROPERTY: header-args:matlab+ :output-dir ${2:figs} -$0 -#+end_src - -*** Mdescription -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mdescription -#contributor : Thomas Dehaeze -#name :Measurement-Description -# -- -,* Measurement description -,** Setup :ignore: -*Setup*: - -,** Goal :ignore: -*Goal*: - -,** Measurements :ignore: -*Measurements*: - -Three measurements are done: -| Measurement File | Description | -|-------------------------+------------------------------| -| =mat/data_${1:001}.mat= | $2 | - -Each of the measurement =mat= file contains one =data= array with 3 columns: -| Column number | Description | -|---------------+-------------------| -| 1 | $3 | -| 2 | $4 | -| 3 | Time | - -$0 -#+end_src - -*** Mfigure -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mfigure -#contributor : Thomas Dehaeze -#name :Matlab-Figure -# -- -#+HEADER: :tangle no :exports results :results none :noweb yes -,#+begin_src matlab :var filepath="${2:figs}/$1.pdf" :var figsize="${3:full-tall}" :post pdf2svg(file=*this*, ext="png") - <>$0 -,#+end_src - -#+NAME: fig:$1 -#+CAPTION: ${4:caption}${5: ([[./figs/$1.png][png]], [[./figs/$1.pdf][pdf]])} -[[file:$2/$1.png]] -#+end_src - -*** Mfunction -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mfunction -#contributor : Thomas Dehaeze -#name :Matlab-Function -# -- -,* ${1:Function Name} -:PROPERTIES: -:header-args:matlab+: :tangle src/${2:matlab_file_name}.m -:header-args:matlab+: :comments none :mkdirp yes :eval no -:END: -<> - -This Matlab function is accessible [[file:src/$2.m][here]]. - -,#+begin_src matlab - function [${4:in_data}] = $2(${3:in_data}) - % $2 - $0 - % - % Syntax: [$4] = $2($3) - % - % Inputs: - % - $3 - - % - % Outputs: - % - $4 - - - end -,#+end_src -#+end_src - -*** Mheader -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mheader -#contributor : Thomas Dehaeze -#name :Matlab-Header -# -- -,* ${1:Heading Name} -:PROPERTIES: -:header-args:matlab+: :tangle matlab/${2:matlab_file_name}.m -:header-args:matlab+: :comments org :mkdirp yes -:END: -<> - -,** ZIP file containing the data and matlab files :ignore: -,#+begin_src bash :exports none :results none - if [ matlab/$2.m -nt data/$2.zip ]; then - cp matlab/$2.m $2.m; - zip data/$2 \ - mat/data.mat \ - $2.m - rm $2.m; - fi -,#+end_src - -,#+begin_note - All the files (data and Matlab scripts) are accessible [[file:data/$2.zip][here]]. -,#+end_note - -$0 -#+end_src - -*** Minipage -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/minipage -#contributor : Thomas Dehaeze -#name :minipage -# -- -#+BEGIN_EXPORT latex -\begin{figure}[htbp] -\centering -\begin{minipage}[t]{0.49\linewidth} -#+END_EXPORT -#+attr_latex: :float nil :width 0.95\linewidth -$0 -#+BEGIN_EXPORT latex -\end{minipage}% -\hfill% -\begin{minipage}[t]{0.49\linewidth} -#+END_EXPORT -#+attr_latex: :float nil :width 0.95\linewidth - -#+BEGIN_EXPORT latex -\end{minipage} -\end{figure} -#+END_EXPORT -#+end_src - -*** Minit -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/minit -#contributor : Thomas Dehaeze -#name :Matlab-Init -# -- -,** Matlab Init :noexport:ignore: -,#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name) - <> -,#+end_src - -,#+begin_src matlab :exports none :results silent :noweb yes - <> -,#+end_src - -$0 -#+end_src - -*** Mtable -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/mtable -#contributor : Thomas Dehaeze -#name :Matlab-Table -# -- -,#+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*) - data2orgtable(${1:data}, {${2:'rowlabel'}}, {${3:'collabel'}}, ' %.1f '); -,#+end_src -$0 -#+end_src - -*** Multicolumn -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/multicolumn -#contributor : Thomas Dehaeze -#name :Multcolumn -# -- -#+attr_latex: :float multicolumn -$0 -#+end_src - -*** Subfigure -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/subfigure -#contributor : Thomas Dehaeze -#name :Subfigure -# -- -#+name: fig:${1:figure_name} -#+caption: ${2:figure caption} -#+attr_latex: :environment subfigure :width 0.49\linewidth :align c -| file:${3:sub_fig_name}.${4:pdf} | file:${5:sub_fig_name}.${6:pdf} | -| <> ${7:sub figure caption} | <> ${8:sub figure caption} | -$0 -#+end_src - -*** Table -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/table -#contributor : Thomas Dehaeze -#name :Table -# -- -#+name: tab:${1:table_name} -#+caption: ${2:Table caption} -#+attr_latex: :environment tabularx :width ${3:\linewidth} :align ${4:lXX} -#+attr_latex: :center t :booktabs t :float t -| $0 | | | -|---+---+---| -| | | | -#+end_src - -*** Tikz -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/tikz -#contributor : Thomas Dehaeze -#name :Tikz figure -# -- -,#+begin_src latex :file ${1:figure_name}.pdf :post pdf2svg(file=*this*, ext="png") :exports both - \begin{tikzpicture} - $0 - \end{tikzpicture} -,#+end_src -#+end_src - -*** Tikzfig -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/tikzfig -#contributor : Thomas Dehaeze -#name :Tikz Figure -# -- -#+NAME: fig:${1:figure_name} -#+HEADER: :headers '("\\\\usepackage{tikz}" "\\\\usepackage{import}" "\\\\import{$HOME/Cloud/thesis/LaTeX/}{config.tex}") -#+HEADER: :imagemagick t :fit yes :iminoptions -scale 100% -density 150 :imoutoptions -quality 100 -#+HEADER: :results raw replace :buffer no :eval no-export :exports both :mkdirp yes -#+HEADER: :output-dir ${2:figs} -,#+begin_src latex :file $1.pdf :post pdf2svg(file=*this*, ext="png") :exports both - \begin{tikzpicture} - $0 - \end{tikzpicture} -,#+end_src - -#+NAME: fig:$1 -#+CAPTION: ${3:Caption} -#+RESULTS: fig:$1 -#+end_src - -*** Tikzheader -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/tikzheader -#contributor : Thomas Dehaeze -#name :Tikz Header -# -- -,* ${1:Title/Description of the figure} -,#+begin_src latex :file ${2:figure_name}.pdf :tangle figs/$2.tex :exports ${3:both} - \begin{tikzpicture} - $0 - \end{tikzpicture} -,#+end_src - -#+name: fig:$2 -#+caption: $1 ([[./figs/$2.png][png]], [[./figs/$2.pdf][pdf]], [[./figs/$2.tex][tex]]). -#+RESULTS: -[[file:./figs/$2.png]] -#+end_src - -*** User-config -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/user-config -# -*- mode: snippet -*- -# name: user-config -# key: uc -# -- -,#+begin_src emacs-lisp :tangle user-config.el -$1 -,#+end_src -#+end_src - -*** User-init -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/user-init -# -*- mode: snippet -*- -# name: user-init -# key: ui -# -- -,#+begin_src emacs-lisp :tangle user-init.el -$1 -,#+end_src -#+end_src - -*** Wrap -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/wrap -#contributor : Thomas Dehaeze -#name :Wrap -# -- -#+attr_latex: :float wrap -$0 -#+end_src -*** Latex -**** Integral -#+begin_src conf :tangle ~/.config/doom/snippets/org-mode/latex/int -# -*- mode: snippet -*- -# name: latex integral -# key: int -# contributor: John Kitchin -# -- -\int_{$1}^{$2} $3d$4$0 -#+end_src diff --git a/dotfiles/doom/init.el b/dotfiles/doom/init.el deleted file mode 100644 index 1642141..0000000 --- a/dotfiles/doom/init.el +++ /dev/null @@ -1,139 +0,0 @@ -;;; init.el -*- lexical-binding: t; -*- - -;; Copy this file to ~/.doom.d/init.el or ~/.config/doom/init.el ('doom install' -;; will do this for you). The `doom!' block below controls what modules are -;; enabled and in what order they will be loaded. Remember to run 'doom refresh' -;; after modifying it. -;; -;; More information about these modules (and what flags they support) can be -;; found in modules/README.org. - -(doom! :completion - company ; the ultimate code completion backend - helm ; the *other* search engine for love and life - ivy ; a search engine for love and life - - :ui - doom ; what makes DOOM look the way it does - doom-dashboard ; a nifty splash screen for Emacs - hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW - hydra - modeline ; snazzy, Atom-inspired modeline, plus API - nav-flash ; blink the current line after jumping - ophints ; highlight the region an operation acts on - (popup ; tame sudden yet inevitable temporary windows - +all ; catch all popups that start with an asterix - +defaults) ; default popup rules - unicode ; extended unicode support for various languages - vc-gutter ; vcs diff in the fringe - vi-tilde-fringe ; fringe tildes to mark beyond EOB - window-select ; visually switch windows - workspaces ; tab emulation, persistence & separate workspaces - - :editor - (evil +everywhere); come to the dark side, we have cookies - fold ; (nigh) universal code folding - rotate-text ; cycle region at point between text candidates - snippets ; my elves. They type so I don't have to - word-wrap ; soft wrapping with language-aware indent - - :emacs - dired ; making dired pretty [functional] - electric ; smarter, keyword-based electric-indent - ibuffer ; interactive buffer management - vc ; version-control and Emacs, sitting in a tree - - :term - eshell ; a consistent, cross-platform shell (WIP) - - :tools - debugger ; FIXME stepping through code, to help you add bugs - ;;ein ; tame Jupyter notebooks with emacs - (eval +overlay) ; run code, run (also, repls) - (lookup ; helps you navigate your code and documentation - +docsets) ; ...or in Dash docsets locally - ;;lsp - magit ; a git porcelain for Emacs - ;;make ; run make tasks from Emacs - ;;pass ; password manager for nerds - pdf ; pdf enhancements - ;;rgb ; creating color strings - ;;upload ; map local to remote projects via ssh/ftp - - :checkers - syntax ; tasing you for every semicolon you forget - spell ; tasing you for misspelling mispelling - - :lang - data ; config/data formats - emacs-lisp ; drown in parentheses - ;;ess ; emacs speaks statistics - ;;go ; the hipster dialect - ;;(haskell +dante) ; a language that's lazier than I am - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) - latex ; writing papers in Emacs has never been so fun - markdown ; writing docs for people to ignore - (org ; organize your plain life in plain text - +dragndrop ; drag & drop files/images into org buffers - +hugo ; use Emacs for hugo blogging - +journal ; - ;;+pomodoro ; be fruitful with the tomato technique - +present) ; using org-mode for presentations - ;;python ; beautiful is better than ugly - sh ; she sells {ba,z,fi}sh shells on the C xor - ;;web ; the tubes - - :email - ;;(mu4e +gmail) - - :app - ;;calendar - ;;(rss +org) ; emacs as an RSS reader - ;;write ; emacs for writers (fiction, notes, papers, etc.) - - :config - literate - (default +bindings +smartparens)) -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(custom-safe-themes - (quote - ("15ba8081651869ec689c9004288bed79003de5b4ee9c51a9d4a208d9e3439706" "f7b230ac0a42fc7e93cd0a5976979bd448a857cd82a097048de24e985ca7e4b2" "c19e5291471680e72d8bd98f8d6e84f781754a9e8fc089536cda3f0b7c3550e3" default))) - '(fci-rule-color "#405A61") - '(jdee-db-active-breakpoint-face-colors (cons "#073642" "#268bd2")) - '(jdee-db-requested-breakpoint-face-colors (cons "#073642" "#859900")) - '(jdee-db-spec-breakpoint-face-colors (cons "#073642" "#56697A")) - '(line-spacing 0.2) - '(objed-cursor-color "#dc322f") - '(pdf-view-midnight-colors (cons "#839496" "#002b36")) - '(vc-annotate-background "#002b36") - '(vc-annotate-color-map - (list - (cons 20 "#859900") - (cons 40 "#959300") - (cons 60 "#a58e00") - (cons 80 "#b58900") - (cons 100 "#bc7407") - (cons 120 "#c35f0e") - (cons 140 "#cb4b16") - (cons 160 "#cd4439") - (cons 180 "#d03d5d") - (cons 200 "#d33682") - (cons 220 "#d63466") - (cons 240 "#d9334a") - (cons 260 "#dc322f") - (cons 280 "#ba3f41") - (cons 300 "#994d54") - (cons 320 "#775b67") - (cons 340 "#405A61") - (cons 360 "#405A61"))) - '(vc-annotate-very-old-color nil)) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) diff --git a/dotfiles/doom/local/cdlatex.el b/dotfiles/doom/local/cdlatex.el deleted file mode 100644 index e2e6be1..0000000 --- a/dotfiles/doom/local/cdlatex.el +++ /dev/null @@ -1,2176 +0,0 @@ -;;; cdlatex.el --- Fast input methods for LaTeX environments and math -;; Copyright (c) 2010, 2011, 2012, 2014, 2019 Free Software Foundation, Inc. -;; -;; Author: Carsten Dominik -;; Keywords: tex -;; Version: 4.8 -;; -;; This file is not part of GNU Emacs. -;; -;; GNUTHis file is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; cdlatex.el is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with cdlatex.el. If not, see . -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Commentary: -;; -;; CDLaTeX is a minor mode supporting fast insertion of environment -;; templates and math stuff in LaTeX. -;; -;; To turn CDLaTeX Minor Mode on and off in a particular buffer, use -;; `M-x cdlatex-mode'. -;; -;; To turn on CDLaTeX Minor Mode for all LaTeX files, add one of the -;; following lines to your .emacs file: -;; -;; (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex) ; with AUCTeX LaTeX mode -;; (add-hook 'latex-mode-hook 'turn-on-cdlatex) ; with Emacs latex mode -;; -;; For key bindings, see further down in this documentation. -;; -;; CDLaTeX requires texmathp.el which is distributed with AUCTeX. -;; Starting with Emacs 21.3, texmathp.el will be part of Emacs. -;; -;;-------------------------------------------------------------------------- -;; -;; OVERVIEW -;; ======== -;; -;; CDLaTeX is a minor mode supporting mainly mathematical and scientific -;; text development with LaTeX. CDLaTeX is really about speed. AUCTeX -;; (the major mode I recommend for editing LaTeX files) does have a hook -;; based system for inserting environments and macros - but while this is -;; useful and general, it is sometimes slow to use. CDLaTeX tries to be -;; quick, with very few and easy to remember keys, and intelligent -;; on-the-fly help. -;; -;; 1. ABBREVIATIONS. -;; ------------- -;; CDLaTeX has an abbrev-like mechanism to insert full LaTeX -;; environments and other templates into the buffer. Abbreviation -;; expansion is triggered with the TAB key only, not with SPC or RET. -;; For example, typing "ite" inserts an itemize environment. A -;; full list of defined abbreviations is available with the command -;; `C-c ?' (`cdlatex-command-help'). -;; -;; 1a. ENVIRONMENT TEMPLATES -;; --------------------- -;; Typing `C-c {' (`cdlatex-environment') uses the minibuffer to -;; complete the name of a LaTeX environment and inserts a template -;; for this environment into the buffer. These environment -;; templates also contain labels created with RefTeX. In a -;; template, text needs to be filled in at various places, which we -;; call "points of interest". You can use the TAB key to jump to -;; the next point of interest in the template. -;; -;; For many frequently used LaTeX environments, abbreviations are -;; available. Most of the time, the abbreviation consists of the -;; first three letters of the environment name: `equ' expands -;; into -;; \begin{equation} -;; \label{eq:1} -;; -;; \end{equation} -;; -;; Similarly, `ali' inserts an AMS-LaTeX align environment -;; template etc. For a full list of environment abbreviations, use -;; `C-c ?'. -;; -;; Use the command `C-c -' (`cdlatex-item') to insert a generalized -;; new "item" in any "list"-like environment. For example, in an -;; itemize environment, this inserts "\item", in an enumerate -;; environment it inserts "\item\label{item:25}" and in an eqnarray -;; environment, it inserts "\label{eq:25} \n & &". When -;; appropriate, newlines are inserted, and the previous item is also -;; closed with "\\". `cdlatex-item' can also be invoked with the -;; abbreviation "it". -;; -;; 1b. MATH TEMPLATES -;; -------------- -;; Abbreviations are also used to insert simple math templates -;; into the buffer. The cursor will be positioned properly. For -;; example, typing `fr' will insert "\frac{}{}" with the -;; cursor in the first pair of parenthesis. Typing `lr(' -;; will insert a "\left( \right)" pair and position the cursor in -;; between, etc. Again, the TAB key can be used to jump to the -;; points in the template where additional text has to be -;; inserted. For example in the `\frac{}{}' template, it will -;; move you from the first argument to the second and then out of -;; the second. For a list of available templates, type `C-c ?'. -;; -;; 2. MATHEMATICAL SYMBOLS -;; -------------------- -;; This feature is similar to the functionality in the Math minor mode -;; of AUCTeX, and to the input methods of the X-Symbol package. It is -;; introduced by the backquote character. Backquote followed by any -;; character inserts a LaTeX math macro into the buffer. If -;; necessary, a pair of "$" is inserted to switch to math mode. For -;; example, typing "`a" inserts "$\alpha$". Since LaTeX defines many -;; more mathematical symbols than the alphabet has letters, different -;; sets of math macros are provided. We call the different sets -;; "levels". On each level, another LaTeX macro is assigned to a -;; given letter. To select the different levels, simply press the -;; backquote character several times before pressing the letter. For -;; example, typing "`d" inserts "\delta" (level 1), and typing "``d" -;; inserts "\partial" (level 2). Similarly, "`e" inserts "\epsilon" -;; and "``e" inserts "\vareppsilon". -;; -;; On each level, on-thy-fly help will pop up automatically if you -;; hesitate to press the next key. The help screen is a window which -;; lists all math macros available on the current level. Initially, -;; when you type slowly, this window will pop up each time you press -;; backquote. However, after you have learned the different keys, you -;; will type more quickly and the help window is not shown. Try it -;; out: First press "`" (backquote), wait for the help window and then -;; press "a" to get "\alpha". Then press "`" and "b" as a quick -;; sequence to get "\beta", without the help window. -;; -;; The LaTeX macros available through this mechanism are fully -;; configurable - see the variable `cdlatex-math-symbol-alist'. -;; -;; 3. ACCENTS AND FONTS -;; ----------------- -;; Putting accents on mathematical characters and/or changing the font -;; of a character uses key combinations with the quote character "'" -;; as a prefix. The accent or font change is applied to the character -;; or LaTeX macro *before* point. For example -;; -;; Keys Result -;; -------------------------------------------------------------------- -;; a'~ ERROR % in text mode -;; $a'~ \tilde{a} % in math mode -;; a': \ddot{a} -;; ab'b \textbf{ab} % in text mode -;; $ab'b a\mathbf{b} % in math mode -;; \alpha'. \dot{\alpha} -;; r_{dust}'r r_\mathrm{dust} % in math mode -;; 'e \emph{} -;; this is important M-2 'b this \textbf{is important} -;; -;; As you can see: -;; - using math accents like ~ outside math mode will throw an error. -;; - the font change used automatically adapts to math mode. -;; - if the item before point is a LaTeX macro, the change applies to -;; the whole macro. -;; - in text mode, the change applies to the entire word before point, -;; while in math mode only the last character is modified. -;; - if the character before point is white space, a dollar or an -;; opening parenthesis, this command just opens an empty template -;; and positions the cursor inside. -;; - when a numeric prefix argument is supplied, the command acts on -;; whole words before the cursor. -;; -;; In order to insert a normal quote, you can press the quote -;; character twice. Also, if the key character is not associated with -;; an accent or font, the quote will be inserted. For example, "'t" -;; and "'s" insert just that, so that normal text typing will not be -;; disturbed. Just like during the insertion of math macros (see above -;; under (4.)), automatic on-the-fly help will pop up when you pause -;; after hitting the quote character, but will be suppressed when you -;; continue quickly. The available accents and also the prefix key -;; can be can be configured - see documentation of the variables -;; `cdlatex-math-modify-alist' and `cdlatex-math-modify-prefix'. -;; -;; 4. PAIR INSERTION of (), [], {}, and $$ -;; ------------------------------------ -;; Dollars and parens can be inserted as pairs. When you type the -;; opening delimiter, the closing delimiter will be inserted as well, -;; and the cursor positioned between them. You can configure which -;; delimiter are inserted pairwise by configuring the variable -;; `cdlatex-paired-parens'. -;; -;; Also, the keys `_' and `^' will insert "_{}" and "^{}", -;; respectively, and, if necessary, also a pair of dollar signs to -;; switch to math mode. You can use TAB to exit paired parenthesis. -;; As a special case, when you use TAB to exit a pair of braces that -;; belong to a subscript or superscript, CDLaTeX removes the braces if -;; the sub/superscript consists of a single character. For example -;; typing "$10^3" inserts "$10^3$", but typing "$10^34" -;; inserts "$10^{34}$" -;; -;; 5. THE OVERLOADED TAB KEY -;; ---------------------- -;; You may have noticed that we use the TAB key for many different -;; purposes in this package. While this may seem confusing, I have -;; gotten used to this very much. Hopefully this will work for you as -;; well: "when in doubt, press TAB". Here is a summary of what happens -;; when you press the TAB key: -;; -;; The function first tries to expand any abbreviation before point. -;; -;; If there is none, it cleans up short subscripts and superscripts at -;; point. I.e., is the cursor is just before the closing brace in -;; "a^{2}", it changes it to "a^2", since this is more readable. If -;; you want to keep the braces also for simple superscripts and -;; subscripts, set the variable `cdlatex-simplify-sub-super-scripts' -;; to nil. -;; -;; After that, the TAB function jumps to the next point of interest in -;; a LaTeX text where one would reasonably expect that more input can -;; be put in. This does *not* use special markers in the template, -;; but a heuristic method which works quite well. For the detailed -;; rules which govern this feature, check the documentation of the -;; function `cdlatex-tab'. -;; -;;----------------------------------------------------------------------------- -;; -;; CONFIGURATION EXAMPLES -;; ====================== -;; -;; Check out the documentation of the variables in the configuration -;; section. The variables must be set before cdlatex-mode is turned on, -;; or, at the latext, in `cdlatex-mode-hook', in order to be effective. -;; When changing the variables, toggle the mode off and on to make sure -;; that everything is up to date. -;; -;; Here is how you might configure CDLaTeX to provide environment templates -;; (including automatic labels) for two theorem-like environments. -;; -;; (setq cdlatex-env-alist -;; '(("axiom" "\\begin{axiom}\nAUTOLABEL\n?\n\\end{axiom}\n" nil) -;; ("theorem" "\\begin{theorem}\nAUTOLABEL\n?\n\\end{theorem}\n" nil))) -;; -;; The "AUTOLABEL" indicates the place where an automatic label should be -;; inserted, using RefTeX. The question mark defines the position of the -;; cursor after the template has been inserted into the buffer. -;; -;; You could also define your own keyword commands "axm" and "thr" to make -;; the template insertion quicker (e.g. `axm' and `thm'): -;; -;; (setq cdlatex-command-alist -;; '(("axm" "Insert axiom env" "" cdlatex-environment ("axiom") t nil) -;; ("thr" "Insert theorem env" "" cdlatex-environment ("theorem") t nil))) -;; -;; Here is how to add new math symbols to CDLaTeX's list: In order to put -;; all rightarrow commands onto `>, ``>, ```>, and ````> (i.e. several -;; backquotes followed by >) and all leftarrow commands onto '<, ``<, ```<, -;; and ````<, you could do this in .emacs: -;; -;; (setq cdlatex-math-symbol-alist -;; '((?< ("\\leftarrow" "\\Leftarrow" "\\longleftarrow" "\\Longleftarrow")) -;; (?> ("\\rightarrow" "\\Rightarrow" "\\longrightarrow" "\\Longrightarrow")) -;; )) -;; -;; To change the prefix key for math accents and font switching, you could -;; do something like -;; -;; (setq cdlatex-math-modify-prefix [f7]) -;;----------------------------------------------------------------------------- -;; -;; KEY BINDINGS -;; -;; Here is the default set of keybindings from CDLaTeX. A menu is also -;; installed. -;; -;; $ cdlatex-dollar -;; ( cdlatex-pbb -;; { cdlatex-pbb -;; [ cdlatex-pbb -;; | cdlatex-pbb -;; < cdlatex-pbb -;; ^ cdlatex-sub-superscript -;; _ cdlatex-sub-superscript -;; -;; TAB cdlatex-tab -;; C-c ? cdlatex-command-help -;; C-c { cdlatex-environment -;; C-c - cdlatex-item -;; ` cdlatex-math-symbol -;; ' cdlatex-math-modify -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; FAQ -;; -;; - Some people find it disturbing that the quote character (') is active -;; for math accents and font switching. I have tried to avoid any letters -;; which are frequently following ' in normal text. For example, 's and 't -;; insert just this. If you still prefer a different prefix key, just -;; configure the variable `cdlatex-math-modify-prefix'. -;; -;; - To insert a backquote into the buffer, use C-q ` -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;;;;; - -;;; Code: - -(eval-when-compile (require 'cl)) - -;;; Begin of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; Configuration Variables and User Options for CDLaTeX ------------------ - -(defgroup cdlatex nil - "LaTeX label and citation support." - :tag "CDLaTeX" - :link '(url-link :tag "Home Page" "http://zon.astro.uva.nl/~dominik/Tools/") - :prefix "cdlatex-" - :group 'tex) - -(defun cdlatex-customize () - "Call the customize function with cdlatex as argument." - (interactive) - (cond - ((fboundp 'customize-browse) - (customize-browse 'cdlatex)) - ((fboundp 'customize-group) - (customize-group 'cdlatex)) - (t (error "No customization available")))) - -(defun cdlatex-create-customize-menu () - "Create a full customization menu for CDLaTeX." - (interactive) - (if (fboundp 'customize-menu-create) - (progn - (easy-menu-change - '("CDLTX") "Customize" - `(["Browse CDLaTeX group" cdlatex-customize t] - "---" - ,(customize-menu-create 'cdlatex) - ["Set" Custom-set t] - ["Save" Custom-save t] - ["Reset to Current" Custom-reset-current t] - ["Reset to Saved" Custom-reset-saved t] - ["Reset to Standard Settings" Custom-reset-standard t])) - (message "\"CDLTX\"-menu now contains full customization menu")) - (error "Cannot expand menu (outdated version of cus-edit.el)"))) - -;; Configuration of KEYWORD commands ------------------------------------ - -(defgroup cdlatex-keyword-commands nil - "How to type a keyword in the buffer and hit TAB to execute." - :group 'cdlatex) - -(defcustom cdlatex-command-alist nil - "List of abbrev-like commands, available with keyword and TAB. -See `cdlatex-command-alist-default' for examples. This list only -defines additons to the defaults. For a full list of active commands, -press \\[cdlatex-command-help]. -Each element of this list is again a list with the following items: -0. KEYWORD The key that has to be typed into the text. -1. DOCSTRING A documentation string, less than 60 characters long. -2. REPLACE The text to be substituted for the keyword, if any. -3. HOOK A function to be called. -4. ARGS Optional list of arguments to the function. -5. TEXTFLAG non-nil means this keyword command is active in textmode. -6. MATHFLAG non-nil means this keyword command is active in math mode." - :group 'cdlatex-keyword-commands - :type '(repeat - (list (string :tag "Keyword ") - (string :tag "Docstring ") - (string :tag "Replacement") - (function :tag "Hook ") - (sexp :tag "Arguments ") - (boolean :tag "Available in Text mode") - (boolean :tag "Available in Math mode")))) - -(defcustom cdlatex-tab-hook nil - "List of functions called by TAB before the default command is executed. -These functions are called each time TAB is pressed. They may parse the -environment and take an action. The function should return t when it -successful executed an action and other TAB actions should *not* be tried. -When a return value is nil, other hook functions are tried, followed by the -default action of TAB (see documentation of the command `cdlatex-tab'." - :group 'cdlatex-keyword-commands - :type '(repeat (function :tag "Function" :value nil))) - -;; Configuration of environment templates ------------------------------- - -(defgroup cdlatex-environment-support nil - "Template-based insertion of LaTeX environments." - :group 'cdlatex) - -(defcustom cdlatex-env-alist nil - "Association list of LaTeX environments and the corresponding templates. -The car of the list is a keyword to identify the environment. -the two following items in the list are the templates for environment -and item. See `cdlatex-env-alist-default' for examples. Any entries -in this variable will be added to the default definitions." - :group 'cdlatex-environment-support - :type '(repeat - (list :tag "" - (string :format "ENVIRONMENT %v" "") - (text :format "ENVIRONMENT TEMPLATE\n%v" "") - (choice :tag "ITEM" - (const :tag "none" nil) - (text :tag "template" :format "TEMPLATE\n%v" ""))))) - -(defcustom cdlatex-insert-auto-labels-in-env-templates t - "*Non-nil means the environment templates CDLaTeX will contain labels. -This variable may be set to t, nil, or a string of label type letters -indicating the label types for which it should be true." - :group 'cdlatex-making-and-inserting-labels - :type '(choice :tag "Insert labels in templates" - (const :tag "always" t) - (const :tag "never" nil) - (string :tag "selected label types" ""))) - -;; Configuration of Math character insertion and accents ---------------- - -(defgroup cdlatex-math-support nil - "Support for mathematical symbols and accents in CDLaTeX." - :group 'cdlatex) - -(defcustom cdlatex-math-symbol-prefix ?` - "Prefix key for `cdlatex-math-symbol'. -This may be a character, a string readable with read-kbd-macro, or a -lisp vector." - :group 'cdlatex-math-support - :type '(choice - (character) - (string :value "" :tag "kbd readable string") - (sexp :value [] :tag "a lisp vector"))) - -(defcustom cdlatex-math-symbol-direct-bindings '(nil nil nil) - "How to bind the math symbols directly. -This is a list of key binding descriptions for different levels of -math symbols. First entry for level 1 etc. -Each entry consists of a prefix key and a list of modifiers for the -character. The prefix key can be nil, or any of a character, a -read-kbd-macro readable string or a vector. -Examples: -`((nil alt))' bind `\\delta' to `A-d'. -`((\"C-c C-f\"))' bind `\\delta' to `C-c C-f d'. -`((nil alt) (nil alt control))' bind `\\delta' to `A-d' and - `\\partial' (which is on level 2) - to `A-C-d'" - :group 'cdlatex-math-support - :type '(repeat - (choice - (const :tag "No binding of this level" nil) - (cons - :tag "Specify a binding" - :value (nil alt) - (choice - (const :tag "No prefix" nil) - (character :value ?@) - (string :value "" :tag "kbd readable string") - (sexp :value [] :tag "a lisp vector")) - (set :tag "Modifiers for the final character" :greedy t - (const control) - (const meta) - (const alt) - (const super) - (const hyper)))))) - -(defcustom cdlatex-math-symbol-alist nil - "Key characters and math symbols for fast access with the prefix key. -First element is a character, followed by a number of strings attached to -this key. When the string contains a question mark, this is where the -cursor will be positioned after insertion of the string into the buffer. -See `cdlatex-math-symbol-alist-default' for an example. Any entry defined -here will replace the corresponding entry of the default list. The -defaults implement 3 levels of symbols so far: Level 1 for greek letters -and standard symbols, level 2 for variations of level 1, and level 3 for -functions and opperators." - :group 'cdlatex-math-support - :type '(repeat - (list - (character ?a) - (repeat (string :tag "macro" ""))))) - -(defcustom cdlatex-math-modify-prefix ?' - "Prefix key for `cdlatex-math-modify'. -It can be a character, a string interpretable with `read-kbd-macro', -or a lisp vector." - :group 'cdlatex-math-support - :type '(choice - (character) - (string :value "" :tag "kbd readable string") - (sexp :value [] :tag "a lisp vector"))) - -(defcustom cdlatex-modify-backwards t - "*Non-nil means, `cdlatex-math-modify' modifies char before point. -Nil means, always insert only an empty modification form. This is also -the case if the character before point is white or some punctuation. " - :group 'cdlatex-math-support - :type 'boolean) - -(defcustom cdlatex-math-modify-alist nil - "List description of the LaTeX math accents. -See `cdlatex-math-modify-alist-default' for an example. Any entries in this -variable will be added to the default. -Each element contains 6 items: -0. key: The character that is the key for a the accent. -1. mathcmd: The LaTeX command associated with the accent in math mode -2. textcmd: The LaTeX command associated with the accent in text mode -3. type: t if command with argument (e.g. \\tilde{a}). - nil if style (e.g. {\\cal a}). -4. rmdot: t if the dot on i and j has to be removed. -5. it t if italic correction is required." - :group 'cdlatex-math-support - :type '(repeat - (list (character :tag "Key character ") - (choice :tag "TeX macro inside math mode" - (string "") - (const :tag "none" nil)) - (choice :tag "TeX macro outside math mode" - (string "") - (const :tag "none" nil)) - (boolean :tag "Type " :on "Command" :off "Style") - (boolean :tag "Remove dot in i/j") - (boolean :tag "Italic correction")))) - -;; Miscellaneous configurations ----------------------------------------- - -(defgroup cdlatex-miscellaneous-configurations nil - "Collection of further configurations." - :group 'cdlatex) - -(defcustom cdlatex-use-fonts t - "*Non-nil means, use fonts in label menu and on-the-fly help. -Font-lock must be loaded as well to actually get fontified display." - :group 'cdlatex-miscellaneous-configurations - :type '(boolean)) - -(defcustom cdlatex-paired-parens "$[{" - "*String with the opening parens you want to have inserted paired. -The following parens are allowed here: `$([{|<'. -I recommend to set this to '$[{' as these have syntactical meaning in -TeX and are required to be paired. TAB is a good way to move out of paired -parens." - :group 'cdlatex-miscellaneous-configurations - :type '(string :tag "Opening delimiters")) - -(defcustom cdlatex-simplify-sub-super-scripts t - "*Non-nil means, TAB will simplify sub- and superscripts at point. -When you use TAB to exit from a sub- or superscript which is a single -letter, the parenthesis will be removed." - :group 'cdlatex-miscellaneous-configurations - :type '(boolean)) - -(defcustom cdlatex-sub-super-scripts-outside-math-mode t - "*Non-nil means, inserting ^ or _ will add dollars outside math environment. -So in text mode surrounding dollars and braces will be added with `_' and `^'. -When nil, `_' and `^' will just self-insert." - :group 'cdlatex-miscellaneous-configurations - :type '(boolean)) - -(defcustom cdlatex-auto-help-delay 1.5 - "Number of idle seconds before display of auto-help. -When executing cdlatex-math-symbol or cdlatex-math-modify, display -automatic help when idle for more than this amount of time." - :group 'cdlatex-miscellaneous-configurations - :type 'number) - -(require 'texmathp) - -;;;============================================================================ -;;; -;;; Define the formal stuff for a minor mode named CDLaTeX. -;;; - -(defun cdlatex-show-commentary () - "Use the finder to view the file documentation from `cdlatex.el'." - (interactive) - (require 'finder) - (finder-commentary "cdlatex.el")) - -(defconst cdlatex-version "4.6" - "Version string for CDLaTeX.") - -(defvar cdlatex-mode nil - "Determines if CDLaTeX minor mode is active.") -(make-variable-buffer-local 'cdlatex-mode) - -(defvar cdlatex-mode-map (make-sparse-keymap) - "Keymap for CDLaTeX minor mode.") -(defvar cdlatex-mode-menu nil) - -;;;###autoload -(defun turn-on-cdlatex () - "Turn on CDLaTeX minor mode." - (cdlatex-mode t)) - -;;;###autoload -(defun cdlatex-mode (&optional arg) - "Minor mode for editing scientific LaTeX documents. Here is a -list of features: \\ - - KEYWORD COMMANDS - ---------------- -Many CDLaTeX commands are activated with an abbrev-like mechanism. -When a keyword is typed followed `\\[cdlatex-tab]', the keyword is deleted -from the buffer and a command is executed. You can get a full list -of these commands with `\\[cdlatex-command-help]'. -For example, when you type `fr', CDLaTeX will insert `\\frac{}{}'. - -When inserting templates like '\\frac{}{}', the cursor is positioned -properly. Use `\\[cdlatex-tab]' to move through templates. `\\[cdlatex-tab]' also kills -unnecessary braces around subscripts and superscripts at point. - - MATH CHARACTERS AND ACCENTS - --------------------------- -\\[cdlatex-math-symbol] followed by any character inserts a LaTeX math character - e.g. \\[cdlatex-math-symbol]e => \\epsilon -\\[cdlatex-math-symbol]\\[cdlatex-math-symbol] followed by any character inserts other LaTeX math character - e.g. \\[cdlatex-math-symbol]\\[cdlatex-math-symbol]e => \\varepsilon -\\[cdlatex-math-modify] followed by character puts a math accent on a letter or symbol - e.g. \\[cdlatex-math-symbol]a\\[cdlatex-math-modify]~ => \\tilde{\\alpha} - -CDLaTeX is aware of the math environments in LaTeX and modifies the -workings of some functions according to the current status. - - ONLINE HELP - ----------- -After pressing \\[cdlatex-math-symbol] or \\[cdlatex-math-modify], CDLaTeX waits for a short time for the second character. -If that does not come, it will pop up a window displaying the available -characters and their meanings. - - KEY BINDINGS - ------------ -\\{cdlatex-mode-map} - -Under X, many functions will be available also in a menu on the menu bar. - -Entering cdlatex-mode calls the hook cdlatex-mode-hook. -------------------------------------------------------------------------------" - - (interactive "P") - (setq cdlatex-mode (not (or (and (null arg) cdlatex-mode) - (<= (prefix-numeric-value arg) 0)))) - - ; Add or remove the menu, and run the hook - (if cdlatex-mode - (progn - (easy-menu-add cdlatex-mode-menu) - (run-hooks 'cdlatex-mode-hook) - (cdlatex-compute-tables)) - (easy-menu-remove cdlatex-mode-menu))) - -(or (assoc 'cdlatex-mode minor-mode-alist) - (setq minor-mode-alist - (cons '(cdlatex-mode " CDL") minor-mode-alist))) - -(or (assoc 'cdlatex-mode minor-mode-map-alist) - (setq minor-mode-map-alist - (cons (cons 'cdlatex-mode cdlatex-mode-map) - minor-mode-map-alist))) - - -;;; =========================================================================== -;;; -;;; Functions that check out the surroundings - -(defun cdlatex-dollars-balanced-to-here (&optional from) - ;; Return t if the dollars are balanced between start of paragraph and point. - (save-excursion - (let ((answer t) (pos (point))) - (if from - (goto-char from) - (backward-paragraph 1)) - (if (not (bobp)) (backward-char 1)) - (while (re-search-forward "[^\\]\\$+" pos t) - (if (/= (char-after (match-beginning 0)) ?\\) - (setq answer (not answer)))) - (setq answer answer)))) - -(defun cdlatex-number-of-backslashes-is-odd () - ;; Count backslashes before point and return t if number is odd. - (let ((odd nil)) - (save-excursion - (while (equal (preceding-char) ?\\) - (progn - (forward-char -1) - (setq odd (not odd))))) - (setq odd odd))) - -;; ============================================================================ -;; -;; Some generally useful functions - -(defun cdlatex-get-kbd-vector (obj) - (cond ((vectorp obj) obj) - ((integerp obj) (vector obj)) - ((stringp obj) (read-kbd-macro obj)) - ((and (fboundp 'characterp) (characterp obj)) - (vector obj)) ; XEmacs only - (t nil))) - -(defun cdlatex-uniquify (alist &optional keep-list) - ;; Return a list of all elements in ALIST, but each car only once. - ;; Elements of KEEP-LIST are not removed even if duplicate. - (let (new elm) - (while alist - (setq elm (car alist) - alist (cdr alist)) - (if (or (member (car elm) keep-list) - (not (assoc (car elm) new))) - (setq new (cons elm new)))) - (setq new (nreverse new)) - new)) - -(defun cdlatex-use-fonts () - ;; Return t if we can and want to use fonts. - (and window-system - cdlatex-use-fonts - (boundp 'font-lock-keyword-face))) - -;;; --------------------------------------------------------------------------- -;;; -;;; Insert pairs of $$ (), etc. - -;; Alist connection opening with closing delimiters -(defconst cdlatex-parens-pairs '(("(".")") ("["."]") ("{"."}") - ("|"."|") ("<".">"))) - -(defun cdlatex-pbb () - "Insert a pair of parens, brackets or braces." - (interactive) - (let ((paren (char-to-string (event-basic-type last-command-event)))) - (if (and (stringp cdlatex-paired-parens) - (string-match (regexp-quote paren) cdlatex-paired-parens) - (not (cdlatex-number-of-backslashes-is-odd))) - (progn - (insert paren) - (insert (cdr (assoc paren cdlatex-parens-pairs))) - (forward-char -1)) - (insert paren)))) - -(defun cdlatex-ensure-math () - ;; Make sure we are in math - (unless (texmathp) - (cdlatex-dollar))) - -(defun cdlatex-dollar (&optional arg) - "Insert a pair of dollars unless number of backslashes before point is odd. -With arg, insert pair of double dollars." - (interactive "P") - (if (cdlatex-number-of-backslashes-is-odd) - (insert "$") - (if (texmathp) - (if (and (stringp (car texmathp-why)) - (equal (substring (car texmathp-why) 0 1) "\$")) - (progn - (insert (car texmathp-why)) - (save-excursion - (goto-char (cdr texmathp-why)) - (if (pos-visible-in-window-p) - (sit-for 1)))) - (message "No dollars inside a math environment!") - (ding)) - (if (and (stringp cdlatex-paired-parens) - (string-match "\\$" cdlatex-paired-parens)) - (if arg - (if (bolp) - (progn (insert "\$\$\n\n\$\$\n") (backward-char 4)) - (insert "\$\$ \$\$") (backward-char 3)) - (insert "$$") (backward-char 1)) - (if arg - (if (bolp) (insert "$$\n") (insert "$$")) - (insert "$")))))) - -(defun cdlatex-sub-superscript () - "Insert ^{} or _{} unless the number of backslashes before point is odd. -When not in LaTeX math environment, _{} and ^{} will have dollars." - (interactive) - (if (cdlatex-number-of-backslashes-is-odd) - ;; Quoted - (insert (event-basic-type last-command-event)) - ;; Check if we are in math mode, if not switch to or only add _ or ^ - (if (and (not (texmathp)) - (not cdlatex-sub-super-scripts-outside-math-mode)) - (insert (event-basic-type last-command-event)) - (if (not (texmathp)) (cdlatex-dollar)) - (if (string= (buffer-substring (max (point-min) (- (point) 2)) (point)) - (concat (char-to-string (event-basic-type last-command-event)) - "{")) - ;; We are at the start of a sub/suberscript. Allow a__{b} and a^^{b} - ;; This is an undocumented feature, please keep it in. It supports - ;; a special notation which can be used for upright sub- and - ;; superscripts. - (progn - (backward-char 1) - (insert (event-basic-type last-command-event)) - (forward-char 1)) - ;; Insert the normal template. - (insert (event-basic-type last-command-event)) - (insert "{}") - (forward-char -1))))) - -(defun cdlatex-lr-pair () - "Insert a \\left-\\right pair of parens." - (interactive) - (let* ((paren (char-to-string (preceding-char))) - (close (cdr (assoc paren cdlatex-parens-pairs))) - (paren1 paren) - (close1 close)) - (if (string= paren "<") (setq paren1 "\\langle" close1 "\\rangle")) - (if (string= paren "{") (setq paren1 "\\{" close1 "\\}")) - (backward-delete-char 1) - (if (and (stringp cdlatex-paired-parens) - (string-match (regexp-quote paren) cdlatex-paired-parens) - (string= close (char-to-string (following-char)))) - (delete-char 1)) - (insert "\\left" paren1 " ? \\right" close1) - (cdlatex-position-cursor))) - -;;; =========================================================================== -;;; -;;; Keyword controlled commands and cursor movement - -(defvar cdlatex-command-alist-comb nil) - -(defun cdlatex-tab () - "This function is intended to do many cursor movements. -It is bound to the tab key since tab does nothing useful in a TeX file. - -This function first calls all functions in `cdlatex-tab-hook', which see. - -If none of those functions returns t, the command first tries to expand -any command keyword before point. - -If there is none, it cleans up short subscripts and superscripts at point. -I.e. it changes a^{2} into a^2, since this is more readable. This feature -can be disabled by setting `cdlatex-simplify-sub-super-scripts' to nil. - -Then it jumps to the next point in a LaTeX text where one would reasonably -expect that more input can be put in. -To do that, the cursor is moved according to the following rules: - -The cursor stops... -- before closing brackets if preceding-char is any of -({[]}) -- after closing brackets, but not if following-char is any of ({[_^ -- just after $, if the cursor was before that $. -- at end of non-empty lines -- at the beginning of empty lines -- before a SPACE at beginning of line -- after first of several SPACE - -Sounds strange? Try it out!" - (interactive) - (catch 'stop - - ;; try hook stuff - (let ((funcs cdlatex-tab-hook)) - (while funcs (if (funcall (pop funcs)) (throw 'stop t)))) - - ;; try command expansion - (let ((pos (point)) exp math-mode) - (backward-word 1) - (while (eq (following-char) ?$) (forward-char 1)) - (setq exp (buffer-substring-no-properties (point) pos)) - (setq exp (assoc exp cdlatex-command-alist-comb)) - (when exp - (setq math-mode (texmathp)) - (when (or (and (not math-mode) (nth 5 exp)) - (and math-mode (nth 6 exp))) - (delete-char (- pos (point))) - (insert (nth 2 exp)) - ;; call the function if there is one defined - (and (nth 3 exp) - (if (nth 4 exp) - (apply (nth 3 exp) (nth 4 exp)) - (funcall (nth 3 exp)))) - (throw 'stop t))) - (goto-char pos)) - - ;; Check for simplification of sub and superscripts - (cond - ((looking-at "}\\|\\]\\|)") - (forward-char -3) - (if (and (looking-at "[_^]{[-+0-9a-zA-Z]}") - cdlatex-simplify-sub-super-scripts) - ;; simplify sub/super script - (progn (forward-char 1) - (delete-char 1) - (forward-char 1) - (delete-char 1)) - (forward-char 4)) - (if (looking-at "[^_\\^({\\[]") - ;; stop after closing bracket, unless ^_[{( follow - (throw 'stop t))) - ((= (following-char) ?$) - (while (= (following-char) ?$) (forward-char 1)) - (throw 'stop t)) - ((= (following-char) ?\ ) - ;; stop after first of many spaces - (forward-char 1) - (re-search-forward "[^ ]") - (if (/= (preceding-char) ?\n) (forward-char -1))) - (t - (forward-char 1))) - - ;; move to next possible stopping site and check out the place - (while (re-search-forward "[ )}\n]\\|\\]" (point-max) t) - (forward-char -1) - (cond - ((= (following-char) ?\ ) - ;; stop at first space or b-o-l - (if (not (bolp)) (forward-char 1)) (throw 'stop t)) - ((= (following-char) ?\n) - ;; stop at line end, but not after \\ - (if (and (bolp) (not (eobp))) - (throw 'stop t) - (if (equal "\\\\" (buffer-substring-no-properties - (- (point) 2) (point))) - (forward-char 1) - (throw 'stop t)))) - (t - ;; Stop before )}] if preceding-char is any parenthesis - (if (or (= (char-syntax (preceding-char)) ?\() - (= (char-syntax (preceding-char)) ?\)) - (= (preceding-char) ?-)) - (throw 'stop t) - (forward-char 1) - (if (looking-at "[^_\\^({\\[]") - ;; stop after closing bracket, unless ^_[{( follow - (throw 'stop t)))))))) - -(defun cdlatex-command-help () - "Show the available cdlatex commands in the help buffer." - (interactive) - (with-output-to-temp-buffer " *CDLaTeX Help*" - (princ " AVAILABLE KEYWORD COMMANDS WITH CDLaTeX\n") - (princ " --------------------------------------\n") - (princ "To execute, type keyword into buffer followed by TAB.\n\n") - (let ((cmdlist cdlatex-command-alist-comb) item key doc text math) - (while cmdlist - (setq item (car cmdlist) - cmdlist (cdr cmdlist) - key (car item) - doc (nth 1 item) - text (nth 5 item) - math (nth 6 item)) - (princ (format "%-10.10s %-58.58s %4s/%4s\n" key - (if (> (length doc) 59) - (substring doc 0 59) - doc) - (if text "TEXT" "") - (if math "MATH" ""))))))) - -;;; --------------------------------------------------------------------------- -;;; -;;; Cursor position after insertion of forms - -(defun cdlatex-position-cursor () - ;; Search back to question mark, delete it, leave point there - (if (search-backward "\?" (- (point) 100) t) - (delete-char 1))) - -;;; --------------------------------------------------------------------------- -;;; -;;; Environments -;;; -;;; The following code implements insertion of LaTeX environments -;;; I prefer these environment over AUCTeX's definitions, since they give -;;; my memory more support and don't prompt for anything. - -(defvar cdlatex-env-alist-comb nil) - -(defun cdlatex-environment (&optional environment item) - "Complete the name of an ENVIRONMENT and insert it. -If the environment is not found in the list, a \\begin \\end pair is -inserted. Any keywords AUTOLABEL will be replaced by an automatic label -statement. Any keywords AUTOFILE will prompt the user for a file name -\(with completion) and insert that file names. If a template starts with -\"\\\\\", the function will make sure that a double backslash occurs before -the template. This is mainly useful for \"items\" of environments, where -\"\\\\\" is often needed as separator." - (interactive) - (let ((env environment) begpos (endmarker (make-marker)) - (auto-label cdlatex-insert-auto-labels-in-env-templates) - template) - (if (not env) - (setq env (completing-read "Environment: " cdlatex-env-alist-comb nil nil ""))) - (if (not (bolp)) (newline)) - (setq begpos (point)) - (if (try-completion env cdlatex-env-alist-comb) - (progn - (setq template (nth (if item 2 1) - (assoc env cdlatex-env-alist-comb))) - (if (string= (substring template 0 2) "\\\\") - ;; Need a double backslash to teminate previous item - (progn - (setq template (substring template 2)) - (if (not (save-excursion - (re-search-backward "\\\\\\\\[ \t\n]*\\=" - (- (point) 20) t))) - (save-excursion - (skip-chars-backward " \t\n") - (insert "\\\\"))))) - (insert template)) - (insert "\\begin{" env "}\n?\n\\end{" env "}\n")) - (move-marker endmarker (point)) - - ;; Look for AUTOFILE requests - (goto-char begpos) - (while (search-forward "AUTOFILE" (marker-position endmarker) t) - (backward-delete-char 8) - (call-interactively 'cdlatex-insert-filename)) - - ;; Look for AUTOLABEL requests - (goto-char begpos) - (while (search-forward "AUTOLABEL" (marker-position endmarker) t) - (backward-delete-char 9) - (if (and auto-label (fboundp 'reftex-label)) - (reftex-label env) - (save-excursion - (beginning-of-line 1) - (if (looking-at "[ \t]*\n") - (kill-line 1))))) - - ;; Position cursor at the first question-mark - (goto-char begpos) - (if (search-forward "?" (marker-position endmarker) t) - (backward-delete-char 1)))) - -(defun cdlatex-item () - "Insert an \\item and provide a label if the environments supports that. -In eqnarrays this inserts a new line with two ampersands. It will also -add two backslashes to the previous line if required." - (interactive) - (let* ((env (car (car (reftex-what-environment t)))) - (envl (assoc env cdlatex-env-alist-comb))) - - (if (not env) (error "No open environment at point.")) - (if (or (< (length envl) 3) - (null (nth 2 envl)) - (and (stringp (nth 2 envl)) - (string= (nth 2 envl) ""))) - (error "No item defined for %s environment." env)) - (cdlatex-environment env t))) - -(defun cdlatex-comment-at-point () - ;; Return t if point is inside a TeX comment - (let ((end (point)) - (start (progn (beginning-of-line 1) (point)))) - (goto-char end) - (save-match-data - (string-match "^%\\|[^\\]%" (buffer-substring start end))))) - -(defun cdlatex-insert-filename (&optional absolute) - (interactive "P") - "Insert a file name, with completion. -The path to the file will be relative to the current directory if the file -is in the current directory or a subdirectory. Otherwise, the link will -be as completed in the minibuffer (i.e. normally relative to the users -HOME directory). -With optional prefix ABSOLUTE, insert the absolute path." - (let ((file (read-file-name "File: " nil ""))) - (let ((pwd (file-name-as-directory (expand-file-name ".")))) - (cond - (absolute - (insert (expand-file-name file))) - ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)") - (expand-file-name file)) - (insert (match-string 1 (expand-file-name file)))) - (t (insert (expand-file-name file))))))) - - -;;; =========================================================================== -;;; -;;; Math characters and modifiers - -;; The actual value of the following variable is calculated -;; by `cdlatex-compute-tables'. It holds the number of levels of math symbols -(defvar cdlatex-math-symbol-no-of-levels 1) -(defvar cdlatex-math-symbol-alist-comb nil) -(defvar cdlatex-math-modify-alist-comb nil) - -(defvar zmacs-regions) -(defun cdlatex-region-active-p () - "Is `transient-mark-mode' on and the region active? -Works on both Emacs and XEmacs." - (if (featurep 'xmeacs) - (and zmacs-regions (region-active-p)) - (and transient-mark-mode mark-active))) - -(defun cdlatex-math-symbol () - "Read a char from keyboard and insert corresponding math char. -The combinations are defined in `cdlatex-math-symbol-alist'. If not in a LaTeX -math environment, you also get a pair of dollars." - (interactive) - (let* ((cell (cdlatex-read-char-with-help - cdlatex-math-symbol-alist-comb - 1 cdlatex-math-symbol-no-of-levels - "Math symbol level %d of %d: " - "AVAILABLE MATH SYMBOLS. [%c]=next level " - cdlatex-math-symbol-prefix - (get 'cdlatex-math-symbol-alist-comb 'cdlatex-bindings))) - (char (car cell)) - (level (cdr cell)) - (entry (assoc char cdlatex-math-symbol-alist-comb)) - (symbol (nth level entry))) - - (if (or (not symbol) - (not (stringp symbol)) - (equal symbol "")) - (error "No such math symbol %c on level %d" char level)) - - (if (or (not (texmathp)) - (cdlatex-number-of-backslashes-is-odd)) - (cdlatex-dollar)) - - (insert symbol) - (when (string-match "\\?" symbol) - (cdlatex-position-cursor)))) - -(defun cdlatex-read-char-with-help (alist start-level max-level prompt-format - header-format prefix bindings) - "Read a char from keyboard and provide help if necessary." - (interactive) - (let (char (help-is-on nil) - (level start-level)) - (catch 'exit - (save-window-excursion - (while t - (if help-is-on - (progn - (cdlatex-turn-on-help - (concat (format header-format prefix) - (if (assoc level bindings) - (concat " Direct binding are `" - (cdr (assoc level bindings)) "' etc.") - "")) - level alist help-is-on nil))) - (message prompt-format level max-level) - (if (and (not help-is-on) - (sit-for cdlatex-auto-help-delay)) - (setq char ?\?) - (setq char (read-char))) - (cond - ((= char ?\C-g) - (keyboard-quit)) - ((= char ?\?) - (if help-is-on - (progn - (setq help-is-on (+ help-is-on (- (window-height) 1))) - (if (> help-is-on (count-lines (point-min) (point-max))) - (setq help-is-on 1))) - (setq help-is-on 1))) - ((or (= char ?\ ) - (equal char prefix)) - (setq level (if (= level cdlatex-math-symbol-no-of-levels) - 1 - (1+ level)))) - (t (throw 'exit (cons char level))))))))) - -;;; The following code implements the possibility to modify a character -;;; by an accent or style when point is behind it. This is more naturally -;;; then the usual way. E.g. \tilde{a} can be typed as a'~ - -(defun cdlatex-math-modify (arg) - "Modify previous char/group/macro with math accent/style. -This macro modifies the character or TeX macro or TeX group BEFORE point -with a math accent or a style. -If the character before point is white space, an empty modifying form -is inserted and the cursor positioned properly. -If the object before point looks like word, this macro modifies the last -character of it. -All this happens only, when the cursor is actually inside a LaTeX math -environment. In normal text, it does just a self-insert. -The accent and style commands and their properties are defined in the -constant `cdlatex-math-modify-alist'." - (interactive "P") - (catch 'exit - - (let ((inside-math (texmathp)) - (win (selected-window)) - char (help-is-on nil) ass acc rmdot it cmd extrabrac) - (catch 'exit1 - (save-window-excursion - (while t - (if help-is-on - (progn - (cdlatex-turn-on-help - "AVAILABLE MODIFIERS. (?=SCROLL)" - (if inside-math 1 2) - cdlatex-math-modify-alist-comb help-is-on t) - (message "Math modify: ")) - (message "Math modify: (?=HELP)")) - - (if (and (not help-is-on) - (sit-for cdlatex-auto-help-delay)) - (setq char ?\?) - (setq char (read-char))) - - (cond - ((= char ?\C-g) - (keyboard-quit)) - ((= char ?\?) - (if help-is-on - (progn - (setq help-is-on (+ help-is-on (- (window-height) 1))) - (if (> help-is-on (count-lines (point-min) (point-max))) - (setq help-is-on 1))) - (setq help-is-on 1))) - ((equal char cdlatex-math-modify-prefix) - (select-window win) - (insert cdlatex-math-modify-prefix) - (message "") - (throw 'exit t)) - (t (throw 'exit1 t)))))) - (message "") - (setq ass (assoc char cdlatex-math-modify-alist-comb)) - (if (not ass) - (progn - (insert cdlatex-math-modify-prefix char) - (throw 'exit t))) - (setq ass (cdr ass)) - (setq cmd (nth (if inside-math 0 1) ass)) - (setq acc (nth 2 ass)) - (setq rmdot (nth 3 ass)) - (setq it (nth 4 ass)) - (if (not cmd) (error "No such modifier `%c' %s math mode." char - (if inside-math "inside" "outside"))) - (cond - ((cdlatex-region-active-p) - (let ((beg (min (region-beginning) (region-end))) - (end (max (region-beginning) (region-end)))) - (goto-char end) - (point-to-register ?x) - (goto-char beg) - (insert "{") - (if acc (forward-char -1)) - (insert cmd) - (if (not acc) (insert " ")) - (register-to-point ?x) - (insert "}"))) - (arg - (point-to-register ?x) - (backward-word arg) - (insert "{") - (if acc (forward-char -1)) - (insert cmd) - (if (not acc) (insert " ")) - (register-to-point ?x) - (insert "}")) - ((or (bolp) - (not cdlatex-modify-backwards) - (memq (preceding-char) '(?\ ?$ ?- ?{ ?\( ))) - ;; Just insert empty form and position cursor - (if acc - (insert cmd "{?") - (insert "{" cmd " ?")) - (if it (insert "\\/")) - (insert "}") - (search-backward "?") - (delete-char 1)) - (t - ;; Modify preceding character or word - (point-to-register ?x) - (if (= (preceding-char) ?\}) - ;; its a group - (progn (setq extrabrac nil) - (backward-list 1) - (if (not acc) (forward-char 1))) - ;; not a group - (forward-char -1) - (if (looking-at "[a-zA-Z]") - ;; a character: look if word or macro - (progn - (setq extrabrac t) - (re-search-backward "[^a-zA-Z]") - (cond - ((= (following-char) ?\\)) - ((not inside-math) (forward-char 1)) - (t (register-to-point ?x) - (forward-char -1) - (if (and rmdot (looking-at "[ij]")) - (progn (insert "\\") - (forward-char 1) - (insert "math") - (point-to-register ?x) - (forward-char -6)))))) - (setq extrabrac t))) - (if extrabrac (progn (insert "{") - (if acc (forward-char -1)))) - (insert cmd) - (if (not acc) (insert " ")) - (register-to-point ?x) - (if extrabrac (insert "}"))))))) - -;;; And here is the help function for the symbol insertions stuff - -(defun cdlatex-turn-on-help (header level alist offset &optional sparse) - ;; Show help-window for alist - (let ((cnt 0) (all-chars "") - (flock (cdlatex-use-fonts)) this-char value) - (if sparse - (setq all-chars (concat (mapcar 'car alist))) - (setq all-chars "aA0 bB1!cC2@dD3#eE4$fF5%gG6^hH7&iI8 -jJ9?kK+~lL-_mM*|nN/\\oO=\"pP()qQ[]rR{}sS<>tT`'uU.:vV - -wW - -xX - -yY - -zZ - -")) - (if (get-buffer-window " *CDLaTeX Help*") - (select-window (get-buffer-window " *CDLaTeX Help*")) - (switch-to-buffer-other-window " *CDLaTeX Help*")) - (erase-buffer) - (make-local-variable 'truncate-lines) - (setq truncate-lines t) - (insert (concat header "\n\n")) - - (while (not (equal "" all-chars)) - (setq cnt (1+ cnt)) - (setq this-char (string-to-char all-chars)) - (setq all-chars (substring all-chars 1)) - (cond - ( (= this-char ?\?) - (setq value "SCROLL")) - ( (= this-char ?\C-m) - (setq this-char ?\ ) - (setq value "")) - ( t - (setq value (nth level (assoc this-char alist))) - (if (not value) (setq value "")))) - (setq this-char (char-to-string this-char) - value (if (> (length value) 15) - (concat (substring value 0 13) "..") - (substring (concat value " ") 0 15))) - (if flock - (put-text-property 0 15 - 'face 'font-lock-keyword-face value)) - - (insert this-char " " value " ") - (if (= (* 4 (/ cnt 4)) cnt) (insert "\n"))) - (unless (one-window-p t) - (enlarge-window (1+(- (count-lines 1 (point)) (window-height))))) - (goto-char (point-min)) (forward-line (1- offset)) - (beginning-of-line 1) - (recenter 0))) - -;;; --------------------------------------------------------------------------- -;;; -;;; Data Section: Definition of large constants - -(defconst cdlatex-command-alist-default - '( - ("pref" "Make page reference" - "" reftex-reference nil t t) - ("ref" "Make reference" - "" reftex-reference nil t t) - - ("lbl" "Insert automatic label at point" - "" reftex-label nil t t) - - ("ct" "Insert \\cite" - "\\cite{?}" cdlatex-position-cursor nil t nil) - ("cte" "Make a citation interactively" - "" reftex-citation nil t nil) - ("cite{" "Make a citation interactively" - "cite{" reftex-citation nil t nil) - - ("beg" "Complete an environment name and insert template" - "" cdlatex-environment nil t t) - ("env" "Complete an environment name and insert template" - "" cdlatex-environment nil t t) - ("it" "New item in current environment" - "" cdlatex-item nil t t) - ("ite" "Insert an ITEMIZE environment template" - "" cdlatex-environment ("itemize") t nil) - ("enu" "Insert an ENUMERATE environment template" - "" cdlatex-environment ("enumerate") t nil) - ("equ" "Insert an EQUATION environment template" - "" cdlatex-environment ("equation") t nil) - ("eqn" "Insert an EQUATION environment template" - "" cdlatex-environment ("eqnarray") t nil) - ("ali" "Insert an ALIGN environment template" - "" cdlatex-environment ("align") t nil) - ("ali*" "Insert an ALIGN* environment template" - "" cdlatex-environment ("align*") t nil) - ("alit" "Insert an ALIGNAT environment template" - "" cdlatex-environment ("alignat") t nil) - ("alit*" "Insert an ALIGNAT* environment template" - "" cdlatex-environment ("alignat*") t nil) - ("xal" "Insert a XALIGNAT environment template" - "" cdlatex-environment ("xalignat") t nil) - ("xal*" "Insert a XALIGNAT* environment template" - "" cdlatex-environment ("xalignat*") t nil) - ("xxa" "Insert a XXALIGNAT environment template" - "" cdlatex-environment ("xxalignat") t nil) - ("xxa*" "Insert a XXALIGNAT environment template" - "" cdlatex-environment ("xxalignat") t nil) - ("mul" "Insert a MULTINE environment template" - "" cdlatex-environment ("multline") t nil) - ("mul*" "Insert a MULTINE* environment template" - "" cdlatex-environment ("multline*") t nil) - ("gat" "Insert a GATHER environment template" - "" cdlatex-environment ("gather") t nil) - ("gat*" "Insert a GATHER* environment template" - "" cdlatex-environment ("gather*") t nil) - ("fla" "Insert a FLALIGN environment template" - "" cdlatex-environment ("flalign") t nil) - ("fla*" "Insert a FLALIGN* environment template" - "" cdlatex-environment ("flalign*") t nil) - ("fg" "Insert a FIGURE environment template" - "" cdlatex-environment ("figure") t nil) - - - ("sn" "Insert a \\section{} statement" - "\\section{?}" cdlatex-position-cursor nil t nil) - ("ss" "Insert a \\subsection{} statement" - "\\subsection{?}" cdlatex-position-cursor nil t nil) - ("sss" "Insert a \\subsubsection{} statement" - "\\subsubsection{?}" cdlatex-position-cursor nil t nil) - ("pf" "Insert a \\paragraph{} statement" - "\\paragraph{?}" cdlatex-position-cursor nil t nil) - ("sp" "Insert a \\subparagraph{} statement" - "\\subparagraph{?}" cdlatex-position-cursor nil t nil) - ("ssp" "Insert a \\subsubparagraph{} statement" - "\\subsubparagraph{?}" cdlatex-position-cursor nil t nil) - - ("cl" "Insert \\centerline" - "\\centerline{?}" cdlatex-position-cursor nil t nil) - ("inc" "Insert \\includegraphics with file name" - "\\includegraphics[]{?}" (lambda () - (cdlatex-position-cursor) - (call-interactively 'cdlatex-insert-filename) - (forward-char 1)) - nil t nil) - ("lr(" "Insert a \\left( \\right) pair" - "(" cdlatex-lr-pair nil nil t) - ("lr[" "Insert a \\left[ \\right] pair" - "[" cdlatex-lr-pair nil nil t) - ("lr{" "Insert a \\left{ \\right} pair" - "{" cdlatex-lr-pair nil nil t) - ("lr<" "Insert a \\left\\langle \\right\\rangle pair" - "<" cdlatex-lr-pair nil nil t) - ("lr|" "Insert a \\left| \\right| pair" - "|" cdlatex-lr-pair nil nil t) - ("caseeq" "Insert a = { construct" - "\\left\\{ \n\\begin{array}{l@{\\quad:\\quad}l}\n? & \\\\\n & \n\\end{array}\\right." cdlatex-position-cursor nil nil t) - ("fr" "Insert \\frac{}{}" - "\\frac{?}{}" cdlatex-position-cursor nil nil t) - ("sq" "Insert \\sqrt{}" - "\\sqrt{?}" cdlatex-position-cursor nil nil t) - ("intl" "Insert \\int\\limits_{}^{}" - "\\int\\limits_{?}^{}" cdlatex-position-cursor nil nil t) - ("suml" "Insert \\sum\\limits_{}^{}" - "\\sum\\limits_{?}^{}" cdlatex-position-cursor nil nil t) - ("nonum" "Insert \\nonumber\\\\" - "\\nonumber\\\\\n" nil nil nil t) - ("fn" "Make a footnote" - "\\footnote{?}" cdlatex-position-cursor nil t nil) - ("qq" "Insert \\quad" - "\\quad" nil nil t t) - ("qqq" "Insert \\qquad" - "\\qquad" nil nil t t) - ) - "Default for cdlatex-command-alist.") - -(defconst cdlatex-math-modify-alist-default - '( - ( ?\. "\\dot" nil t t nil ) - ( ?\: "\\ddot" nil t t nil ) - ( ?\~ "\\tilde" nil t t nil ) - ( ?N "\\widetilde" nil t t nil ) - ( ?^ "\\hat" nil t t nil ) - ( ?H "\\widehat" nil t t nil ) - ( ?\- "\\bar" nil t t nil ) - ( ?T "\\overline" nil t nil nil ) - ( ?\_ "\\underline" nil t nil nil ) - ( ?\{ "\\overbrace" nil t nil nil ) - ( ?\} "\\underbrace" nil t nil nil ) - ( ?\> "\\vec" nil t t nil ) - ( ?/ "\\grave" nil t t nil ) - ( ?\\ "\\acute" nil t t nil ) - ( ?v "\\check" nil t t nil ) - ( ?u "\\breve" nil t t nil ) - ( ?m "\\mbox" nil t nil nil ) - ( ?c "\\mathcal" nil t nil nil ) - ( ?r "\\mathrm" "\\textrm" t nil nil ) - ( ?i "\\mathit" "\\textit" t nil nil ) - ( ?l nil "\\textsl" t nil nil ) - ( ?b "\\mathbf" "\\textbf" t nil nil ) - ( ?e "\\mathem" "\\emph" t nil nil ) - ( ?y "\\mathtt" "\\texttt" t nil nil ) - ( ?f "\\mathsf" "\\textsf" t nil nil ) - ( ?0 "\\textstyle" nil nil nil nil ) - ( ?1 "\\displaystyle" nil nil nil nil ) - ( ?2 "\\scriptstyle" nil nil nil nil ) - ( ?3 "\\scriptscriptstyle" nil nil nil nil ) - ) - "Default for cdlatex-math-modify-alist.") - -(defconst cdlatex-math-symbol-alist-default - '( - ( ?a ("\\alpha" )) - ( ?A ("\\forall" "\\aleph")) - ( ?b ("\\beta" )) - ( ?B ("" )) - ( ?c ("" "" "\\cos")) - ( ?C ("" "" "\\arccos")) - ( ?d ("\\delta" "\\partial")) - ( ?D ("\\Delta" "\\nabla")) - ( ?e ("\\epsilon" "\\varepsilon" "\\exp")) - ( ?E ("\\exists" "" "\\ln")) - ( ?f ("\\phi" "\\varphi")) - ( ?F ("" )) - ( ?g ("\\gamma" "" "\\lg")) - ( ?G ("\\Gamma" "" "10^{?}")) - ( ?h ("\\eta" "\\hbar")) - ( ?H ("" )) - ( ?i ("\\in" "\\imath")) - ( ?I ("" "\\Im")) - ( ?j ("" "\\jmath")) - ( ?J ("" )) - ( ?k ("\\kappa" )) - ( ?K ("" )) - ( ?l ("\\lambda" "\\ell" "\\log")) - ( ?L ("\\Lambda" )) - ( ?m ("\\mu" )) - ( ?M ("" )) - ( ?n ("\\nu" "" "\\ln")) - ( ?N ("\\nabla" "" "\\exp")) - ( ?o ("\\omega" )) - ( ?O ("\\Omega" "\\mho")) - ( ?p ("\\pi" "\\varpi")) - ( ?P ("\\Pi" )) - ( ?q ("\\theta" "\\vartheta")) - ( ?Q ("\\Theta" )) - ( ?r ("\\rho" "\\varrho")) - ( ?R ("" "\\Re")) - ( ?s ("\\sigma" "\\varsigma" "\\sin")) - ( ?S ("\\Sigma" "" "\\arcsin")) - ( ?t ("\\tau" "" "\\tan")) - ( ?T ("" "" "\\arctan")) - ( ?u ("\\upsilon" )) - ( ?U ("\\Upsilon" )) - ( ?v ("\\vee" )) - ( ?V ("\\Phi" )) - ( ?w ("\\xi" )) - ( ?W ("\\Xi" )) - ( ?x ("\\chi" )) - ( ?X ("" )) - ( ?y ("\\psi" )) - ( ?Y ("\\Psi" )) - ( ?z ("\\zeta" )) - ( ?Z ("" )) - ( ? ("" )) - ( ?0 ("\\emptyset" )) - ( ?1 ("" )) - ( ?2 ("" )) - ( ?3 ("" )) - ( ?4 ("" )) - ( ?5 ("" )) - ( ?6 ("" )) - ( ?7 ("" )) - ( ?8 ("\\infty" )) - ( ?9 ("" )) - ( ?! ("\\neg" )) - ( ?@ ("" )) - ( ?# ("" )) - ( ?$ ("" )) - ( ?% ("" )) - ( ?^ ("\\uparrow" )) - ( ?& ("\\wedge" )) - ( ?\? ("" )) - ( ?~ ("\\approx" "\\simeq")) - ( ?_ ("\\downarrow" )) - ( ?+ ("\\cup" )) - ( ?- ("\\leftrightarrow" "\\longleftrightarrow" )) - ( ?* ("\\times" )) - ( ?/ ("\\not" )) - ( ?| ("\\mapsto" "\\longmapsto")) - ( ?\\ ("\\setminus" )) - ( ?\" ("" )) - ( ?= ("\\Leftrightarrow" "\\Longleftrightarrow")) - ( ?\( ("\\langle" )) - ( ?\) ("\\rangle" )) - ( ?\[ ("\\Leftarrow" "\\Longleftarrow")) - ( ?\] ("\\Rightarrow" "\\Longrightarrow")) - ( ?{ ("\\subset" )) - ( ?} ("\\supset" )) - ( ?< ("\\leftarrow" "\\longleftarrow" "\\min")) - ( ?> ("\\rightarrow" "\\longrightarrow" "\\max")) - ( ?` ("" )) - ( ?' ("\\prime" )) - ( ?. ("\\cdot" )) - ) - "Default for cdlatex-math-symbol-alist." - ) - -;;; --------------------------------------------------------------------------- - -(defconst cdlatex-env-alist-default - '( -;;------------------------------------ -( "abstract" -"\\begin{abstract} -? -\\end{abstract}" -nil -) -;;------------------------------------ -( "appendix" -"\\begin{appendix} -? -\\end{appendix}" -nil -) -;;------------------------------------ -( "array" -"\\begin{array}[tb]{?lcrp{width}*{num}{lcrp{}}|} - & & & \\\\ -\\end{array}" -" & & &" -) -;;------------------------------------ -( "center" -"\\begin{center} -? \\\\ -\\end{center}" -nil -) -;;------------------------------------ -( "deflist" -"\\begin{deflist}{width-text} -\\item ? -\\end{deflist}" -"\\item ?" -) -;;------------------------------------ -( "description" -"\\begin{description} -\\item[?] -\\end{description}" -"\\item[?] " -) -;;------------------------------------ -( "displaymath" -"\\begin{displaymath} -? -\\end{displaymath}" -nil -) -;;------------------------------------ -( "document" -"\\begin{document} -? -\\end{document}" -nil -) -;;------------------------------------ -( "enumerate" -"\\begin{enumerate} -\\itemAUTOLABEL ? -\\end{enumerate}" -"\\itemAUTOLABEL ?" -) -;;------------------------------------ -( "eqnarray" -"\\begin{eqnarray} -AUTOLABEL -? & & \\\\ -\\end{eqnarray}" -"\\\\AUTOLABEL -? & & " -) -;;------------------------------------ -( "eqnarray*" -"\\begin{eqnarray*} -? & & \\\\ -\\end{eqnarray*}" -"\\\\? & & " -) -;;------------------------------------ -( "equation" -"\\begin{equation} -AUTOLABEL -? -\\end{equation}" -nil -) -;;------------------------------------ -( "figure" -"\\begin{figure}[htbp] -\\centerline{\\includegraphics[]{AUTOFILE}} -\\caption[]{AUTOLABEL ?} -\\end{figure}" -nil -) -;;------------------------------------ -( "figure*" -"\\begin{figure*}[htbp] -\\centerline{\includegraphics[]{AUTOFILE} -\\end{figure*}" -nil -) -;;------------------------------------ -( "flushleft" -"\\begin{flushleft} -? \\\\ -\\end{flushleft}" -"\\\\?" -) -;;------------------------------------ -( "flushright" -"\\begin{flushright} -? \\\\ -\\end{flushright}" -"\\\\?" -) -;;------------------------------------ -( "fussypar" -"\\begin{fussypar} -? -\\end{fussypar}" -nil -) -;;------------------------------------ -( "itemize" -"\\begin{itemize} -\\item ? -\\end{itemize}" -"\\item ?" -) -;;------------------------------------ -( "letter" -"\\begin{letter} -? -\\end{letter}" -nil -) -;;------------------------------------ -( "list" -"\\begin{list}{}{} -\\item ? -\\end{list}" -"\\item ?" -) -;;------------------------------------ -( "math" -"\\begin{math} -? -\\end{math}" -nil -) -;;------------------------------------ -( "minipage" -"\\begin{minipage}[bt]{?.cm} - -\\end{minipage}" -nil -) -;;------------------------------------ -( "picture" -"\\begin{picture}(,)(,) -? -\\end{picture}" -nil -) -;;------------------------------------ -( "quotation" -"\\begin{quotation} -? -\\end{quotation}" -nil -) -;;------------------------------------ -( "quote" -"\\begin{quote} -? -\\end{quote}" -nil -) -;;------------------------------------ -( "sloppypar" -"\\begin{sloppypar} -? -\\end{sloppypar}" -nil -) -;;------------------------------------ -( "tabbing" -"\\begin{tabbing} -? \\= \\= \\= \\= \\\\[0.5ex] - \\> \\> \\> \\> \\\\ -\\end{tabbing}" -"\\\\?" -) -;;------------------------------------ -( "table" -"\\begin{table}[htbp] -\\caption[]{AUTOLABEL ?} -\\vspace{4mm} - -\\end{table}" -nil -) -;;------------------------------------ -( "tabular" -"\\begin{tabular}[tb]{lcrp{width}*{num}{lcrp{}}|} -? -\\end{tabular}" -nil -) -;;------------------------------------ -( "tabular*" -"\\begin{tabular*}{width}[tb]{lcrp{width}*{num}{lcrp{}}|} -? -\\end{tabular*}" -nil -) -;;------------------------------------ -( "thebibliography" -"\\begin{thebibliography}{} - -\\bibitem[?]{} - -\\end{thebibliography}" -" -\\bibitem[?]{} -") -;;------------------------------------ -( "theindex" -"\\begin{theindex} -? -\\end{theindex}" -nil -) -;;------------------------------------ -( "titlepage" -"\\begin{titlepage} - -\\title{?} - -\\author{ - \\\\ - \\\\ -%\\thanks{} -%\\and -} - -\\date{\\today} - -\\end{titlepage}" -nil -) -;;------------------------------------ -( "trivlist" -"\\begin{trivlist} -? -\\end{trivlist}" -nil -) -;;------------------------------------ -( "verbatim" -"\\begin{verbatim} -? -\\end{verbatim}" -nil -) -;;------------------------------------ -( "verbatim*" -"\\begin{verbatim*} -? -\\end{verbatim*}" -nil -) -;;------------------------------------ -( "verse" -"\\begin{verse} -? \\\\ -\\end{verse}" -nil -) -;;------------------------------------ -;; AMS-LaTeX -( "align" -"\\begin{align} -AUTOLABEL -? -\\end{align}" -"\\\\AUTOLABEL -?") -;;------------------------------------ -( "align*" -"\\begin{align*} -? -\\end{align*}" -"\\\\?") -;;------------------------------------ -( "alignat" -"\\begin{alignat}{?} -AUTOLABEL - -\\end{alignat}" -"\\\\AUTOLABEL -?") -;;------------------------------------ -( "alignat*" -"\\begin{alignat*}{?} - -\\end{alignat*}" -"\\\\?") -;;------------------------------------ -( "xalignat" -"\\begin{xalignat}{?} -AUTOLABEL - -\\end{xalignat}" -"\\\\AUTOLABEL -?") -;;------------------------------------ -( "xalignat*" -"\\begin{xalignat*}{?} - -\\end{xalignat*}" -"\\\\?") -;;------------------------------------ -( "xxalignat" -"\\begin{xxalignat}{?} - -\\end{xxalignat}" -"\\\\?") -;;------------------------------------ -("multline" -"\\begin{multline} -AUTOLABEL -? -\\end{multline}" -"\\\\AUTOLABEL -?") -;;------------------------------------ -("multline*" -"\\begin{multline*} -? -\\end{multline*}" -"?") -;;------------------------------------ -( "flalign" -"\\begin{flalign} -AUTOLABEL -? -\\end{flalign}" -"\\\\AUTOLABEL -?" -) -;;------------------------------------ -( "flalign*" -"\\begin{flalign*} -? -\\end{flalign*}" -"\\\\?" -) -;;------------------------------------ -( "gather" -"\\begin{gather} -AUTOLABEL -? -\\end{gather}" -"\\\\AUTOLABEL -?") -;;------------------------------------ -( "gather*" -"\\begin{gather*} -? -\\end{gather*}" -"\\\\?") -;;------------------------------------ -;;; SOME NON-STANDARD ENVIRONMENTS -;; figure environment for the epsf macro package -( "epsfigure" -"\\begin{figure}[htbp] -\\centerline{\\epsfxsize=\\textwidth \\epsffile{?.eps}} -\\caption[]{AUTOLABEL} -\\end{figure}" -nil -) -;;------------------------------------ -;; table environment for AASTeX -( "deluxetable" -"\\begin{deluxetable}{?lcrp{width}*{num}{lcrp{}}} -\\tablecolumns{} -\\tablewidth{0pt} -\\tablecaption{AUTOLABEL } -\\tablehead{ \\colhead{} & \colhead{} & \\multicolumn{3}{c}{} } -\\startdata - & & \\nl -\\enddata -\\end{deluxetable}" -nil -) -;;------------------------------------ -;; figure environments for A&A -( "aafigure" -"\\begin{figure} -\\resizebox{\\hsize}{!}{\\includegraphics{?.eps}} -\\caption[]{AUTOLABEL} -\\end{figure}" -nil -) -;;------------------------------------ -( "aafigure*" -"\\begin{figure*} -\\resizebox{12cm}{!}{\\includegraphics{?.eps}} -\\caption[]{AUTOLABEL} -\\end{figure*}" -nil -) -)) - -;;; --------------------------------------------------------------------------- -;;; -;;; Functions to compile the tables, reset the mode etc. - -(defun cdlatex-reset-mode () - "Reset CDLaTeX Mode. Required to implement changes to some list variables. -This function will compile the information in `cdlatex-label-alist' and similar -variables. It is called when CDLaTeX is first used, and after changes to -these variables via `cdlatex-add-to-label-alist'." - (interactive) - (cdlatex-compute-tables)) - - -(defun cdlatex-compute-tables () - ;; Update tables not connected with ref and cite support - - (setq cdlatex-env-alist-comb - (cdlatex-uniquify - (append cdlatex-env-alist - cdlatex-env-alist-default))) - ;; Merge the user specified lists with the defaults - (setq cdlatex-command-alist-comb - (cdlatex-uniquify - (append cdlatex-command-alist - cdlatex-command-alist-default))) - (setq cdlatex-math-symbol-alist-comb - (cdlatex-uniquify - (mapcar (lambda (x) - (if (listp (nth 1 x)) - (cons (car x) (nth 1 x)) - x)) - (append cdlatex-math-symbol-alist - cdlatex-math-symbol-alist-default)))) - (setq cdlatex-math-modify-alist-comb - (cdlatex-uniquify - (append cdlatex-math-modify-alist - cdlatex-math-modify-alist-default))) - - ;; find out how many levels are needed for the math symbol stuff - (let ((maxlev 0) (list cdlatex-math-symbol-alist-comb) entry) - (while (setq entry (pop list)) - (setq maxlev (max maxlev (length (nth 1 list))) - list (cdr list))) - (setq cdlatex-math-symbol-no-of-levels (1- maxlev))) - - ;; The direct key bindings. - (let (map dummy-map prefix modifiers symbol bindings) - (loop for level from 1 to cdlatex-math-symbol-no-of-levels do - (setq dummy-map (make-sparse-keymap)) - (setq prefix (car (nth (1- level) - cdlatex-math-symbol-direct-bindings))) - (setq modifiers (cdr - (nth (1- level) - cdlatex-math-symbol-direct-bindings))) - (when (or prefix modifiers) - (cond - ((stringp prefix) (setq prefix (read-kbd-macro prefix))) - ((integerp prefix) (setq prefix (vector prefix)))) - - (if (null prefix) - (setq map cdlatex-mode-map) - (setq map (make-keymap)) - (define-key cdlatex-mode-map prefix (setq map - (make-keymap)))) - (defun cdlatex-nop () (interactive)) - (define-key dummy-map - (vector (append modifiers (list ?a))) 'cdlatex-nop) - (push (cons level (substitute-command-keys - "\\\\[cdlatex-nop]")) - bindings) - (mapc (lambda (entry) - (setq symbol (nth level entry)) - (when (and symbol (stringp symbol) - (not (equal "" symbol))) - (define-key - map (vector (append modifiers (list (car entry)))) - (list 'lambda '() '(interactive) - (list 'cdlatex-insert-math symbol))))) - cdlatex-math-symbol-alist-comb))) - (put 'cdlatex-math-symbol-alist-comb 'cdlatex-bindings bindings))) - -(defun cdlatex-insert-math (string) - (cdlatex-ensure-math) - (insert string) - (if (string-match "\\?" string) - (cdlatex-position-cursor))) - -;;; Keybindings -------------------------------------------------------------- - -(define-key cdlatex-mode-map "$" 'cdlatex-dollar) -(define-key cdlatex-mode-map "(" 'cdlatex-pbb) -(define-key cdlatex-mode-map "{" 'cdlatex-pbb) -(define-key cdlatex-mode-map "[" 'cdlatex-pbb) -(define-key cdlatex-mode-map "|" 'cdlatex-pbb) -(define-key cdlatex-mode-map "<" 'cdlatex-pbb) -(define-key cdlatex-mode-map "^" 'cdlatex-sub-superscript) -(define-key cdlatex-mode-map "_" 'cdlatex-sub-superscript) - -(define-key cdlatex-mode-map "\t" 'cdlatex-tab) -(define-key cdlatex-mode-map "\C-c?" 'cdlatex-command-help) -(define-key cdlatex-mode-map "\C-c{" 'cdlatex-environment) -(define-key cdlatex-mode-map [(control return)] 'cdlatex-item) - -(define-key cdlatex-mode-map - (cdlatex-get-kbd-vector cdlatex-math-symbol-prefix) - 'cdlatex-math-symbol) -(define-key cdlatex-mode-map - (cdlatex-get-kbd-vector cdlatex-math-modify-prefix) - 'cdlatex-math-modify) - -;;; Menus -------------------------------------------------------------------- - -;; Define a menu for the menu bar if Emacs is running under X - -(require 'easymenu) - -(easy-menu-define - cdlatex-mode-menu cdlatex-mode-map - "Menu used in CDLaTeX mode" - '("CDLTX" - ["\\begin{...} \\label" cdlatex-environment t] - ["\\item \\label" cdlatex-item t] - "----" - ["Insert Math Symbol" cdlatex-math-symbol t] - ["Modify Math Symbol" cdlatex-math-modify t] - "----" - ("Customize" - ["Browse CDLaTeX group" cdlatex-customize t] - "---" - ["Build Full Customize Menu" cdlatex-create-customize-menu - (fboundp 'customize-menu-create)]) - "----" - ["Show documentation" cdlatex-show-commentary t] - ["Help with KEYWORD Cmds" cdlatex-command-help t] - ["Reset CDLaTeX Mode" cdlatex-reset-mode t])) - -;(eval-after-load "cus-edit" -; '(and (fboundp 'customize-menu-create) (cdlatex-create-customize-menu))) - -;;; Run Hook ------------------------------------------------------------------ - -(run-hooks 'cdlatex-load-hook) - -;;; That's it! ---------------------------------------------------------------- - -; Make sure tabels are compiled -(cdlatex-compute-tables) - -(provide 'cdlatex) - -;;;============================================================================ - -;;; cdlatex.el ends here diff --git a/dotfiles/doom/my-abbreviations.el b/dotfiles/doom/my-abbreviations.el deleted file mode 100644 index e69de29..0000000 diff --git a/dotfiles/doom/packages.el b/dotfiles/doom/packages.el deleted file mode 100644 index a06104b..0000000 --- a/dotfiles/doom/packages.el +++ /dev/null @@ -1,12 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; $DOOMDIR/packages.el - -(package! org-noter) -(package! poet-theme) -(package! org-alert) -(package! org-gcal) -(package! ox-latex-subfigure - :recipe (:host github :repo "linktohack/ox-latex-subfigure")) -(package! matlab-mode - :recipe (:host github :repo "matlab-mode/mirror")) -(package! org-ref)