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 #+begin_src emacs-lisp
(after! org-agenda (after! org-agenda
(defun tdh-org-agenda-skip-scheduled () (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 (setq org-agenda-custom-commands
'(("w" "Work" tags-todo "@work") ;; All todos related to work '(("w" "Work"
("h" "Home" tags-todo "@home") ;; All todos not related to work ((org-ql-block '(and (tags "@work")
("q" . "Questions to ask") (todo "TODO")
("qc" "Questions to Cristophe" tags "@christophe/QUES" ((org-agenda-overriding-header "Questions to Christophe"))) (priority "A"))
("qm" "Questions to Muriel" tags "@muriel/QUES" ((org-agenda-overriding-header "Questions to Muriel"))) ((org-ql-block-header "Things to do")))
("qo" "Questions to Olivier" tags "@olivier/QUES" ((org-agenda-overriding-header "Questions to Olivier"))) (org-ql-block '(and (tags "@work")
("qq" "All questions" tags "/QUES" ((org-agenda-overriding-header "Other questions"))) (todo "TODO")
("n" "Next things to do" (priority "B"))
((tags "+PRIORITY+\"A\"" ((org-ql-block-header "Things to do")))
((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) (org-ql-block '(and (tags "@work")
(org-agenda-overriding-header "High-priority unfinished tasks:"))) (todo "TODO")
(agenda "") (priority "C"))
(todo "NEXT" ((org-agenda-skip-function 'tdh-org-agenda-skip-scheduled)(org-agenda-overriding-header "Next thing to do that are not scheduled"))) ((org-ql-block-header "Things to do")))))
(todo "MAIL" ((org-agenda-overriding-header "Email to write/reply"))) ("h" "Home"
(todo "WAIT" ((org-agenda-overriding-header "Things Waiting"))))) ((org-ql-block '(and (tags "@home")
("u" "Unscheduled tasks" todo "TODO" (todo "TODO")
((org-agenda-skip-function 'tdh-org-agenda-skip-scheduled) (priority "A"))
(org-agenda-overriding-header "Unscheduled TODO entries: "))) ((org-ql-block-header "Things to do")))
("R" "Already read Articles and Books" (org-ql-block '(and (tags "@home")
((org-ql-block '(and (todo "DONE") (todo "TODO")
(level 1) (priority "B"))
(tags "article" "inproceedings" "techreport" "inbook")) ((org-ql-block-header "Things to do")))
((org-ql-block-header "Articles"))) (org-ql-block '(and (tags "@home")
(org-ql-block '(and (todo "DONE") (todo "TODO")
(level 1) (priority "C"))
(tags "book")) ((org-ql-block-header "Things to do")))))
((org-ql-block-header "Books"))) ("q" "Questions to ask"
(org-ql-block '(and (todo "DONE") ((org-ql-block '(and (todo "QUES")
(level 1) (tags "@christophe"))
(tags "phdthesis")) ((org-ql-block-header "Questions")))
((org-ql-block-header "Phd Thesis"))) (org-ql-block '(and (todo "QUES")
(org-ql-block '(and (todo "DONE") (tags "@veijo"))
(level 1) ((org-ql-block-header "Veijo")))
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis"))) (org-ql-block '(and (todo "QUES")
((org-ql-block-header "Other Things")))) (not (tags "@veijo" "@christophe")))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/")))) ((org-ql-block-header "Other Questions")))))
("r" "Custom: Agenda and Emacs SOMEDAY [#A] items" ("R" "Already read Articles and Books"
((org-ql-block '(and (todo "READ") ((org-ql-block '(and (todo "DONE")
(level 1) (level 1)
(tags "article" "inproceedings" "techreport" "inbook")) (tags "article" "inproceedings" "techreport" "inbook"))
((org-ql-block-header "Article to Read"))) ((org-ql-block-header "Articles")))
(org-ql-block '(and (todo "READ") (org-ql-block '(and (todo "DONE")
(level 1) (level 1)
(tags "book")) (tags "book"))
((org-ql-block-header "Books to Read"))) ((org-ql-block-header "Books")))
(org-ql-block '(and (todo "READ") (org-ql-block '(and (todo "DONE")
(level 1) (level 1)
(tags "phdthesis")) (tags "phdthesis"))
((org-ql-block-header "Phd Thesis to Read"))) ((org-ql-block-header "Phd Thesis")))
(org-ql-block '(and (todo "READ") (org-ql-block '(and (todo "DONE")
(level 1) (level 1)
(not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis"))) (not (tags "article" "inproceedings" "techreport" "inbook" "book" "phdthesis")))
((org-ql-block-header "Other Things to Read")))) ((org-ql-block-header "Other Things"))))
((org-agenda-files '("~/Cloud/thesis/ressources/notes/"))))) ((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 #+end_src
@ -901,7 +919,7 @@ by spaces.
(after! org (after! org
;; Custom classes to use when exporting to latex ;; Custom classes to use when exporting to latex
(add-to-list 'org-latex-classes (add-to-list 'org-latex-classes
`("beamer" '("beamer"
,(concat "\\documentclass[presentation]{beamer}\n" ,(concat "\\documentclass[presentation]{beamer}\n"
"[DEFAULT-PACKAGES]" "[DEFAULT-PACKAGES]"
"[PACKAGES]" "[PACKAGES]"
@ -1189,6 +1207,32 @@ https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbit
) )
#+end_src #+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 ** TODO [#A] View PDF in org mode
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(defun tdh-org-include-img-from-pdf (&rest _) (defun tdh-org-include-img-from-pdf (&rest _)
@ -1384,9 +1428,36 @@ Ressources:
(setq org-ref-show-broken-links t) (setq org-ref-show-broken-links t)
;; Display information on the citation ;; Display information on the citation
(setq org-ref-show-citation-on-enter t) (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 #+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 ** Org Noter
- https://github.com/weirdNox/org-noter - https://github.com/weirdNox/org-noter
@ -1434,6 +1505,21 @@ Ressources:
:with-todo-keywords nil :with-todo-keywords nil
:html-wrap-src-lines nil :html-wrap-src-lines nil
:table-of-contents 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" ("nass-simscape"
:base-directory "~/Cloud/thesis/matlab/nass-simscape/org/" :base-directory "~/Cloud/thesis/matlab/nass-simscape/org/"
:base-extension "org" :base-extension "org"
@ -1565,7 +1651,7 @@ Ressources:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun tdh-open-org-pdf-externally () (defun tdh-open-org-pdf-externally ()
(interactive) (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 (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. "Capture screenshot and insert the resulting file.
The screenshot tool is determined by `org-download-screenshot-method'." The screenshot tool is determined by `org-download-screenshot-method'."
(interactive) (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)) (shell-command (concat "maim -s " filename))
(insert (format "[[file:%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 Don't ask for confirmation when evaluating following blocs
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun tdh-org-confirm-babel-evaluate (lang body) (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 (after! org
(setq org-confirm-babel-evaluate 'tdh-org-confirm-babel-evaluate)) (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)))) (mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?✎) `(("#+begin_src" . ?✎)
("#+end_src" . ?□) ("#+end_src" . ?□)
("#+begin_quote" . ?») ("#+begin_quote" . ?«)
("#+end_quote" . ?«))))) ("#+end_quote" . ?»)))))
(turn-on-prettify-symbols-mode)) (turn-on-prettify-symbols-mode))
(add-hook 'org-mode-hook #'tdh-org-prettify-symbols) (add-hook 'org-mode-hook #'tdh-org-prettify-symbols)
#+end_src #+end_src