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:
Henrik Lissner 2019-06-28 16:53:26 +02:00
parent 9752cc005c
commit 11bfb17894
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
17 changed files with 972 additions and 809 deletions

View 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))