Update the doom emacs configuration

This commit is contained in:
Thomas Dehaeze 2020-01-28 21:31:08 +01:00
parent a55d3230f1
commit 63ddff6795

View File

@ -16,7 +16,7 @@
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/readtheorg.js"></script>
#+PROPERTY: header-args :tangle yes :results none :padline no
#+PROPERTY: header-args :tangle ~/.config/doom/config.el :results none :padline no
:END:
https://medium.com/urbint-engineering/emacs-doom-for-newbies-1f8038604e3b
@ -139,12 +139,17 @@ Documentation:
** Visual
Automatic line wrap.
#+begin_src emacs-lisp
(global-visual-line-mode t)
(global-visual-line-mode nil)
#+end_src
Turn off auto-fill mode that add line breaks.
#+begin_src emacs-lisp
(auto-fill-mode -1)
(remove-hook 'text-mode-hook 'turn-on-auto-fill)
;; turn on auto-fill for text-mode
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; turn off auto-fill for org-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill)
#+end_src
** Change default alert backend
@ -157,6 +162,17 @@ Turn off auto-fill mode that add line breaks.
(setq create-lockfiles nil)
#+end_src
** Disable highlight of current line
#+begin_src emacs-lisp
(global-hl-line-mode -1)
(add-hook 'org-mode-hook
(lambda()
(hl-line-mode -1)
(global-hl-line-mode -1))
't
)
#+end_src
* Magit
#+begin_src emacs-lisp
(setenv "GIT_ASKPASS" "git-gui--askpass")
@ -200,8 +216,10 @@ TAB was changed to toggle only the visibility state of the current subtree, rath
#+end_src
** Org latex fragment
Don't change the font size for subscripts and superscripts in latex fragments.
This cause the orgmode tables not to be well aligned.
#+begin_src emacs-lisp
(setq org-highlight-latex-and-related '(native))
(setq font-latex-fontify-script nil)
#+end_src
#+begin_src emacs-lisp
@ -244,7 +262,7 @@ TAB was changed to toggle only the visibility state of the current subtree, rath
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
r (<= (overlay-start ov) (point))
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
@ -294,7 +312,7 @@ r (<= (overlay-start ov) (point))
** Org Tagging
#+begin_src emacs-lisp
;; Align Tags and flush right
(setq org-tags-column -80)
(setq org-tags-column -78)
;; Tags with fast selection keys
(setq org-tag-alist (quote (("@home" . ?h)
("@work" . ?w)
@ -790,60 +808,59 @@ Special Environments
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)))
(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 "<f9>" (lambda () (interactive) (org-preview-latex-fragment 16)))
;; Use F9 to globally generate all the latex fragments
(map! :map org-mode-map :n "<f9>" (lambda () (interactive) (org-preview-latex-fragment 16)))
;; Put all the preview images in some directory
(setq org-preview-latex-image-directory "~/.ltximg/")
;; 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"))
))
;; Define backends to preview LaTeX fragments
(setq org-preview-latex-process-alist '((imagemagick
:programs ("pdflatex" "convert")
:description "pdf > png"
:message "you need to install the programs: pdflatex 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"))
(dvipng
:programs ("latex" "dvipng")
:description "dvi > png"
:message "you need to install the programs: latex and dvipng."
:image-input-type "dvi"
:image-output-type "png"
:image-size-adjust (0.5 . 0.5)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvipng -D %D -T tight -o %O %f"))
(dvisvgm
:programs ("pdflatex" "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.7 . 0.7)
: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)
;; Use imagemagick/dvisvgm to generate png from pdf
(setq org-preview-latex-default-process 'dvipng)
#+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)))
(defcustom tdh/org-property-mapping
'((latex ("CUSTOM_PAGE" . tdh/insert-org-page-latex)
("CUSTOM_LABEL" . tdh/insert-org-label-latex)))
"List of mappings from org property to arbitrary strings.
Each element is a list:
(BACKEND (PROPERTY1 . FUNCTION1) (PROPERTY2 . FUNCTION2) ...)
@ -854,13 +871,13 @@ https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbit
#+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
(defun tdh/replace-org-property (backend)
"Convert org properties using `tdh/org-property-mapping'.
Lookup BACKEND in `tdh/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)))
(let ((map (cdr (assoc backend tdh/org-property-mapping)))
value replacement)
(when map
(org-map-entries
@ -870,16 +887,16 @@ https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbit
(when (setq value (org-entry-get (point) (car it)))
(funcall (cdr it) value)))))))))
(add-hook 'org-export-before-processing-hook #'tdehaeze/replace-org-property)
(add-hook 'org-export-before-processing-hook #'tdh/replace-org-property)
#+end_src
#+begin_src emacs-lisp :tangle no
(defun tdehaeze/insert-org-label-latex (label)
(defun tdh/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)
(defun tdh/insert-org-page-latex (page)
"Insert \"\\\\page{PAGE}\\n\" after the :PROPERTY: drawer."
(search-forward-regexp org-property-end-re)
(forward-char 1)
@ -1115,28 +1132,33 @@ Ressources:
- 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")
(use-package! org-ref
:after org
:config
;; 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"))
;; 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")
;; 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)))))))
;; 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)
;; Problem with speed: don't display broken links
(setq org-ref-show-broken-links t)
;; Display information on the citation
(setq org-ref-show-citation-on-enter t)
(bibtex-set-dialect 'BibTeX)
)
#+end_src
** Org Noter
@ -1681,7 +1703,7 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
** General Config
#+begin_src emacs-lisp
;; Use "tags" field when looking for bib entries
(setq helm-bibtex-additional-search-fields '(keywords))
(setq helm-bibtex-additional-search-fields '(tags))
;; Display of bibtex entries with helm
(setq bibtex-completion-display-formats
@ -1716,7 +1738,7 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
"#+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: \\newcommand{\\refKeywords}{${tags}}\n"
"#+LATEX_HEADER: \\input{config.tex}\n"
"#+LATEX_HEADER: \\graphicspath{{./figs/${=key=}/}}\n"
"# #+TOC: headlines 2\n"
@ -1744,8 +1766,7 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
;; 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)
)
(helm-add-action-to-source "Edit notes" 'helm-bibtex-edit-notes helm-source-bibtex 0))
#+end_src
** Open pdf externally
@ -1756,8 +1777,7 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
;; 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)
)
(helm-add-action-to-source "Open PDF Externally" 'tdehaeze/open-pdf-externally helm-source-bibtex 1))
#+end_src
** Special Commands
@ -2147,12 +2167,12 @@ Check [[https://github.com/djcb/mu/issues/179][here]].
** Open ranger in current directory
#+begin_src emacs-lisp
(defun open-ranger-in-workdir ()
(defun tdh/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)
(map! :map org-mode-map :n ",oo" 'tdh/open-ranger-in-workdir)
#+end_src
* Yassnippets
@ -2161,12 +2181,6 @@ Check [[https://github.com/djcb/mu/issues/179][here]].
(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
@ -2273,7 +2287,6 @@ they are implemented.
: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
@ -2306,17 +2319,13 @@ they are implemented.
: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
@ -2325,21 +2334,15 @@ they are implemented.
: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)