From 1f7e7ebf24fd72aa4bcebd978b03590101f5df2f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 20 Apr 2022 10:43:20 -0500 Subject: Add org-drawer-list --- init.el | 6 ++++++ lisp/+org-drawer-list.el | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 lisp/+org-drawer-list.el diff --git a/init.el b/init.el index a69081f..f6ed814 100644 --- a/init.el +++ b/init.el @@ -1913,6 +1913,12 @@ See also `crux-reopen-as-root-mode'." (:else 'url-retrieve))) (add-hook 'dired-mode-hook 'org-download-enable)) +(setup (:straight (org-drawer-list + :host github + :repo "d12frosted/org-drawer-list")) + (:load-after org) + (:also-load +org-drawer-list)) + (setup (:straight org-mime) (:option org-mime-export-ascii 'utf-8)) 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 @@ +;;; +org-drawer-list.el --- Add stuff to org drawers easy-style -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(require 'org) +(require '+org) +(require 'ol) +(require 'org-drawer-list) + +(defcustom +org-drawer-list-resources-drawer "RESOURCES" + "Where to add links with `+org-drawer-list-add-resource'.") + +(defun +org-drawer-list-add-resource (url &optional title) + "Add URL to the resource drawer of the current tree. +The resource drawer is given by the variable +`+org-drawer-list-resources-drawer'. If optional TITLE is given, +format the list item as an Org link." + (interactive + (let* ((clipboard-url (if (string-match-p (rx (sequence bos + (or "http" + "gemini" + "gopher" + "tel" + "mailto"))) + (current-kill 0)) + (string-trim (current-kill 0)) + (read-string "URL: "))) + (url-title (let ((clipboard-headings + (+org-insert--get-title-and-headings clipboard-url))) + (read-string "title (edit): " + (completing-read + "title: " clipboard-headings + nil nil nil nil (car clipboard-headings)))))) + (list clipboard-url url-title))) + (org-drawer-list-add +org-drawer-list-resources-drawer + (org-link-make-string url title))) + +(provide '+org-drawer-list) +;;; +org-drawer-list.el ends here -- cgit 1.4.1-21-gabe81