aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-12-01 09:28:21 -0800
committerGravatar Tom Willemse2020-12-01 09:28:21 -0800
commit7969cd4251368706607fcaf887d00e0b720ef08a (patch)
tree09d2151f1c2e4d9c75cffa01a7f36d0233ecd17d
parent5cd4dee407f35c20d70f18dd95b44aa4ebb33499 (diff)
downloademacs-config-7969cd4251368706607fcaf887d00e0b720ef08a.tar.gz
emacs-config-7969cd4251368706607fcaf887d00e0b720ef08a.zip
Add things to deal with reading list in org-mode
-rw-r--r--oni-org/capture-templates/reading-url-protocol.org9
-rw-r--r--oni-org/capture-templates/reading-url.org7
-rw-r--r--oni-org/oni-org.el27
3 files changed, 41 insertions, 2 deletions
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 <tom@ryuslash.org>
;; 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=\"<today>\"")
@@ -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 "<title" (zero-or-more (not ">")) ">") nil t)
+ (let ((title-start (point)))
+ (when (re-search-forward (rx "</title>") 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"))