Set up bookmark capture template to create standalone files
This commit is contained in:
parent
7041eb1ba7
commit
718e1c9934
@ -1900,19 +1900,35 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
:after org
|
||||
:init
|
||||
(defvar org-capture-bookmark-last-url nil)
|
||||
(defun org-capture-bookmark-link ()
|
||||
"Returns an org-mode link. If it finds
|
||||
a valid URL on the clipboard it uses that;
|
||||
otherwise, it prompts for a URL."
|
||||
(defvar org-capture-bookmark-last-title nil)
|
||||
|
||||
(defun org-capture-bookmark-get-url ()
|
||||
(let* ((clip (org-cliplink-clipboard-content))
|
||||
(parsed (url-generic-parse-url clip))
|
||||
(url (if (url-type parsed)
|
||||
clip
|
||||
(read-string "Bookmark URL: ")))
|
||||
(title (or (org-cliplink-retrieve-title-synchronously url)
|
||||
(read-string "Bookmark title: "))))
|
||||
(parsed (url-generic-parse-url clip)))
|
||||
(if (url-type parsed)
|
||||
clip
|
||||
(read-string "Bookmark URL: "))))
|
||||
|
||||
(defun org-capture-bookmark-get-title (url)
|
||||
(or (org-cliplink-retrieve-title-synchronously url)
|
||||
(read-string "Bookmark title: ")))
|
||||
|
||||
(defun org-capture-bookmark-file ()
|
||||
(let* ((url (org-capture-bookmark-get-url))
|
||||
(title (org-capture-bookmark-get-title url)))
|
||||
(setq org-capture-bookmark-last-url url)
|
||||
(format "[[%s][%s]]" url title)))
|
||||
(setq org-capture-bookmark-last-title title)
|
||||
(concat (get-dropbox-directory)
|
||||
(format "/org/%s.org" (org-roam--get-new-id title)))))
|
||||
|
||||
(defun org-capture-bookmark-link ()
|
||||
(format "[[%s][%s]]"
|
||||
org-capture-bookmark-last-url
|
||||
org-capture-bookmark-last-title))
|
||||
|
||||
(defun org-capture-bookmark-title ()
|
||||
org-capture-bookmark-last-title)
|
||||
|
||||
(defun org-capture-bookmark-after-finalize ()
|
||||
"Runs `org-board-new' on the captured entry.
|
||||
Also saves to Wallabag."
|
||||
@ -1923,6 +1939,8 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
(equal key "b")
|
||||
(equal desc "Bookmark")
|
||||
org-capture-bookmark-last-url)
|
||||
(goto-char (point-min))
|
||||
(search-forward "* Bookmark")
|
||||
(org-board-new org-capture-bookmark-last-url)
|
||||
(wallabag-add-entry org-capture-bookmark-last-url
|
||||
(cl-function
|
||||
@ -1931,15 +1949,16 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
wallabag-base-url
|
||||
(alist-get 'id data))))
|
||||
(message "Added bookmark to Wallabag: %s" entry-url)))))
|
||||
(setq org-capture-bookmark-last-url nil))))
|
||||
(setq org-capture-bookmark-last-url nil)
|
||||
(setq org-capture-bookmark-last-title nil))))
|
||||
|
||||
(add-hook 'org-capture-prepare-finalize-hook
|
||||
#'org-capture-bookmark-after-finalize)
|
||||
|
||||
(add-to-list 'org-capture-templates
|
||||
'("b" "Bookmark" entry
|
||||
(file ,(concat (get-dropbox-directory)
|
||||
"/org/deft/bookmarks.org"))
|
||||
"* %(org-capture-bookmark-link)"
|
||||
:empty-lines 1))
|
||||
'("b" "Bookmark" plain
|
||||
(file org-capture-bookmark-file)
|
||||
"#+TITLE: %(org-capture-bookmark-title)\n\n- tags :: [[file:deft/bookmarks.org][Bookmarks]]\n- source :: %(org-capture-bookmark-link)\n%?\n* Bookmark"))
|
||||
:config
|
||||
;; Use w3m instead of eww to open org-board archived links
|
||||
(advice-add 'org-board-open-with :around
|
||||
|
Loading…
Reference in New Issue
Block a user