Add few useful functions
This commit is contained in:
parent
b4020fbf2d
commit
ea7e34cdf2
135
doom.org
135
doom.org
@ -11,6 +11,7 @@
|
|||||||
#+html_head: <link rel="stylesheet" type="text/css" href="./dist/style.css"/>
|
#+html_head: <link rel="stylesheet" type="text/css" href="./dist/style.css"/>
|
||||||
#+html_head: <script type="text/javascript" src="./dist/script.js"></script>
|
#+html_head: <script type="text/javascript" src="./dist/script.js"></script>
|
||||||
#+property: header-args:emacs-lisp :tangle ~/.config/doom/config.el :results none :padline no
|
#+property: header-args:emacs-lisp :tangle ~/.config/doom/config.el :results none :padline no
|
||||||
|
#+auto_tangle: t
|
||||||
|
|
||||||
* Installation
|
* Installation
|
||||||
#+begin_src bash :tangle no
|
#+begin_src bash :tangle no
|
||||||
@ -297,6 +298,27 @@ This works also with =C-x C-q=
|
|||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun tdh-screenshot-page ()
|
||||||
|
"Open current page as an SVG file with Inkscape"
|
||||||
|
(interactive)
|
||||||
|
(if (string-match "_" (file-name-base buffer-file-name))
|
||||||
|
(setq filename (read-string "Enter file name:" (car (split-string (file-name-base buffer-file-name) "_"))))
|
||||||
|
(setq filename (read-string "Enter file name:")))
|
||||||
|
(setq filepath (concat "/tmp/" filename ".svg"))
|
||||||
|
(shell-command (concat "pdftk " buffer-file-name " cat " (number-to-string (pdf-view-current-page)) " output /tmp/pdf_page.pdf"))
|
||||||
|
(shell-command (concat "pdf2svg /tmp/pdf_page.pdf " filepath))
|
||||||
|
(start-process "" nil "inkscape" filepath))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(after! pdf-tools
|
||||||
|
(map! :map pdf-view-mode-map
|
||||||
|
(:desc "Screenshot"
|
||||||
|
:ni "C-c s" 'tdh-screenshot-page)
|
||||||
|
))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Yassnippets
|
** Yassnippets
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(push "~/.config/doom/snippets" yas-snippet-dirs)
|
(push "~/.config/doom/snippets" yas-snippet-dirs)
|
||||||
@ -612,6 +634,17 @@ Org Agenda Custom Views
|
|||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Org Agenda HTML
|
||||||
|
This function can be used to export the week calendar to html.
|
||||||
|
This html page can be used as a starting page for the browser.
|
||||||
|
This idea comes from [[https://blog.lambda.cx/posts/org-agenda-new-tab/][here]].
|
||||||
|
#+begin_src emacs-lisp :tangle no
|
||||||
|
(defun tdh-org-agenda-to-html ()
|
||||||
|
(interactive)
|
||||||
|
(org-agenda-list)
|
||||||
|
(org-agenda-write "/ssh:thomas@grenoble:~/docker/config/calendar/www/index.html"))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Org Fancy Priority
|
** Org Fancy Priority
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package! org-fancy-priorities ; priority icons
|
(use-package! org-fancy-priorities ; priority icons
|
||||||
@ -661,7 +694,7 @@ dunstify --replace=85401 "Event in $TIME minutes" "$MSG"
|
|||||||
("C" . "comment")
|
("C" . "comment")
|
||||||
("mm" . "src matlab")
|
("mm" . "src matlab")
|
||||||
("mf" . "src matlab :exports none")
|
("mf" . "src matlab :exports none")
|
||||||
("mv" . "src matlab :results value replace :exports none :tangle no")
|
("mv" . "src matlab :results value replace :exports results :tangle no")
|
||||||
("l" . "src emacs-lisp")
|
("l" . "src emacs-lisp")
|
||||||
("q" . "quote")
|
("q" . "quote")
|
||||||
("s" . "src")
|
("s" . "src")
|
||||||
@ -1049,13 +1082,13 @@ by spaces.
|
|||||||
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
|
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
|
||||||
:image-converter ("dvipng -D %D -T tight -o %O %f"))
|
:image-converter ("dvipng -D %D -T tight -o %O %f"))
|
||||||
(dvisvgm
|
(dvisvgm
|
||||||
:programs ("pdflatex" "dvisvgm")
|
:programs ("xetex" "dvisvgm")
|
||||||
:description "dvi > svg"
|
:description "xdv > svg"
|
||||||
:message "you need to install the programs: latex and dvisvgm."
|
:message "you need to install the programs: xetex and dvisvgm."
|
||||||
:image-input-type "dvi"
|
:image-input-type "xdv"
|
||||||
:image-output-type "svg"
|
:image-output-type "svg"
|
||||||
:image-size-adjust (0.6 . 0.6)
|
:image-size-adjust (0.6 . 0.6)
|
||||||
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
|
:latex-compiler ("xelatex -no-pdf -output-directory %o %f")
|
||||||
:image-converter ("dvisvgm %f -n -b min -c %S -o %O"))
|
:image-converter ("dvisvgm %f -n -b min -c %S -o %O"))
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -1378,6 +1411,14 @@ https://kitchingroup.cheme.cmu.edu/blog/2016/11/07/Better-equation-numbering-in-
|
|||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Org Auto Tangle
|
||||||
|
#+begin_src emacs-lisp :tangle no
|
||||||
|
(use-package! org-auto-tangle
|
||||||
|
:after org
|
||||||
|
:hook (org-mode . org-auto-tangle-mode)
|
||||||
|
)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** LaTeX macro both for LaTeX and HTML export
|
** LaTeX macro both for LaTeX and HTML export
|
||||||
https://www.reddit.com/r/orgmode/comments/7u2n0h/tip_for_defining_latex_macros_for_use_in_both/
|
https://www.reddit.com/r/orgmode/comments/7u2n0h/tip_for_defining_latex_macros_for_use_in_both/
|
||||||
|
|
||||||
@ -1558,7 +1599,7 @@ The file is taken from a start directory set by `tdh-image-dir' and moved to the
|
|||||||
** Render Tables
|
** Render Tables
|
||||||
https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_chapter_2_it/
|
https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_chapter_2_it/
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(after! org
|
(after! org
|
||||||
(defun tdh-render-org-table-at-point ()
|
(defun tdh-render-org-table-at-point ()
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -2146,6 +2187,35 @@ Better format the output results for Matlab ([[https://www.reddit.com/r/emacs/co
|
|||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Mermaid
|
||||||
|
#+begin_src bash :tangle no
|
||||||
|
yay -S mermaid-cli
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package! ob-mermaid
|
||||||
|
:after org
|
||||||
|
:config
|
||||||
|
(setq ob-mermaid-cli-path "/usr/bin/mmdc")
|
||||||
|
)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src mermaid :file figs/mermaid.png :theme default :background-color transparent :tangle no :exports both
|
||||||
|
gantt
|
||||||
|
dateFormat YYYY-MM-DD
|
||||||
|
title Adding GANTT diagram to mermaid
|
||||||
|
excludes weekdays 2014-01-10
|
||||||
|
|
||||||
|
section A section
|
||||||
|
Completed task :done, des1, 2014-01-06,2014-01-08
|
||||||
|
Active task :active, des2, 2014-01-09, 3d
|
||||||
|
Future task : des3, after des2, 5d
|
||||||
|
Future task2 : des4, after des3, 5d
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
[[file:figs/mermaid.png]]
|
||||||
|
|
||||||
** Some functions for using Matlab with Org Babel =,m=
|
** Some functions for using Matlab with Org Babel =,m=
|
||||||
=whos= matlab function
|
=whos= matlab function
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -2336,8 +2406,9 @@ This function:
|
|||||||
(tdh-matlab-execute-selected (region-beginning) (region-end))
|
(tdh-matlab-execute-selected (region-beginning) (region-end))
|
||||||
(progn (tdh-org-babel-execute-matlab-background)
|
(progn (tdh-org-babel-execute-matlab-background)
|
||||||
(org-babel-next-src-block)))
|
(org-babel-next-src-block)))
|
||||||
(tdh-ctrl-ret))
|
(org-babel-next-src-block))
|
||||||
)
|
)
|
||||||
|
(org-babel-next-src-block)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -2532,7 +2603,7 @@ Nice Functions:
|
|||||||
:custom-face
|
:custom-face
|
||||||
(org-roam-link ((t (:inherit org-link :foreground "#cc241d"))))
|
(org-roam-link ((t (:inherit org-link :foreground "#cc241d"))))
|
||||||
:config
|
:config
|
||||||
(setq org-roam-directory "~/Cloud/brain/")
|
(setq org-roam-directory (file-truename "~/Cloud/brain/"))
|
||||||
(setq org-roam-completion-system 'helm)
|
(setq org-roam-completion-system 'helm)
|
||||||
(setq org-roam-tag-sources '(prop last-directory))
|
(setq org-roam-tag-sources '(prop last-directory))
|
||||||
(setq org-roam-capture-templates
|
(setq org-roam-capture-templates
|
||||||
@ -2580,19 +2651,22 @@ Automatic export of backlinks
|
|||||||
(insert (format "- [[file:%s][%s]]\n"
|
(insert (format "- [[file:%s][%s]]\n"
|
||||||
(file-relative-name link org-roam-directory)
|
(file-relative-name link org-roam-directory)
|
||||||
(org-roam--get-title-or-slug link))))))
|
(org-roam--get-title-or-slug link))))))
|
||||||
|
|
||||||
(add-hook 'org-export-before-processing-hook #'tdh-org-export-preprocessor)
|
(add-hook 'org-export-before-processing-hook #'tdh-org-export-preprocessor)
|
||||||
|
|
||||||
|
|
||||||
(defun tdh-org-roam-export-all ()
|
|
||||||
"Re-exports all Org-roam files to Hugo markdown."
|
|
||||||
(interactive)
|
|
||||||
(dolist (f (org-roam--list-all-files))
|
|
||||||
(with-current-buffer (find-file f)
|
|
||||||
(when (s-contains? "SETUPFILE" (buffer-string))
|
|
||||||
(org-hugo-export-wim-to-md)))))
|
|
||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Re-Export all roam files.
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun tdh-org-roam-export-all ()
|
||||||
|
"Re-exports all Org-roam files to Hugo markdown."
|
||||||
|
(interactive)
|
||||||
|
(dolist (f (org-roam--list-all-files))
|
||||||
|
(with-current-buffer (find-file f)
|
||||||
|
(when (s-contains? "SETUPFILE" (buffer-string))
|
||||||
|
(org-hugo-export-wim-to-md)))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
Create Org-Roam file from heading ([[https://ag91.github.io/blog/2020/11/12/write-org-roam-notes-via-elisp/][link]])
|
Create Org-Roam file from heading ([[https://ag91.github.io/blog/2020/11/12/write-org-roam-notes-via-elisp/][link]])
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun tdh/make-roam-filepath (title)
|
(defun tdh/make-roam-filepath (title)
|
||||||
@ -2824,6 +2898,13 @@ Provides nice functions such as:
|
|||||||
(setq citeproc-org-html-backends '(html)))
|
(setq citeproc-org-html-backends '(html)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Bibtex-Mode
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(after! bibtex
|
||||||
|
(map! :map bibtex-mode-map
|
||||||
|
:n "C-c c" 'org-ref-clean-bibtex-entry))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* LaTeX
|
* LaTeX
|
||||||
- https://tex.stackexchange.com/questions/52179/what-is-your-favorite-emacs-and-or-auctex-command-trick
|
- 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
|
- https://tex.stackexchange.com/questions/20843/useful-shortcuts-or-key-bindings-or-predefined-commands-for-emacsauctex
|
||||||
@ -3233,7 +3314,7 @@ Choose account label to feed msmtp -a option based on From header in Message buf
|
|||||||
|
|
||||||
* Doom =packages.el=
|
* Doom =packages.el=
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/.config/doom/packages.el
|
:header-args:emacs-lisp: :tangle ~/.config/doom/packages.el
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -3274,11 +3355,21 @@ Choose account label to feed msmtp -a option based on From header in Message buf
|
|||||||
(package! citeproc-org)
|
(package! citeproc-org)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
;; Connector between Org-roam, BibTeX-completion, and Org-ref
|
||||||
|
(package! org-roam-bibtex)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
;; Org-mode modules for citations, cross-references, bibliographies
|
;; Org-mode modules for citations, cross-references, bibliographies
|
||||||
(package! org-ref)
|
(package! org-ref)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
;; Org file tangling upon save
|
||||||
|
;; (package! org-auto-tangle)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
;; Alert notifications for org-agenda
|
;; Alert notifications for org-agenda
|
||||||
(package! org-wild-notifier)
|
(package! org-wild-notifier)
|
||||||
@ -3304,6 +3395,7 @@ Choose account label to feed msmtp -a option based on From header in Message buf
|
|||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
;; Org-mode query language
|
;; Org-mode query language
|
||||||
(package! org-ql)
|
(package! org-ql)
|
||||||
|
(package! helm-org-ql)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -3320,3 +3412,8 @@ Choose account label to feed msmtp -a option based on From header in Message buf
|
|||||||
;; Don't use this default package in Doom
|
;; Don't use this default package in Doom
|
||||||
(package! evil-escape :disable t)
|
(package! evil-escape :disable t)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
;; Nice gantt charts
|
||||||
|
(package! ob-mermaid)
|
||||||
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user