From 7969cd4251368706607fcaf887d00e0b720ef08a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 1 Dec 2020 09:28:21 -0800 Subject: Add things to deal with reading list in org-mode --- oni-org/capture-templates/reading-url-protocol.org | 9 ++++++++ oni-org/capture-templates/reading-url.org | 7 ++++++ oni-org/oni-org.el | 27 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 oni-org/capture-templates/reading-url-protocol.org create mode 100644 oni-org/capture-templates/reading-url.org diff --git a/oni-org/capture-templates/reading-url-protocol.org b/oni-org/capture-templates/reading-url-protocol.org new file mode 100644 index 0000000..2c53274 --- /dev/null +++ b/oni-org/capture-templates/reading-url-protocol.org @@ -0,0 +1,9 @@ +* READ %:description +:PROPERTIES: +:CREATED: %U +:END: + +[[%:link]] + +#+BEGIN: oni-backlinks +#+END diff --git a/oni-org/capture-templates/reading-url.org b/oni-org/capture-templates/reading-url.org new file mode 100644 index 0000000..316c0c3 --- /dev/null +++ b/oni-org/capture-templates/reading-url.org @@ -0,0 +1,7 @@ +* READ %(oni-org-get-url-link (read-from-minibuffer "URL: ")) %^g +:PROPERTIES: +:CREATED: %U +:END: + +#+BEGIN: oni-backlinks +#+END diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index be193b9..efa90a2 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2020.1119.235712 +;; Version: 2020.1130.123201 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org-plus-contrib org-bullets org-edna diminish all-the-icons) ;; This program is free software; you can redistribute it and/or modify @@ -335,6 +335,7 @@ also move point to the start of the heading." (setq org-agenda-custom-commands '(("i" "Inbox" tags "CATEGORY=\"inbox\"") ("t" "Next" tags-todo "TODO=\"NEXT\"-CATEGORY=\"inbox\"") + ("r" "Reading list" tags-todo "TODO=\"READ\"") ("s" "Someday" tags-todo "TODO=\"TODO\"-CATEGORY=\"inbox\"") ("p" "Projects & ideas" tags "CATEGORY=\"project\"|CATEGORY=\"idea\"") ("c" "Today's (Current) tasks" tags "SCHEDULED=\"\"") @@ -342,7 +343,7 @@ also move point to the start of the heading." ("wo" "Overview" ((tags-todo "+work+FOR=\"\"") (tags-todo "+work+FOR=\"Jordan\"") (tags-todo "+work+FOR=\"Remy\""))) - ("wt" "Word todo" tags-todo "+work+FOR=\"\"") + ("wt" "Work todo" tags-todo "+work+FOR=\"\"") ("wj" "Topics for Jordan" tags-todo "+work+1o1+FOR=\"Jordan\"") ("wr" "Topics for Remy" tags-todo "+work+1o1+FOR=\"Remy\"") ("S" "Shopping" tags-todo "+shopping"))) @@ -378,6 +379,22 @@ After running it once remove it from `org-capture-after-finalize-hook'." (setf (frame-height) 24) (add-hook 'org-capture-after-finalize-hook 'oni-org-delete-frame-once))) +(defun oni-org-get-url-title (url) + "Load URL and parse out the title." + (with-current-buffer + (url-retrieve-synchronously url) + (unwind-protect + (when (re-search-forward (rx "")) ">") nil t) + (let ((title-start (point))) + (when (re-search-forward (rx "") nil t) + (string-trim (buffer-substring title-start (- (point) 8)))))) + (kill-buffer)))) + +(defun oni-org-get-url-link (url) + "Turn URL into an org link." + (let ((title (oni-org-get-url-title url))) + (format "[[%s][%s]]" url title))) + (setq org-capture-templates `(("i" "Inbox" entry (file "") (file ,(expand-file-name "inbox.org" oni-org-capture-template-directory))) @@ -387,6 +404,12 @@ After running it once remove it from `org-capture-after-finalize-hook'." (file ,(expand-file-name "task.org" oni-org-capture-template-directory))) ("a" "Appointment" entry (file "") (file ,(expand-file-name "appointment.org" oni-org-capture-template-directory))) + ("u" "URL to read" entry (file "") + (file ,(expand-file-name "reading-url.org" oni-org-capture-template-directory)) + :immediate-finish t) + ("U" "URL to read" entry (file "") + (file ,(expand-file-name "reading-url-protocol.org" oni-org-capture-template-directory)) + :immediate-finish t) ("j" "Journal entry" entry (file+olp+datetree ,(oni-org-expand-to-home "documents/gtd/journal.org")) -- cgit v1.2.3-54-g00ecf