summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-02-03 19:45:16 -0800
committerFranck Cuny <franck@fcuny.net>2022-02-03 19:45:16 -0800
commit84b6cddc5bee7c45f87879a64ef0b9f802787b0e (patch)
tree29eb84d727c9f956346c321febe0817e378b33d8
parentclipboard: function to get clipboard's content (diff)
downloademacs.d-84b6cddc5bee7c45f87879a64ef0b9f802787b0e.tar.gz
org: new capture for bookmarks
Add a new template to capture bookmarks. The link needs to be in the
clipboard, and the title of the entry uses the title of the page.
-rw-r--r--emacs/custom/fcuny-org.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/custom/fcuny-org.el b/emacs/custom/fcuny-org.el
index 5aff1c9..39cfbe6 100644
--- a/emacs/custom/fcuny-org.el
+++ b/emacs/custom/fcuny-org.el
@@ -1,4 +1,5 @@
 (require 'fcuny-vars)
+(require 'fcuny-clipboard)
 
 (use-package org-ml
   :ensure t)
@@ -108,6 +109,7 @@
                       ,(expand-file-name "notes.org" org-directory)
                       ,(expand-file-name "tasks.org" org-directory)
                       ,(expand-file-name "projects.org" org-directory)
+                      ,(expand-file-name "bookmarks.org" org-directory)
                       ,(expand-file-name "journal.org" org-directory)))
   (org-agenda-show-all-dates t)
   (calendar-week-start-day 1)
@@ -130,6 +132,22 @@
                         ((org-agenda-overriding-header "Not yet started")
                          (org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled))))))))
 
+(defun fcuny/org-capture/link ()
+  "Make a TODO entry with a link in clipboard. Page title is used as an entry heading."
+  (let* ((url-string (s-trim (fcuny/clipboard-get-contents)))
+         (pdf (string-suffix-p "pdf" url-string)))
+    (unless pdf
+      (let ((page-title (org-web-tools--html-title (org-web-tools--get-url url-string))))
+        (concat "* "
+                page-title
+                "\t%^g"
+                "\n:PROPERTIES:\n:CREATED: %T\n:URL: "
+                url-string
+                "\n:END:\n%?")))))
+
+(use-package org-web-tools
+  :ensure t)
+
 (use-package org-capture
   :ensure nil
   :after (org)
@@ -141,6 +159,9 @@
      ("n" "Note" entry (file "notes.org")
       "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n")
 
+     ("l" "Bookmark" entry (file "bookmarks.org")
+      (function fcuny/org-capture/link))
+
      ("j" "Journal" entry
       (file+olp+datetree "journal.org")
       "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n" :tree-type day))))