about summary refs log tree commit diff stats
path: root/lisp/+org-drawer-list.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+org-drawer-list.el')
-rw-r--r--lisp/+org-drawer-list.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/lisp/+org-drawer-list.el b/lisp/+org-drawer-list.el new file mode 100644 index 0000000..2fc7234 --- /dev/null +++ b/lisp/+org-drawer-list.el
@@ -0,0 +1,41 @@
1;;; +org-drawer-list.el --- Add stuff to org drawers easy-style -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(require 'org)
8(require '+org)
9(require 'ol)
10(require 'org-drawer-list)
11
12(defcustom +org-drawer-list-resources-drawer "RESOURCES"
13 "Where to add links with `+org-drawer-list-add-resource'.")
14
15(defun +org-drawer-list-add-resource (url &optional title)
16 "Add URL to the resource drawer of the current tree.
17The resource drawer is given by the variable
18`+org-drawer-list-resources-drawer'. If optional TITLE is given,
19format the list item as an Org link."
20 (interactive
21 (let* ((clipboard-url (if (string-match-p (rx (sequence bos
22 (or "http"
23 "gemini"
24 "gopher"
25 "tel"
26 "mailto")))
27 (current-kill 0))
28 (string-trim (current-kill 0))
29 (read-string "URL: ")))
30 (url-title (let ((clipboard-headings
31 (+org-insert--get-title-and-headings clipboard-url)))
32 (read-string "title (edit): "
33 (completing-read
34 "title: " clipboard-headings
35 nil nil nil nil (car clipboard-headings))))))
36 (list clipboard-url url-title)))
37 (org-drawer-list-add +org-drawer-list-resources-drawer
38 (org-link-make-string url title)))
39
40(provide '+org-drawer-list)
41;;; +org-drawer-list.el ends here