:PROPERTIES: :ID: 5579f7b0-3b00-4751-9211-9b9381481954 :END: #+TITLE: org-mode #+Author: Yann Esposito tags :: [[id:e459f88b-5f6d-4547-b6b2-08d4815c1ede][emacs]] * tips - ~(org-num-mode)~ to show numbers * org-agenda To display the list of clocked tasks in agenda, type =L= to pass in =org-agenda-log-mode=. * configuration #+begin_src elisp ;; function needed to have nice name displayed by helm (defun org-capture-todo () "Capture a todo." (interactive) (org-capture nil "t")) (defun org-capture-pause () "Capture a pause." (interactive) (org-capture nil "p")) (defun org-capture-review () "Capture a review." (interactive) (org-capture nil "r")) (defun org-capture-work () "Capture a work." (interactive) (org-capture nil "w")) (defun org-capture-meeting () "Capture time spend during meeting." (interactive) (org-capture nil "m")) (defun org-capture-email () "Capture time spend in email." (interactive) (org-capture nil "e")) (defun org-capture-chat () "Capture time spend in chat." (interactive) (org-capture nil "c")) (defun fci-mode-override-advice (&rest args) "https://github.com/alpaker/fill-column-indicator/issues/45.") (defun org-publish-force () "Force publish blog by deleting the cache." (interactive) (save-excursion (delete-directory org-publish-timestamp-directory t) (org-publish "blog" t))) (defun org-publish-current-file-keep-position () "Force publish blog by deleting the cache." (interactive) (save-excursion (org-publish-current-file))) (defun org-publish-current-project-keep-position () "Force publish blog by deleting the cache." (interactive) (save-excursion (org-publish-current-project))) (defun org-publish-assets () "Force publish assets." (interactive) (save-excursion (org-publish "assets" t))) (defun org-publish-draft () "Force publish assets." (interactive) (save-excursion (org-publish "draft" t))) (defun org-mode-config () "Org-mode." ;; EXPERIMENTAL (setq helm-org-rifle-org-directories "~/.org/") (setq helm-org-rifle-org-directories-filename-regex "\.org(\.gpg)?$") (setq helm-org-rifle-directories-recursive t) ;; EXPERIMENTAL (setq org-todo-keywords '((sequence "TODO(t)" "IN-PROGRESS(p)" "|" "DONE(d)" "HOLD(h@/!)" "CANCELED(c@/!)") (sequence "|" "PAUSE(p)" "CHAT(c)" "EMAIL(e)" "MEETING(m)" "REVIEW(r)"))) (require 'org-download) (setq-default org-download-image-dir "~/.org/img") ;; generate stable ids for headers, human readable, github-like (require 'org-auto-id) ;; Align tags (add-hook 'focus-in-hook (lambda () (progn (setq org-tags-column 60)) (org-align-all-tags))) (add-hook 'focus-out-hook (lambda () (progn (setq org-tags-column 60)) (org-align-all-tags))) ;; org-sticky-full-path (setq org-sticky-header-full-path 'full) (setq org-sticky-header-heading-star ">") (setq org-sticky-header-outline-path-separator "/") ;; src block indentation / editing / syntax highlighting (setq org-src-fontify-natively t org-src-window-setup 'current-window ;; edit in current window org-src-strip-leading-and-trailing-blank-lines t org-src-preserve-indentation t ;; do not put two spaces on the left org-src-tab-acts-natively t) ;; Org Journal (setq org-journal-dir "~/.org/journal/") (setq org-journal-file-type "daily") (setq org-journal-file-format "%Y-%m-%d.org") (evil-leader/set-key "ooj" 'org-journal-new-entry) (defvar birth-date "1977-03-05") (defun str-time-to-year-float (date-str) (/ (float-time (apply 'encode-time (mapcar (lambda (x) (if (null x) 0 x)) (parse-time-string date-str)))) (* 365.25 24 60 60))) (defun y-date () "Number of year since my birth" (let ((y (- (str-time-to-year-float (format-time-string "%Y-%m-%d" (current-time))) (str-time-to-year-float birth-date)))) (format "∆y=%.2f (%d)" y (floor (* 365.25 y))))) (defun my/journal-template () (mapconcat 'identity `(,(format "#+Title: Journal (%s - %s)" (format-time-string "%Y-%m-%d" (current-time)) (y-date)) "#+Author: Yann Esposito" ,(format "#+Date: [%s]" (format-time-string "%Y-%m-%d" (current-time))) "#+STARTUP: showeverything" "" "- tags :: [[id:ad2aac23-4550-4f9a-acf3-3bd2c5d0cb5e][journal]] " "" "* Resumé Journée" "" " | sommeil | ?/5 | horrible -> comme un bébé |" " | activité φ | ?/5 | au lit -> activité sportive |" " | nourriture | ?/5 | malbouffe -> saine |" " | humeur | ?/5 | exécrable -> excellente |" " | interêt | ?/5 | habituel -> exceptionel |" "" "- Faits positifs" "- Faits marquants" "- Résumé des discussions intéressantes" "- Réflexions/Éssais") "\n")) (setq org-journal-date-format "%Y-%m-%d %A") (setq org-journal-file-header 'my/journal-template) ;; Org Roam (setq org-roam-directory "~/.org/journal") (setq org-roam-graph-viewer "/System/Applications/Preview.app/Contents/MacOS/Preview") (setq org-roam-buffer-position 'left) ;; (setq org-roam-buffer "*my-buffer-name*") (setq org-roam-buffer-width 0.4) ;; (setq org-roam-link-title-format "R:%s") (setq org-roam-capture-templates '(("d" "default" plain (function org-roam--capture-get-point) "%?" :file-name "%(format-time-string \"%Y-%m-%d--%H-%M-%SZ--${slug}\" (current-time) t)" :head "#+TITLE: ${title}\n#+Author: Yann Esposito\n\ntags ::\nsource ::\n" :unnarrowed t))) (evil-leader/set-key "orr" 'org-roam) (evil-leader/set-key "orf" 'org-roam-find-file) (evil-leader/set-key "ori" 'org-roam-insert) (evil-leader/set-key "orb" 'org-roam-switch-to-buffer) (evil-leader/set-key "org" 'org-roam-graph) (org-roam-mode +1) ;; Org Capture ;; Org capture is really neat. So for now I use these infos. ;; *** Templates ;; You can specify your own properties in the property list for the template, and then you can access those properties with plist-get and org-capture-plist. Here's a brief example: ;; ;; (defun my/expense-template () ;; (format "Hello world %s" (plist-get org-capture-plist :account))) ;; (setq org-capture-templates '(("x" "Test entry 1" plain ;; (file "~/tmp/test.txt") ;; (function my/expense-template) ;; :account "Account:Bank") ;; ("y" "Test entry 2" plain ;; (file "~/tmp/test.txt") ;; (function my/expense-template) ;; :account "Account:AnotherBank"))) (setq org-capture-templates '(("t" "todo" entry (file "~/.org/TODO.org") "** TODO %?\n %U\n %a\n") ;; time tracker ("c" "chat" entry (file "~/.org/tracker.org") "** CHAT %?\n %U\n %a\n" :clock-in t :clock-resume t) ("e" "email" entry (file "~/.org/tracker.org") "** EMAIL %?\n %U\n %a\n" :clock-in t :clock-resume t) ("m" "meeting" entry (file "~/.org/tracker.org") "** MEETING %? :meeting:\n %U\n %a\n" :clock-in t :clock-resume t) ("p" "pause" entry (file "~/.org/tracker.org") "* PAUSE pause %?\n %U\n" :clock-in t :clock-resume t) ("r" "review" entry (file "~/.org/tracker.org") "* REVIEW %?\n %U\n %a\n" :clock-in t :clock-resume t) ("w" "work" entry (file "~/.org/tracker.org") "** IN-PROGRESS %?\n %U\n %a\n" :clock-in t :clock-resume t))) (evil-leader/set-key "oc." 'org-capture) (evil-leader/set-key "oct" 'org-capture-todo) (evil-leader/set-key "occ" 'org-capture-chat) (evil-leader/set-key "oce" 'org-capture-email) (evil-leader/set-key "ocm" 'org-capture-meeting) (evil-leader/set-key "ocp" 'org-capture-pause) (evil-leader/set-key "ocr" 'org-capture-review) (evil-leader/set-key "ocw" 'org-capture-work) (evil-leader/set-key "ocof" 'org-capture-refile) (evil-leader/set-key "ocol" 'org-capture-goto-last-stored) (evil-leader/set-key "oxF" 'org-publish-force) (evil-leader/set-key "oxf" 'org-publish-current-file-keep-position) (evil-leader/set-key "oxp" 'org-publish-current-project-keep-position) (evil-leader/set-key "oxa" 'org-publish-assets) (evil-leader/set-key "oxd" 'org-publish-draft) ;; *** Projectile (setq org-projectile-file "TODO.org") ;; *** Refile ;; to sync with beorg on iCloud ;; create a symlink named "~/.org" to iCloud dir for beorg (when (not (file-symlink-p "~/.org")) (if (not (file-exists-p "~/.org")) (let ((icloudpath (concat (getenv "HOME") "/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/org"))) (f-symlink icloudpath "~/.org")) (message "%" "~/.org exists and is not a symlink to iCloud for beorg"))) ;; Refile to either the =refile.org= file or to =agenda.org= org =standup.org= (setq org-refile-target-files '("~/.org/tracker.org")) (setq org-refile-targets '((nil :maxlevel . 5) (org-refile-target-files :maxlevel . 5))) ;; *** Agenda (setq org-agenda-files '("~/.org/TODO.org" "~/.org/tracker.org")) ;; ** Org Annotate ;; Ability to take annotate some files, can of double usage with org-capture. ;; Still, I keep that keyboard shortcut here. (defun my-org-settings () (org-display-inline-images) (spacemacs/toggle-auto-fill-mode-on) (setq fill-column 75) (abbrev-mode) (org-indent-mode)) (add-hook 'org-mode-hook #'my-org-settings) (evil-leader/set-key "oa" 'org-annotate-file) (setq org-annotate-file-storage-file "~/.org/annotations.org") ;; ** Org colums ;; I can pass in org-column view mode with SPC-o-v-c (evil-leader/set-key "ovc" 'org-columns) (setq org-columns-default-format "%TODO %3PRIORITY %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM %8TAGS(TAG)") ;; ** Deft (setq deft-extensions '("org" "gpg" "md" "txt")) (setq deft-recursive t) (setq deft-use-filter-string-for-filename t) (setq deft-default-extension "org") (setq deft-directory "~/.org") ;; ** Look and Feel ;; I like to have something different than ellipsis because I often use them ;; myself. (setq org-ellipsis "⤵") ;; *** Colors (setq solaryzed-yellow "#b58900") (setq solaryzed-orange "#cb4b16") (setq solaryzed-red "#d30102") (setq solaryzed-magenta "#d33682") (setq solaryzed-violet "#6c71c4") (setq solaryzed-blue "#268bd2") (setq solaryzed-cyan "#2aa198") (setq solaryzed-green "#859900") ;; **** Spacemacs bug workaround ;; To handle a colorization bug; see https://github.com/syl20bnr/spacemacs/issues/9950 (add-hook 'org-mode-hook (lambda () (hl-todo-mode -1) nil)) ;; **** Rainbow colors (custom-theme-set-faces 'user `(org-level-1 ((t (:foreground ,solaryzed-green))))) (custom-theme-set-faces 'user `(org-level-2 ((t (:foreground ,solaryzed-cyan))))) (custom-theme-set-faces 'user `(org-level-3 ((t (:foreground ,solaryzed-blue))))) (custom-theme-set-faces 'user `(org-level-4 ((t (:foreground ,solaryzed-violet))))) (custom-theme-set-faces 'user `(org-level-5 ((t (:foreground ,solaryzed-magenta))))) (custom-theme-set-faces 'user `(org-level-6 ((t (:foreground ,solaryzed-red))))) (custom-theme-set-faces 'user `(org-level-7 ((t (:foreground ,solaryzed-orange))))) (custom-theme-set-faces 'user `(org-level-8 ((t (:foreground ,solaryzed-yellow))))) (setq org-priority-faces `((?A . (:background ,solaryzed-red :foreground "white" :weight bold)) (?B . (:foreground ,solaryzed-yellow)) (?C . (:foreground ,solaryzed-cyan)))) ;; **** Keywords colors (setq org-todo-keyword-faces `(("TODO" . (:foreground ,solaryzed-orange :weight bold)) ("IN-PROGRESS" . (:foreground ,solaryzed-yellow :weight bold)) ("HOLD" . (:foreground ,solaryzed-violet :weight bold)) ("DONE" . (:foreground ,solaryzed-green :weight bold)) ("CANCELED" . (:foreground ,solaryzed-green :weight bold)) ("CHAT" . (:foreground ,solaryzed-blue :weight bold)) ("EMAIL" . (:foreground ,solaryzed-blue :weight bold)) ("MEETING" . (:foreground ,solaryzed-blue :weight bold)) ("PAUSE" . (:foreground ,solaryzed-cyan :weight bold)) ("REVIEW" . (:foreground ,solaryzed-blue :weight bold)))) ;; Org Babel (org-babel-do-load-languages 'org-babel-load-languages '(;; other Babel languages (shell . t) (haskell . t) (plantuml . t))) (setq org-plantuml-jar-path "~/bin/plantuml.jar") ;; https://github.com/alpaker/fill-column-indicator/issues/45 (advice-add 'org-html-fontify-code :around (lambda (fun &rest args) (advice-add 'fci-mode :override #'fci-mode-override-advice) (let ((result (apply fun args))) (advice-remove 'fci-mode #'fci-mode-override-advice) result))) ;; FIX easytemplates issue ;; https://github.com/syl20bnr/spacemacs/issues/11798 (when (version<= "9.2" (org-version)) (require 'org-tempo))) #+end_src