Update org-agenda by using org-ql

This commit is contained in:
Thomas Dehaeze 2020-03-16 12:15:59 +01:00
parent 17029e9b1b
commit cca1362e11

View File

@ -481,64 +481,82 @@ https://blog.aaronbieber.com/2016/09/24/an-agenda-for-life-with-org-mode.html
#+begin_src emacs-lisp
(after! org-agenda
(defun tdh-org-agenda-skip-scheduled ()
(org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>"))
(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" "Already read Articles and Books"
((org-ql-block '(and (todo "DONE")
(level 1)
(tags "article" "inproceedings" "techreport" "inbook"))
((org-ql-block-header "Articles")))
(org-ql-block '(and (todo "DONE")
(level 1)
(tags "book"))
((org-ql-block-header "Books")))
(org-ql-block '(and (todo "DONE")
(level 1)
(tags "phdthesis"))
((org-ql-block-header "Phd Thesis")))
(org-ql-block '(and (todo "DONE")
(level 1)
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis")))
((org-ql-block-header "Other Things"))))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/"))))
("r" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((org-ql-block '(and (todo "READ")
(level 1)
(tags "article" "inproceedings" "techreport" "inbook"))
((org-ql-block-header "Article to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(tags "book"))
((org-ql-block-header "Books to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(tags "phdthesis"))
((org-ql-block-header "Phd Thesis to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis")))
((org-ql-block-header "Other Things to Read"))))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/")))))
)
'(("w" "Work"
((org-ql-block '(and (tags "@work")
(todo "TODO")
(priority "A"))
((org-ql-block-header "Things to do")))
(org-ql-block '(and (tags "@work")
(todo "TODO")
(priority "B"))
((org-ql-block-header "Things to do")))
(org-ql-block '(and (tags "@work")
(todo "TODO")
(priority "C"))
((org-ql-block-header "Things to do")))))
("h" "Home"
((org-ql-block '(and (tags "@home")
(todo "TODO")
(priority "A"))
((org-ql-block-header "Things to do")))
(org-ql-block '(and (tags "@home")
(todo "TODO")
(priority "B"))
((org-ql-block-header "Things to do")))
(org-ql-block '(and (tags "@home")
(todo "TODO")
(priority "C"))
((org-ql-block-header "Things to do")))))
("q" "Questions to ask"
((org-ql-block '(and (todo "QUES")
(tags "@christophe"))
((org-ql-block-header "Questions")))
(org-ql-block '(and (todo "QUES")
(tags "@veijo"))
((org-ql-block-header "Veijo")))
(org-ql-block '(and (todo "QUES")
(not (tags "@veijo" "@christophe")))
((org-ql-block-header "Other Questions")))))
("R" "Already read Articles and Books"
((org-ql-block '(and (todo "DONE")
(level 1)
(tags "article" "inproceedings" "techreport" "inbook"))
((org-ql-block-header "Articles")))
(org-ql-block '(and (todo "DONE")
(level 1)
(tags "book"))
((org-ql-block-header "Books")))
(org-ql-block '(and (todo "DONE")
(level 1)
(tags "phdthesis"))
((org-ql-block-header "Phd Thesis")))
(org-ql-block '(and (todo "DONE")
(level 1)
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis")))
((org-ql-block-header "Other Things"))))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/"))))
("r" "Articles and Books to read"
((org-ql-block '(and (todo "READ")
(level 1)
(tags "article" "inproceedings" "techreport" "inbook"))
((org-ql-block-header "Article to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(tags "book"))
((org-ql-block-header "Books to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(tags "phdthesis"))
((org-ql-block-header "Phd Thesis to Read")))
(org-ql-block '(and (todo "READ")
(level 1)
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis")))
((org-ql-block-header "Other Things to Read"))))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/")))))
)
)
#+end_src
@ -901,7 +919,7 @@ by spaces.
(after! org
;; Custom classes to use when exporting to latex
(add-to-list 'org-latex-classes
`("beamer"
'("beamer"
,(concat "\\documentclass[presentation]{beamer}\n"
"[DEFAULT-PACKAGES]"
"[PACKAGES]"
@ -1189,6 +1207,32 @@ https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbit
)
#+end_src
** 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/
#+begin_src emacs-lisp
(after! org
(add-to-list 'org-src-lang-modes '("latex-macros" . latex))
(defvar org-babel-default-header-args:latex-macros
'((:results . "raw")
(:exports . "results")))
(defun prefix-all-lines (pre body)
(with-temp-buffer
(insert body)
(string-insert-rectangle (point-min) (point-max) pre)
(buffer-string)))
(defun org-babel-execute:latex-macros (body _params)
(concat
"\n#+HTML_HEAD_EXTRA: <div style=\"display: none\"> \\(\n"
(prefix-all-lines "#+HTML_HEAD_EXTRA: " body)
"\n#+HTML_HEAD_EXTRA: \\)</div>\n"))
)
#+end_src
** TODO [#A] View PDF in org mode
#+begin_src emacs-lisp :tangle no
(defun tdh-org-include-img-from-pdf (&rest _)
@ -1384,9 +1428,36 @@ Ressources:
(setq org-ref-show-broken-links t)
;; Display information on the citation
(setq org-ref-show-citation-on-enter t)
(add-to-list 'org-ref-helm-user-candidates
'("Open pdf in Zathura" . (lambda () (call-process "zathura" nil 0 nil (concat
(file-name-as-directory org-ref-pdf-directory)
(car (org-ref-get-bibtex-key-and-file))
".pdf"))))
t)
(add-to-list 'org-ref-helm-user-candidates
'("Drag and Drop" . (lambda () (call-process "/bin/bash" nil 0 nil "-c" (concat
"dragon-drag-and-drop "
(file-name-as-directory org-ref-pdf-directory)
(car (org-ref-get-bibtex-key-and-file))
".pdf"))))
t)
)
#+end_src
#+begin_src emacs-lisp
(defun tdh-org-ref-open-pdf-at-point ()
"Open the pdf in external program for bibtex key under point if it exists."
(interactive)
(let* ((results (org-ref-get-bibtex-key-and-file))
(key (car results))
(pdf-file (funcall org-ref-get-pdf-filename-function key)))
(if (file-exists-p pdf-file)
(call-process "zathura" nil 0 nil pdf-file)
(message "no pdf found for %s" key))))
#+end_src
** Org Noter
- https://github.com/weirdNox/org-noter
@ -1434,6 +1505,21 @@ Ressources:
:with-todo-keywords nil
:html-wrap-src-lines nil
:table-of-contents nil)
("bibliography"
:base-directory "~/Cloud/thesis/ressources/notes/"
:base-extension "org"
:publishing-directory "~/Cloud/thesis/ressources/docs/"
:author "Dehaeze Thomas"
:email "dehaeze.thomas@gmail.com/"
:recursive nil
:publishing-function org-html-publish-to-html
:auto-preamble t
:auto-sitemap nil
:html-link-up "index.html"
:html-link-home "index.html"
:with-todo-keywords nil
:html-wrap-src-lines nil
:table-of-contents nil)
("nass-simscape"
:base-directory "~/Cloud/thesis/matlab/nass-simscape/org/"
:base-extension "org"
@ -1565,7 +1651,7 @@ Ressources:
#+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"))
(call-process "zathura" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".pdf"))
)
(after! org
@ -1600,7 +1686,7 @@ Then it would be nice to automatically prefix the =CUSTOM_ID= property (until th
"Capture screenshot and insert the resulting file.
The screenshot tool is determined by `org-download-screenshot-method'."
(interactive)
(defvar filename (concat "./figs/" (read-string "Enter file name:") ".png"))
(setq filename (concat "./figs/" (read-string "Enter file name:") ".png"))
(shell-command (concat "maim -s " filename))
(insert (format "[[file:%s]]" filename))
)
@ -1772,7 +1858,7 @@ https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_c
Don't ask for confirmation when evaluating following blocs
#+begin_src emacs-lisp
(defun tdh-org-confirm-babel-evaluate (lang body)
(not (member lang '("emacs-lisp" "latex" "matlab" "sh"))))
(not (member lang '("emacs-lisp" "latex" "matlab" "sh" "latex-macros"))))
(after! org
(setq org-confirm-babel-evaluate 'tdh-org-confirm-babel-evaluate))
@ -1792,8 +1878,8 @@ Use the current window for C-c ' source editing
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?✎)
("#+end_src" . ?□)
("#+begin_quote" . ?»)
("#+end_quote" . ?«)))))
("#+begin_quote" . ?«)
("#+end_quote" . ?»)))))
(turn-on-prettify-symbols-mode))
(add-hook 'org-mode-hook #'tdh-org-prettify-symbols)
#+end_src