2019-05-16 21:28:33 +02:00
|
|
|
#+TITLE: Spacemacs configuration
|
|
|
|
#+PROPERTY: header-args:emacs-lisp :comments link :results silent
|
|
|
|
|
|
|
|
* User Init
|
2019-05-16 21:39:04 +02:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args:emacs-lisp+: :tangle ~/.spacemacs.d/user-init.el
|
|
|
|
:END:
|
|
|
|
|
2019-05-16 21:28:33 +02:00
|
|
|
** Melpa
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(add-to-list 'package-archives '("melpa" . "http://www.mirrorservice.org/sites/melpa.org/packages/"))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Ispell
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq ispell-program-name "/usr/bin/aspell")
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Org latex fragment
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(defvar kk/org-latex-fragment-last nil
|
|
|
|
"Holds last fragment/environment you were on.")
|
|
|
|
|
|
|
|
(defun kk/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 kk/org-latex-fragment-toggle ()
|
|
|
|
"Toggle a latex fragment image "
|
|
|
|
(and (eq 'org-mode major-mode)
|
|
|
|
(let ((begin (kk/org-in-latex-fragment-p)))
|
|
|
|
(cond
|
|
|
|
;; were on a fragment and now on a new fragment
|
|
|
|
((and
|
|
|
|
;; fragment we were on
|
|
|
|
kk/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 kk/org-latex-fragment-last
|
|
|
|
(= begin
|
|
|
|
kk/org-latex-fragment-last))))
|
|
|
|
;; go back to last one and put image back, provided there is still a fragment there
|
|
|
|
(save-excursion
|
|
|
|
(goto-char kk/org-latex-fragment-last)
|
|
|
|
(when (kk/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
|
|
|
|
(<= (overlay-start ov) (point))
|
|
|
|
(>= (overlay-end ov) (point)))
|
|
|
|
return ov)))
|
|
|
|
(when ov
|
|
|
|
(delete-overlay ov)))
|
|
|
|
;; and save new fragment
|
|
|
|
(setq kk/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
|
|
|
|
kk/org-latex-fragment-last)
|
|
|
|
;; put image back on, provided that there is still a fragment here.
|
|
|
|
(save-excursion
|
|
|
|
(goto-char kk/org-latex-fragment-last)
|
|
|
|
(when (kk/org-in-latex-fragment-p) (org-preview-latex-fragment)))
|
|
|
|
|
|
|
|
;; unset last fragment
|
|
|
|
(setq kk/org-latex-fragment-last nil))
|
|
|
|
|
|
|
|
;; were not on a fragment, and now are
|
|
|
|
((and
|
|
|
|
;; we were not one one
|
|
|
|
(not kk/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 kk/org-latex-fragment-last begin))))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Default Browser
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq browse-url-browser-function 'browse-url-generic
|
|
|
|
browse-url-generic-program "qutebrowser")
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
* User-Config
|
|
|
|
:PROPERTIES:
|
|
|
|
:header-args:emacs-lisp+: :tangle ~/.spacemacs.d/user-config.el
|
|
|
|
:END:
|
2019-05-16 21:28:33 +02:00
|
|
|
** Others
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
;; Line Wrapping
|
|
|
|
(spacemacs/toggle-truncate-lines-on)
|
|
|
|
|
|
|
|
;; Visual line navigation for textual modes
|
|
|
|
(add-hook 'text-mode-hook 'spacemacs/toggle-visual-line-navigation-on)
|
|
|
|
|
|
|
|
;; leader-q-q just kill the frame without killink the server
|
|
|
|
(evil-leader/set-key
|
|
|
|
"q q" 'spacemacs/frame-killer)
|
|
|
|
|
|
|
|
;; Remove current light highlight
|
|
|
|
(spacemacs/toggle-highlight-current-line-globally-off)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Windows Management
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(global-set-key (kbd "<C-up>") 'shrink-window)
|
|
|
|
(global-set-key (kbd "<C-down>") 'enlarge-window)
|
|
|
|
(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)
|
|
|
|
(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)
|
|
|
|
#+END_SRC
|
2019-05-30 16:22:26 +02:00
|
|
|
|
2019-05-16 21:28:33 +02:00
|
|
|
** Lockfiles
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq create-lockfiles nil)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Autosave
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq backup-directory-alist `(("." . "~/.saves")))
|
|
|
|
(setq backup-by-copying t)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Path
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq thesis-base-path (expand-file-name "~/MEGA/These"))
|
|
|
|
(setq dropbox-base-path (expand-file-name "~/Dropbox"))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Magit
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setenv "GIT_ASKPASS" "git-gui--askpass")
|
|
|
|
|
|
|
|
(setq magit-diff-refine-hunk 'all)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** User informations
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
;; Used to the \author for LaTeX export
|
|
|
|
(setq user-full-name "Thomas Dehaeze")
|
2019-05-30 16:22:26 +02:00
|
|
|
|
2019-05-16 21:28:33 +02:00
|
|
|
;; Used to set \email for LaTeX export
|
|
|
|
(setq user-mail-address "dehaeze.thomas@gmail.com")
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Change default alert backend
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq alert-default-style 'libnotify)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** LaTeX
|
2019-05-16 21:28:33 +02:00
|
|
|
- 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
|
2019-05-30 16:22:26 +02:00
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Basic LaTeX configuration
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(defun latex/clean ()
|
|
|
|
"Clean LaTeX output using latexmk"
|
|
|
|
(interactive)
|
|
|
|
(async-shell-command
|
|
|
|
;; command and parameters
|
|
|
|
"latexmk -c "
|
|
|
|
(shell-quote-argument buffer-file-name)
|
|
|
|
" &"
|
|
|
|
))
|
|
|
|
|
|
|
|
(evil-define-key 'normal LaTeX-mode-map (kbd ", C") 'latex/clean)
|
|
|
|
|
|
|
|
(add-hook 'TeX-mode-hook #'TeX-fold-mode)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Master file
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq-default TeX-master nil)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Pdf Viewer
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-30 16:22:26 +02:00
|
|
|
** Helm-Bibtex
|
|
|
|
*** General Config
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'helm-bibtex
|
|
|
|
;; Use "tags" field when looking for bib entries
|
|
|
|
(setq helm-bibtex-additional-search-fields '(keywords))
|
|
|
|
;; Special Tags:
|
|
|
|
;; - favorite
|
|
|
|
|
|
|
|
;; Reverse the order of display
|
|
|
|
;; (advice-add 'bibtex-completion-candidates
|
|
|
|
;; :filter-return 'reverse)
|
|
|
|
|
|
|
|
;; 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 "✎")
|
|
|
|
|
|
|
|
;; Use file field to find the PDF
|
|
|
|
;; (setq bibtex-completion-pdf-field "file")
|
|
|
|
|
|
|
|
;; Bibliography file
|
|
|
|
(setq bibtex-completion-bibliography "~/MEGA/These/Ressources/references.bib")
|
|
|
|
|
|
|
|
;; Directory with all the pdfs
|
|
|
|
(setq bibtex-completion-library-path "~/MEGA/These/Ressources/pdfs")
|
|
|
|
|
|
|
|
;; Directory with notes files
|
|
|
|
(setq bibtex-completion-notes-path "~/MEGA/These/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"
|
|
|
|
"\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"
|
2019-06-22 17:34:07 +02:00
|
|
|
"#+LATEX_HEADER: \\graphicspath{{./figs/${=key=}/}}\n"
|
|
|
|
":END:\n"
|
2019-05-16 21:28:33 +02:00
|
|
|
"\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
|
|
|
|
(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
|
|
|
|
|
2019-05-30 16:22:26 +02:00
|
|
|
*** Open pdf externally
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'helm-bibtex
|
|
|
|
(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
|
|
|
|
(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
|
|
|
|
|
2019-05-30 16:22:26 +02:00
|
|
|
*** Special Commands
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(defun helm-bibtex-favorites (&optional arg)
|
|
|
|
"Search Favorite BibTeX entries"
|
|
|
|
(interactive "P")
|
|
|
|
(helm-bibtex arg nil "favorite "))
|
|
|
|
#+END_SRC
|
2019-05-16 21:39:04 +02:00
|
|
|
** Auto Complete
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(global-company-mode)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Yas Snippets
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq yas-indent-line "fixed")
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Org-Mode
|
2019-05-16 21:28:33 +02:00
|
|
|
- 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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Tagging
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; Tags with fast selection keys
|
|
|
|
(setq org-tag-alist (quote (("@christophe" . ?c)
|
|
|
|
("@muriel" . ?m))))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Gcal
|
2019-05-16 21:28:33 +02:00
|
|
|
- https://cestlaz.github.io/posts/using-emacs-26-gcal/#.WIqBud9vGAk
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-gcal-client-id "396102378658-dcmbcmrnthbe925519otsjbd921otq0v.apps.googleusercontent.com"
|
|
|
|
org-gcal-client-secret "4M5PWrbhQjwYEMXGK85lDYX9"
|
|
|
|
org-gcal-file-alist '(("dehaeze.thomas@gmail.com" . "~/Dropbox/org/gcal.org")
|
|
|
|
("udqehfhfqkecm984313pgat5192sm1cl@import.calendar.google.com" . "~/Dropbox/org/wunderlist.org")
|
|
|
|
("8kjmhe2ar0abnm054ill1fb0gc@group.calendar.google.com" . "~/Dropbox/org/gcal_phd.org")))
|
|
|
|
;; Automatic fetch of the new events
|
|
|
|
;; (add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Refile
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-refile-targets '((org-agenda-files . (:maxlevel . 6))))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Todos
|
2019-05-16 21:28:33 +02:00
|
|
|
http://sachachua.com/blog/2014/04/thinking-todo-keywords/
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; 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
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Agenda
|
|
|
|
**** General configuration
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; File to save todo items
|
|
|
|
(setq org-agenda-files (list (format "%s/%s" thesis-base-path "TODOs/")
|
|
|
|
(format "%s/%s" dropbox-base-path "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 (quote 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
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Org Agenda Custom Views
|
2019-05-16 21:28:33 +02:00
|
|
|
https://blog.aaronbieber.com/2016/09/24/an-agenda-for-life-with-org-mode.html
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(defun tdehaeze/org-agenda-skip-scheduled ()
|
|
|
|
(org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>"))
|
|
|
|
|
|
|
|
(setq org-agenda-custom-commands
|
|
|
|
'(("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 'tdehaeze/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 'tdehaeze/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 '("~/MEGA/These/Ressources/notes/")))))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO Add Custom Views for the bibliography
|
2019-05-16 21:28:33 +02:00
|
|
|
- Things reading (BOOKMARS)
|
|
|
|
- Things to read
|
|
|
|
- etc...
|
2019-06-22 17:34:07 +02:00
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Notification based on calendar event
|
2019-05-16 21:28:33 +02:00
|
|
|
https://emacs.stackexchange.com/questions/3844/good-methods-for-setting-up-alarms-audio-visual-triggered-by-org-mode-events
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** appt-notification script
|
2019-05-16 21:28:33 +02:00
|
|
|
:PROPERTIES:
|
|
|
|
:header-args: :tangle ~/bin/appt-notification
|
|
|
|
:header-args+: :comments none :mkdirp yes
|
|
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
|
|
:END:
|
|
|
|
#+begin_src bash
|
|
|
|
TIME="$1"
|
|
|
|
MSG="$2"
|
|
|
|
|
|
|
|
dunstify --replace=85401 "Event in $TIME minutes" "$MSG"
|
|
|
|
#+end_src
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Structure Template
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-structure-template-alist
|
|
|
|
'(("a" . "export ascii")
|
|
|
|
("c" . "center")
|
|
|
|
("C" . "comment")
|
|
|
|
("e" . "example")
|
|
|
|
("E" . "export")
|
|
|
|
("h" . "export html")
|
|
|
|
("l" . "export latex")
|
|
|
|
("q" . "quote")
|
|
|
|
("s" . "src")
|
|
|
|
("v" . "verse"))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Capture
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-directory "~/MEGA/These/TODOs/")
|
|
|
|
(setq org-default-notes-file "~/MEGA/These/TODOs/refile.org")
|
|
|
|
|
|
|
|
;; Capture templates for: Tasks, Notes, appointments, phone calls, meetings, and org-protocol
|
|
|
|
(setq org-capture-templates
|
|
|
|
(quote (("t" ; key
|
|
|
|
"todo" ; name
|
|
|
|
entry ; type
|
|
|
|
(file (lambda () (concat (file-name-as-directory thesis-base-path) "TODOs/refile.org"))) ; target
|
|
|
|
"* TODO %?\n%U\n" ; template
|
|
|
|
)
|
|
|
|
("m" ; key
|
|
|
|
"mail" ; name
|
|
|
|
entry ; type
|
|
|
|
(file (lambda () (format "%s/%s" thesis-base-path "TODOs/mails.org"))) ; target
|
|
|
|
"* TODO %a %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n" ; template
|
|
|
|
)
|
|
|
|
("Q" ; key
|
|
|
|
"quote org capture" ; name
|
|
|
|
entry ; type
|
|
|
|
(file+headline (lambda () (format "%s/%s" dropbox-base-path "org/refile.org")) "Unsorted") ; target
|
|
|
|
"* %?%:description Added %U\n#+BEGIN_QUOTE\n%x\n#+END_QUOTE" ; Template
|
|
|
|
:immediate-finish t ; properties
|
|
|
|
)
|
|
|
|
("c"
|
|
|
|
"Contacts"
|
|
|
|
entry
|
|
|
|
(file (lambda () (format "%s/%s" dropbox-base-path "org/contacts.org")))
|
|
|
|
"* %(org-contacts-template-name)\n :PROPERTIES:\n :EMAIL: %(org-contacts-template-email)\n :PHONE:\n :ALIAS:\n :NICKNAME:\n :IGNORE:\n :ICON:\n :NOTE:\n :ADDRESS:\n :BIRTHDAY:\n :END:")
|
|
|
|
("a" ; key
|
|
|
|
"Article" ; name
|
|
|
|
entry ; type
|
|
|
|
(file+headline (lambda () (format "%s/%s" thesis-base-path "Ressources/bibliography.org") "Article")) ; target
|
|
|
|
"* %^{Title} %(org-set-tags) :article: \n:PROPERTIES:\n:Created: %U\n:Linked: %A\n:END:\n%i\nBrief description:\n%?" ; template
|
|
|
|
:prepend t ; properties
|
|
|
|
:empty-lines 1 ; properties
|
|
|
|
:created t ; properties
|
|
|
|
)
|
|
|
|
)))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Org Publish
|
2019-05-16 21:28:33 +02:00
|
|
|
https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-publish-project-alist
|
|
|
|
'(
|
|
|
|
("tikz-maker"
|
|
|
|
:base-directory "~/MEGA/These/LaTeX/ressources/"
|
|
|
|
:base-extension "org"
|
|
|
|
:publishing-directory "~/MEGA/These/LaTeX/ressources/docs/"
|
|
|
|
:recursive t
|
|
|
|
:publishing-function org-html-publish-to-html
|
|
|
|
:headline-levels 4 ; Just the default for this project.
|
|
|
|
:auto-preamble t
|
|
|
|
)
|
|
|
|
("tikz-maker-static"
|
|
|
|
:base-directory "~/MEGA/These/LaTeX/ressources/Figures/"
|
|
|
|
:base-extension "css\\|js\\|png\\|jpg\\|svg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
|
|
|
|
:publishing-directory "~/MEGA/These/LaTeX/ressources/docs/Figures/"
|
|
|
|
:recursive t
|
|
|
|
:publishing-function org-publish-attachment
|
|
|
|
)
|
|
|
|
("org" :components ("tikz-maker" "tikz-maker-static"))
|
|
|
|
))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Babel
|
|
|
|
**** Main configuration
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; 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)
|
|
|
|
|
|
|
|
;; Enable Babel evalutation
|
|
|
|
(org-babel-do-load-languages 'org-babel-load-languages '((latex . t)
|
|
|
|
(shell . t)
|
|
|
|
(matlab . t)
|
|
|
|
(python . t)
|
|
|
|
(emacs-lisp . t)))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Library of Babel
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(org-babel-lob-ingest "~/MEGA/These/org-mode/org-babel-tutorial/org-babel-library.org")
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Matlab
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-babel-matlab-shell-command "/usr/local/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');
|
|
|
|
")
|
|
|
|
|
|
|
|
(setq org-babel-octave-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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Asynchronous execution
|
2019-05-16 21:28:33 +02:00
|
|
|
https://github.com/astahlman/ob-async
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(require 'ob-async)
|
|
|
|
#+end_src
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Theme
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(require 'color)
|
|
|
|
(set-face-attribute 'org-block nil :background (color-darken-name (face-attribute 'default :background) 3))
|
|
|
|
#+end_src
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Export
|
|
|
|
**** Basic
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; 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
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Ox Latex Subfigure package
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(use-package ox-latex-subfigure
|
|
|
|
:init
|
|
|
|
(setq org-latex-prefer-user-labels t)
|
|
|
|
:config (require 'ox-latex-subfigure))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Clear page before heading
|
2019-05-16 21:28:33 +02:00
|
|
|
https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-heading/30892
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-latex
|
|
|
|
(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
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO HTML Export
|
|
|
|
***** Export with css class instead of inline css
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-html-htmlize-output-type 'css)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
***** TODO MP4 movies
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-html-html5-fancy t)
|
|
|
|
(setq org-html-doctype "xhtml-strict")
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
***** TODO MathJax with SIunix
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-html-mathjax-template
|
|
|
|
"<script type=\"text/x-mathjax-config\">
|
|
|
|
MathJax.Hub.Config({
|
|
|
|
extensions: [\"tex2jax.js\", \"[siunitx]/siunitx.js\"],
|
|
|
|
jax: [\"input/TeX\",\"output/HTML-CSS\"],
|
|
|
|
tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\(\",\"\\)\"]]},
|
|
|
|
displayAlign: \"%ALIGN\",
|
|
|
|
displayIndent: \"%INDENT\",
|
|
|
|
|
|
|
|
\"HTML-CSS\": { scale: %SCALE,
|
|
|
|
linebreaks: { automatic: \"%LINEBREAKS\" },
|
|
|
|
webFont: \"%FONT\"
|
|
|
|
},
|
|
|
|
SVG: {scale: %SCALE,
|
|
|
|
linebreaks: { automatic: \"%LINEBREAKS\" },
|
|
|
|
font: \"%FONT\"},
|
|
|
|
NativeMML: {scale: %SCALE},
|
|
|
|
TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
|
|
|
|
extensions: [\"AMSmath.js\",\"AMSsymbols.js\", \"sinuitx.js\"],
|
|
|
|
MultLineWidth: \"%MULTLINEWIDTH\",
|
|
|
|
TagSide: \"%TAGSIDE\",
|
|
|
|
TagIndent: \"%TAGINDENT\"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
MathJax.Ajax.config.path['siunitx'] = '../js';
|
|
|
|
</script>
|
|
|
|
<script type=\"text/javascript\"
|
|
|
|
src=\"%PATH\"></script>"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org LaTeX
|
|
|
|
**** LaTeX Classes
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-latex
|
|
|
|
;; 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
|
|
|
|
'("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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Basic
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-latex
|
|
|
|
;; Add packages by default
|
|
|
|
(add-to-list 'org-latex-packages-alist '("" "siunitx" 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=\"xelatex -synctex=1 -shell-escape -interaction nonstopmode -output-directory %o\" -pdf -bibtex -f %f"))
|
|
|
|
;; (setq org-latex-pdf-process
|
|
|
|
;; '("xelatex -interaction nonstopmode -output-directory %o %f"
|
|
|
|
;; "xelatex -interaction nonstopmode -output-directory %o %f"
|
|
|
|
;; "xelatex -interaction nonstopmode -output-directory %o %f"))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Beamer
|
|
|
|
***** TODO Make a custom environment for columns with title
|
2019-05-16 21:28:33 +02:00
|
|
|
#+beamer: \csubtitle{title}\vspace{1em}
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
***** Custom Environments
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-beamer
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
***** Beamer export options
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-beamer
|
|
|
|
(defun my-beamer-bold (contents backend info)
|
|
|
|
(when (eq backend 'beamer)
|
|
|
|
(replace-regexp-in-string "\\`\\\\[A-Za-z0-9]+" "\\\\textbf" contents)))
|
|
|
|
|
|
|
|
(add-to-list 'org-export-filter-bold-functions 'my-beamer-bold)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Latex Fragments
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(with-eval-after-load 'ox-latex
|
|
|
|
;; Automatic toggle of latex fragments http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/
|
|
|
|
;; Activate Automatic LaTeX fragment
|
|
|
|
(spacemacs/set-leader-keys "ol" '(lambda () (interactive) (add-hook 'post-command-hook 'kk/org-latex-fragment-toggle t)))
|
|
|
|
;; Disable Automatic LaTeX fragment
|
|
|
|
(spacemacs/set-leader-keys "oL" '(lambda () (interactive) (remove-hook 'post-command-hook 'kk/org-latex-fragment-toggle t)))
|
|
|
|
|
|
|
|
;; Use F9 to globally generate all the latex fragments
|
|
|
|
(global-set-key (kbd "<f9>") (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: pdflatex and imagemagick."
|
|
|
|
:use-xcolor t
|
|
|
|
:image-input-type "pdf"
|
|
|
|
:image-output-type "png"
|
|
|
|
:image-size-adjust (1.0 . 1.0)
|
|
|
|
:latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
|
|
|
|
;; :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."
|
|
|
|
:use-xcolor t
|
|
|
|
: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 ~/Downloads/test.pdf && pdf2svg %f %O"))
|
|
|
|
(dvisvgm
|
|
|
|
:programs ("latex" "dvisvgm")
|
|
|
|
:description "dvi > svg"
|
|
|
|
:message "you need to install the programs: latex and dvisvgm."
|
|
|
|
:use-xcolor t
|
|
|
|
:image-input-type "dvi"
|
|
|
|
:image-output-type "svg"
|
|
|
|
:image-size-adjust (1.0 . 1.0)
|
|
|
|
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
|
|
|
|
;; :image-converter ("dvisvgm %f -e -n -b min -Z 1.2 -c %S -o %O"))
|
|
|
|
: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)
|
|
|
|
;; (setq org-preview-latex-default-process 'pdf2svg)
|
|
|
|
;; (setq org-preview-latex-default-process 'imagemagick)
|
|
|
|
))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO Custom Export - Add Page and Label for LaTeX export
|
2019-05-16 21:28:33 +02:00
|
|
|
https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbitrary-org-property-into-an-arbitrary-string-na?rq=1
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Org-Bibtex
|
2019-05-16 21:28:33 +02:00
|
|
|
It seems it is uncompatble with org-ref (https://github.com/jkitchin/org-ref/issues/101)
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
;; (require 'ox-bibtex)
|
|
|
|
;; (with-eval-after-load 'org
|
|
|
|
;; )
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Org-pomodoro
|
|
|
|
*** Org Ref
|
2019-05-16 21:28:33 +02:00
|
|
|
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/
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; Folder where the notes files are located (or file if just one Note file)
|
|
|
|
(setq org-ref-notes-directory "~/MEGA/These/Ressources/notes")
|
|
|
|
(setq org-ref-bibliography-notes "~/MEGA/These/Ressources/notes")
|
|
|
|
;; Bibliography File
|
|
|
|
(setq reftex-default-bibliography '("~/MEGA/These/Ressources/references.bib"))
|
|
|
|
;; TODO - determine why it is not working with format or concat?
|
|
|
|
(setq org-ref-default-bibliography '("~/MEGA/These/Ressources/references.bib"))
|
|
|
|
;; Folder where all the pdf are located
|
|
|
|
(setq org-ref-pdf-directory "~/MEGA/These/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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org Noter
|
2019-05-16 21:28:33 +02:00
|
|
|
- https://github.com/weirdNox/org-noter
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
2019-06-22 17:34:07 +02:00
|
|
|
(setq org-noter-always-create-frame nil)
|
|
|
|
(setq org-noter-kill-frame-at-session-end nil)
|
2019-05-16 21:28:33 +02:00
|
|
|
;; 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 (format "%s/%s" thesis-base-path "/Ressources/notes"))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Custom key bindings
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
;; Export to LaTeX
|
|
|
|
(evil-define-key 'normal org-mode-map (kbd ", l") 'org-latex-export-to-latex)
|
|
|
|
;; Open pdf externally with Zathura
|
|
|
|
;; (evil-define-key 'normal org-mode-map (kbd ", v") 'org-latex-export-to-latex)
|
|
|
|
;; (call-process "zathura" nil 0 nil (nth 0 (-cons-to-list (bibtex-completion-find-pdf key)))))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org-Contacts
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
(setq org-contacts-files (list (format "%s/%s" dropbox-base-path "org/contacts.org")))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Org-Wunderlist
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(require 'org-wunderlist)
|
|
|
|
(setq org-wunderlist-client-id "6799d9caeb2f5d8bd641"
|
|
|
|
org-wunderlist-token "fd5965cde436c2587850a7c517d366561d8a1cbf7b6d96ab62f3fc8c9930"
|
|
|
|
org-wunderlist-file "~/MEGA/These/TODOs/wunderlist.org"
|
|
|
|
org-wunderlist-dir "~/.emacs.d/org-wunderlist/")
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-07-20 16:29:41 +02:00
|
|
|
*** ox-hugo
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package ox-hugo
|
|
|
|
:ensure t ;Auto-install the package from Melpa (optional)
|
|
|
|
:after ox)
|
|
|
|
#+end_src
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** More Config
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'org
|
|
|
|
;; Highligh latex parts in org mode
|
|
|
|
(setq org-highlight-latex-and-related '(latex))
|
|
|
|
|
|
|
|
;; Automatically change to DONE when all children are done
|
|
|
|
(defun org-summary-todo (n-done n-not-done)
|
|
|
|
"Switch entry to DONE when all subentries are done, to TODO otherwise."
|
|
|
|
(let (org-log-done org-log-states) ; turn off logging
|
|
|
|
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
|
|
|
|
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-30 16:22:26 +02:00
|
|
|
Disable automatic highlight of TODO keywords in orgmode buffers
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(add-hook 'org-mode-hook (lambda () (hl-todo-mode -1)))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Projectile
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq projectile-generic-command "fd -H --ignore-file .projectile -t f -0")
|
|
|
|
#+END_SRC
|
2019-05-30 16:22:26 +02:00
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** TODO [#A] Matlab
|
2019-05-16 21:28:33 +02:00
|
|
|
- https://github.com/yuhonglin/matlab-mode
|
|
|
|
- https://github.com/pronobis/matlab-mode
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Setup Matlab Mode
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-06-22 17:34:07 +02:00
|
|
|
;; (setq matlab-shell-command "/usr/local/bin/matlab")
|
|
|
|
;; (setq matlab-shell-command-switches (list "-nodesktop -nosplash"))
|
|
|
|
;; (setq mlint-programs '("mlint" "/usr/local/matlab/r2018a/bin/glnxa64/mlint"))
|
2019-05-16 21:28:33 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Setup Flycheck
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(defvar mlint-executable "/usr/local/MATLAB/R2018a/bin/glnxa64/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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-06-22 17:34:07 +02:00
|
|
|
(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)
|
2019-05-16 21:28:33 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Setup Company - not working
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
;; (add-to-list 'company-backends 'company-matlab)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-30 16:22:26 +02:00
|
|
|
** TODO [#B] Mails With Mu4e
|
|
|
|
:PROPERTIES:
|
|
|
|
:header-args:emacs-lisp+: :tangle no
|
|
|
|
:END:
|
|
|
|
|
2019-05-16 21:28:33 +02:00
|
|
|
- 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/
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Set default mail user agent to mu4e
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mail-user-agent 'mu4e-user-agent)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Default config
|
|
|
|
**** Default behavior
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Default folders
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Default signature and email address
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-compose-signature "Thomas Dehaeze\n"
|
|
|
|
user-mail-address "dehaeze.thomas@gmail.com")
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Saving the attachment to Downloads directory
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-attachment-dir "~/Downloads")
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** A list of user's e-mail addresses
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-user-mail-address-list '("dehaeze.thomas@gmail.com" "thomas.dehaeze@esrf.fr" "thomas.dehaeze@doct.ulg.ac.be"))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Mail directory shortcuts
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-maildir-shortcuts
|
|
|
|
'(
|
|
|
|
("/gmail/Inbox" . ?g)
|
|
|
|
("/esrf/Inbox" . ?e)
|
|
|
|
("/ulg/Inbox" . ?u)
|
|
|
|
))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Contexts - Email accounts
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Receiving emails - Mbsync
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-get-mail-command "mbsync -a"
|
|
|
|
smtpmail-default-smtp-server "smtp.gmail.com"
|
|
|
|
smtpmail-smtp-server "smtp.gmail.com"
|
|
|
|
smtpmail-smtp-service 587)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Let systemd get the mail, then pressing =U= will just run =mu= to reindex everything.
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(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]].
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-change-filenames-when-moving t)
|
|
|
|
#+end_src
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Sending emails - Msmtp
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Bookmarks
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(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
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Notifications
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(with-eval-after-load 'mu4e-alert
|
|
|
|
(mu4e-alert-set-default-style 'libnotify))
|
|
|
|
(mu4e-alert-enable-notifications)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO Mode-line notifications
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq mu4e-enable-mode-line t)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO [#A] When putting something on the Trash, it will be in the archive folder on gmail
|
2019-05-16 21:28:33 +02:00
|
|
|
Even when totally deleting it. It will stage on gmail. How to fix that?
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Verify that sending mails with gmail account works and that there is no duplicate
|
2019-05-16 21:28:33 +02:00
|
|
|
SCHEDULED: <2019-01-17 jeu.>
|
|
|
|
Should check this variable: mu4e-sent-messages-behavior
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(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]].
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** TODO Cheatsheet
|
2019-05-16 21:28:33 +02:00
|
|
|
| Command | Usage |
|
|
|
|
|---------+-----------------------|
|
|
|
|
| =C-j= | Next mail |
|
|
|
|
| =C-k= | Previous mail |
|
|
|
|
| =R/C/F= | Reply/Compose/Forward |
|
|
|
|
| =t= | Move to Archive |
|
|
|
|
| =d= | Move to Trash |
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO Add keybindings to refresh mu
|
2019-05-16 21:28:33 +02:00
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** TODO Send email using org-mode
|
2019-05-16 21:28:33 +02:00
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
**** Store emails into org-mode
|
2019-05-16 21:28:33 +02:00
|
|
|
Use =mu4e-org-store-and-capture= when on an email to store it using a capture template.
|
|
|
|
Org simply =C-c l= to store the link to the email and then =C-c C-l= and paste the link.
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** PDF-Tools
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(add-hook 'pdf-view-mode-hook (lambda() (linum-mode -1)))
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
** Custom command and leader keys
|
|
|
|
*** Watch LaTeX file using latexmk
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(defun 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 latex/watch/kill ()
|
|
|
|
"Kill the currently running TeX job."
|
|
|
|
(interactive)
|
|
|
|
(delete-process "latexmk-watch")
|
|
|
|
)
|
|
|
|
|
|
|
|
(spacemacs/set-leader-keys "ow" 'latex/watch)
|
|
|
|
(spacemacs/set-leader-keys "ok" 'latex/watch/kill)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Helm-Bibtex
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(spacemacs/set-leader-keys "ob" 'helm-bibtex)
|
|
|
|
(spacemacs/set-leader-keys "of" 'helm-bibtex-favorites)
|
|
|
|
(spacemacs/set-leader-keys "or" 'helm-resume)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:39:04 +02:00
|
|
|
*** Eshell
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(spacemacs/set-leader-keys "os" 'eshell)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-07-20 16:29:54 +02:00
|
|
|
*** Open terminal in current directory
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defun open-terminal-in-workdir ()
|
|
|
|
(interactive)
|
|
|
|
(call-process-shell-command
|
|
|
|
(concat "termite --directory=" default-directory) nil 0))
|
|
|
|
|
|
|
|
(spacemacs/set-leader-keys "ot" '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))
|
|
|
|
|
|
|
|
(spacemacs/set-leader-keys "oo" 'open-ranger-in-workdir)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-05-16 21:28:33 +02:00
|
|
|
** Path for Shell
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
(exec-path-from-shell-initialize))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Proxy
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2019-05-16 21:28:33 +02:00
|
|
|
(setq url-proxy-services
|
|
|
|
'(("http" . "proxy.esrf.fr:3128")
|
|
|
|
("https" . "proxy.esrf.fr:3128")
|
|
|
|
("no_proxy" . "^.*esrf.fr")))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Remove the problem of recentf files
|
2019-05-16 21:39:04 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
2019-05-16 21:28:33 +02:00
|
|
|
(cancel-timer recentf-auto-save-timer)
|
|
|
|
#+END_SRC
|
2019-06-22 17:34:07 +02:00
|
|
|
|
|
|
|
** 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 tdehaeze/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" 'tdehaeze/mutt-open-message)
|
|
|
|
#+end_src
|