lang/org: major refactor
The motivation for this change was to rethink lang/org's flags. Many of its former flags represented non-features. Therefore, its flags have been reduced to five: +dragndrop, +ipython, +pandoc, +gnuplot and +present. Everything else is included as org-load-hooks and treated as reasonable defaults. Other changes: - Fixes #1502: don't autopair certain pairs when in a math region - Fixes #1483: broken localleader in org-agenda - Adds gnuplot support #1108 - Doom's org submodules have been moved into lang/org/contrib/, because I expect there will be *many* more to come, and I don't want to pollute the moudle's root.
This commit is contained in:
parent
9752cc005c
commit
11bfb17894
17 changed files with 972 additions and 809 deletions
39
modules/lang/org/contrib/dragndrop.el
Normal file
39
modules/lang/org/contrib/dragndrop.el
Normal file
|
@ -0,0 +1,39 @@
|
|||
;;; lang/org/contrib/dragndrop.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! org-download
|
||||
:commands (org-download-dnd org-download-dnd-base64)
|
||||
:init
|
||||
;; Add these manually so that org-download is lazy-loaded...
|
||||
(add-to-list 'dnd-protocol-alist '("^\\(https?\\|ftp\\|file\\|nfs\\):" . +org-dragndrop-download-dnd))
|
||||
(add-to-list 'dnd-protocol-alist '("^data:" . org-download-dnd-base64))
|
||||
|
||||
(advice-add #'org-download-enable :override #'ignore)
|
||||
:config
|
||||
(setq org-download-image-dir org-attach-directory
|
||||
org-download-heading-lvl nil
|
||||
org-download-timestamp "_%Y%m%d_%H%M%S"
|
||||
org-download-screenshot-method
|
||||
(cond (IS-MAC "screencapture -i %s")
|
||||
(IS-LINUX
|
||||
(cond ((executable-find "maim") "maim -s %s")
|
||||
((executable-find "scrot") "scrot -s %s")))))
|
||||
|
||||
;; Handle non-image files a little differently. Images should be inserted
|
||||
;; as-is, as image previews. Other files, like pdfs or zips, should be linked
|
||||
;; to, with an icon indicating the type of file.
|
||||
(advice-add #'org-download-insert-link :override #'+org-dragndrop*insert-link)
|
||||
|
||||
(defun +org-dragndrop*download-subdir ()
|
||||
(when (file-in-directory-p buffer-file-name org-directory)
|
||||
(file-relative-name buffer-file-name org-directory)))
|
||||
|
||||
(defun +org-dragndrop*download-fullname (path)
|
||||
"Write PATH relative to current file."
|
||||
(let ((dir (or (if buffer-file-name (file-name-directory buffer-file-name))
|
||||
default-directory)))
|
||||
(if (file-in-directory-p dir org-directory)
|
||||
(file-relative-name path dir)
|
||||
path)))
|
||||
(advice-add #'org-download--dir-2 :override #'ignore)
|
||||
(advice-add #'org-download--fullname
|
||||
:filter-return #'+org-dragndrop*download-fullname))
|
38
modules/lang/org/contrib/ipython.el
Normal file
38
modules/lang/org/contrib/ipython.el
Normal file
|
@ -0,0 +1,38 @@
|
|||
;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! ob-ipython
|
||||
:defer t
|
||||
:init
|
||||
(defvar +ob-ipython-local-runtime-dir nil)
|
||||
|
||||
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
|
||||
|
||||
(defun +org|babel-load-ipython (lang)
|
||||
(and (string-prefix-p "jupyter-" (symbol-name lang))
|
||||
(require 'ob-ipython nil t)))
|
||||
(add-hook '+org-babel-load-functions #'+org|babel-load-ipython)
|
||||
:config
|
||||
(set-popup-rules!
|
||||
'(("\\*ob-ipython.*"
|
||||
:slot 2 :side right :size 100 :height 0.2
|
||||
:select nil :quit nil :transient nil)
|
||||
("^\\*Python"
|
||||
:slot 0 :side right :size 100
|
||||
:select nil :quit nil :ttl nil)
|
||||
("\\*Python:.*"
|
||||
:slot 0 :side right :size 100
|
||||
:select nil :quit nil :transient nil)))
|
||||
|
||||
;; advices for remote kernel and org-src-edit
|
||||
(advice-add 'ob-ipython--create-repl :override #'+org*ob-ipython--create-repl)
|
||||
(advice-add 'org-babel-edit-prep:ipython :override #'+org*org-babel-edit-prep:ipython)
|
||||
(advice-add 'org-babel-execute:ipython :override #'+org*org-babel-execute:ipython)
|
||||
(advice-add 'org-babel-ipython-initiate-session :override #'+org*org-babel-ipython-initiate-session)
|
||||
|
||||
;; retina resolution image hack
|
||||
(when (eq window-system 'ns)
|
||||
(advice-add 'ob-ipython--write-base64-string :around #'+org*ob-ipython--write-base64-string))
|
||||
|
||||
;; ipython has its own async keyword, disable ipython in ob-async.
|
||||
(after! ob-async
|
||||
(add-to-list 'ob-async-no-async-languages-alist "ipython")))
|
44
modules/lang/org/contrib/present.el
Normal file
44
modules/lang/org/contrib/present.el
Normal file
|
@ -0,0 +1,44 @@
|
|||
;;; lang/org/contrib/present.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +org-present-text-scale 7
|
||||
"The `text-scale-amount' for `org-tree-slide-mode'.")
|
||||
|
||||
(after! ox
|
||||
(add-to-list 'org-export-backends 'beamer))
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(def-package! ox-reveal
|
||||
:after ox
|
||||
:init
|
||||
;; Fix #1127, where ox-reveal adds an errant entry to
|
||||
;; `org-structure-template-alist'
|
||||
(setq org-reveal-note-key-char nil)
|
||||
:config
|
||||
(setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js@3/"
|
||||
org-reveal-mathjax t))
|
||||
|
||||
|
||||
(def-package! org-tree-slide
|
||||
:commands org-tree-slide-mode
|
||||
:config
|
||||
(org-tree-slide-simple-profile)
|
||||
(setq org-tree-slide-skip-outline-level 2
|
||||
org-tree-slide-activate-message " "
|
||||
org-tree-slide-deactivate-message " "
|
||||
org-tree-slide-modeline-display nil)
|
||||
|
||||
(map! :map org-tree-slide-mode-map
|
||||
:n [right] #'org-tree-slide-move-next-tree
|
||||
:n [left] #'org-tree-slide-move-previous-tree)
|
||||
|
||||
(add-hook! 'org-tree-slide-mode-after-narrow-hook
|
||||
#'(+org-present|detect-slide
|
||||
+org-present|add-overlays
|
||||
org-display-inline-images))
|
||||
|
||||
(add-hook 'org-tree-slide-mode-hook #'+org-present|init-org-tree-window)
|
||||
(advice-add #'org-tree-slide--display-tree-with-narrow
|
||||
:around #'+org-present*narrow-to-subtree))
|
Loading…
Add table
Add a link
Reference in a new issue