From 84b6cddc5bee7c45f87879a64ef0b9f802787b0e Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 3 Feb 2022 19:45:16 -0800 Subject: 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. --- emacs/custom/fcuny-org.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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)))) -- cgit 1.4.1