org.el 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ;; [[https://github.com/syl20bnr/spacemacs/issues/11798][Org source block babel expansion stopped working · Issue #11798 · syl20bnr/spacemacs]]
  2. (when (version<= "9.2" (org-version))
  3. (require 'org-tempo))
  4. ;; Origin <https://changelog.complete.org/archives/9865-emacs-2-introducing-org-mode>.
  5. (setq org-ellipsis "…")
  6. ;; Origin <https://old.reddit.com/r/emacs/comments/mt51h4/strike_through_orgdone_tasks_in_agenda_to/>.
  7. (set-face-attribute 'org-headline-done nil :strike-through t)
  8. (setq plain-org-wiki-directory (expand-file-name "~/src/gitlab.com/wigust/notes/"))
  9. ;; (with-eval-after-load 'org
  10. ;; (setq org-format-latex-options
  11. ;; (plist-put org-format-latex-options :scale 1.5))
  12. ;; (setq org-todo-keywords
  13. ;; '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))))
  14. (with-eval-after-load 'org
  15. (require 'org-protocol) ; For `org-capture' from Xorg
  16. (add-to-list 'org-file-apps '("\\.png\\'" . system))
  17. (add-to-list 'org-file-apps '("\\.dot\\'" . "xdot %s"))
  18. (org-babel-do-load-languages
  19. 'org-babel-load-languages
  20. '((R . t)
  21. (emacs-lisp . t)
  22. (scheme . t)
  23. (shell . t)))
  24. ;; [[https://www.orgroam.com/manual.html][Org-roam User Manual]]
  25. (setq org-roam-directory (expand-file-name "~/src/gitlab.com/wigust/notes"))
  26. (setq org-roam-db-gc-threshold most-positive-fixnum)
  27. ;; XXX: Fix File is missing: Cannot open load file, No such file or directory, org-roam-protocol
  28. ;; (require 'org-roam-protocol)
  29. )
  30. (setq org-startup-folded 'showall) ; Show all in `org-mode' at startup
  31. (setq org-email-link-description-format "Email %c: %s") ; More than 30 character
  32. (setq org-capture-templates
  33. '(("c" "Note" item (file "~/.notes") "%?")
  34. ("f" "File email" entry (file+headline "inbox.org" "Email")
  35. "* %U %a by [[mailto:%:fromaddress][%:fromname]]"
  36. :immediate-finish nil
  37. :prepend nil)
  38. ;; Requires org-capture-extension
  39. ;; https://github.com/sprig/org-capture-extension
  40. ("l" "Protocol" item (file "web.org")
  41. "[[%:link][%:description]]\n%i"
  42. :immediate-finish t)
  43. ("L" "Protocol Link" item (file "web.org")
  44. "[[%:link][%:description]]"
  45. ;; (concat "* TODO [[%:link][%:description]]\nSCHEDULED: " (format-time-string "<%Y-%m-%d %a>"))
  46. :immediate-finish t)
  47. ("X" "emacs-org-capture" item (file "web.org")
  48. "[[%:link]]"
  49. ;; (concat "* TODO [[%:link]]\nSCHEDULED: " (format-time-string "<%Y-%m-%d %a>"))
  50. :immediate-finish t)
  51. ("r" "Respond ro email" entry (file+headline "inbox.org" "Email")
  52. "[[mailto:%:fromaddress][%:fromname]]"
  53. :immediate-finish t
  54. :prepend t)
  55. ("t" "Tasks" entry (file+headline ".notes" "Tasks")
  56. "* TODO %? \n%T" :prepend t)
  57. ("b" "buffer" entry (file "TODO.org") "* TODO [[%F]]%?")
  58. ("B" "blog" plain (file "blog.org") "%?")
  59. ("e" "emacs" plain (file "emacs.org") "%?")
  60. ("g" "guix" plain (file "guix.org") "%?")
  61. ("i" "Templates for TODO")
  62. ("ii" "TODO" entry (file "TODO.org") "* TODO %?")
  63. ("ir" "TODO region" entry (file "TODO.org") "* TODO %i"
  64. :immediate-finish t)
  65. ("m" "music" plain (file "music.org") "%?")
  66. ("n" "pdfview" item (file "pdf.org") "%a %?")
  67. ("o" "misc" plain (file "misc.org") "%?")
  68. ("p" "phrase" item (file "phrase.org") "%?")
  69. ("r" "read" plain (file "read.org") "%?")
  70. ("v" "video" plain (file "video.org") "%?")
  71. ("V" "watch" plain (file "watch.org") "%?")
  72. ("w" "work" plain (file "work.org") "%?")))
  73. (defun org-capture-inbox ()
  74. (interactive)
  75. (org-capture nil "f")
  76. (org-capture-finalize))
  77. (setq org-publish-project-alist
  78. '(("org-notes"
  79. :base-directory "~/src/gitlab.com/wigust/notes/"
  80. :base-extension "org"
  81. :publishing-directory "/var/www/org"
  82. :recursive t
  83. :publishing-function org-html-publish-to-html
  84. :headline-levels 4 ; Just the default for this project.
  85. :auto-preamble t
  86. :auto-sitemap t
  87. :sitemap-filename "index.org")))
  88. (defun wigust-mir-org-uniq ()
  89. "Remove duplicate subheadings, preserving order."
  90. ;; See <http://lists.gnu.org/archive/html/emacs-orgmode/2018-01/msg00000.html>.
  91. (interactive)
  92. (let ((seen (make-hash-table :test 'equal))
  93. (removed 0))
  94. (save-excursion
  95. (org-map-entries (lambda ()
  96. (let ((heading (org-get-heading t t t t)))
  97. (if (not (gethash heading seen))
  98. (puthash heading t seen)
  99. (org-cut-subtree)
  100. (org-backward-heading-same-level 1)
  101. (setq removed (1+ removed)))))
  102. (format "LEVEL=%s" (1+ (org-current-level)))
  103. 'tree))
  104. (message "Removed %d duplicates" removed)))
  105. ;; See <http://mbork.pl/2017-12-04_Embedding_files_in_Org-mode>.
  106. (defun wi-org-insert-file (filename)
  107. "Insert Elisp code block recreating file named FILENAME."
  108. (interactive "f")
  109. (let ((base64-string
  110. (with-temp-buffer
  111. (insert-file-contents-literally filename)
  112. (base64-encode-region (point-min) (point-max))
  113. (buffer-string))))
  114. (insert (format "#+BEGIN_SRC emacs-lisp :results output silent\n (with-temp-file %S\n (insert (base64-decode-string\n %S)))\n#+END_SRC" filename base64-string))))
  115. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  116. (add-hook 'org-mode-hook 'company-mode)
  117. (add-hook 'org-mode-hook 'emojify-mode)
  118. ;;;
  119. ;;; Haunt
  120. ;;;
  121. (setq ox-haunt-base-dir (expand-file-name "~/src/haunt-blog"))
  122. (setq org-export-with-toc nil)
  123. ;;;
  124. ;;; org-appear-mode
  125. ;;;
  126. (add-hook 'org-mode-hook 'org-appear-mode)
  127. (setq org-appear-autoemphasis t)
  128. (setq org-appear-autolinks t)
  129. (setq org-appear-autosubmarkers t)
  130. ;;;
  131. ;;; Block
  132. ;;;
  133. ;; (with-eval-after-load 'org
  134. ;; (require 'company-org-block)
  135. ;; (setq company-org-block-edit-style 'auto) ;; 'auto, 'prompt, or 'inline
  136. ;; (add-hook 'org-mode-hook
  137. ;; (lambda ()
  138. ;; (add-to-list (make-local-variable 'company-backends)
  139. ;; 'company-org-block))))