Put all org-board config in the relevant use-package call
This commit is contained in:
parent
6ff348bb1b
commit
a3417f5722
103
emacs/init.org
103
emacs/init.org
@ -1470,46 +1470,6 @@ A function to add ids to every heading in an Org file:
|
||||
|
||||
** Capture templates
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(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."
|
||||
(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: "))))
|
||||
(setq org-capture-bookmark-last-url url)
|
||||
(format "[[%s][%s]]" url title)))
|
||||
|
||||
(defun org-capture-bookmark-after-finalize ()
|
||||
"Runs `org-board-new' on the captured entry.
|
||||
Also saves to Wallabag."
|
||||
(let ((success (not org-note-abort))
|
||||
(key (plist-get org-capture-plist :key))
|
||||
(desc (plist-get org-capture-plist :description)))
|
||||
(when (and success
|
||||
(equal key "b")
|
||||
(equal desc "Bookmark")
|
||||
org-capture-bookmark-last-url)
|
||||
(org-board-new org-capture-bookmark-last-url)
|
||||
(wallabag-add-entry org-capture-bookmark-last-url
|
||||
(cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(let ((entry-url (format "%s/view/%s"
|
||||
wallabag-base-url
|
||||
(alist-get 'id data))))
|
||||
(message "Added bookmark to Wallabag: %s" entry-url)))))
|
||||
(setq org-capture-bookmark-last-url nil))))
|
||||
|
||||
(with-eval-after-load 'org
|
||||
(add-hook 'org-capture-prepare-finalize-hook
|
||||
#'org-capture-bookmark-after-finalize))
|
||||
|
||||
(setq org-capture-templates
|
||||
`(("L" "Lola task" entry
|
||||
(file+headline ,(agenda-files "todo.org") "Lola")
|
||||
@ -1530,12 +1490,7 @@ A function to add ids to every heading in an Org file:
|
||||
"* %i%?" :empty-lines 1)
|
||||
("l" "Log" entry
|
||||
(file ,(agenda-files "log.org"))
|
||||
"* %<%Y-%m-%d %H:%M:%S>%?")
|
||||
("b" "Bookmark" entry
|
||||
(file ,(concat (get-dropbox-directory)
|
||||
"/org/deft/bookmarks.org"))
|
||||
"* %(org-capture-bookmark-link)"
|
||||
:empty-lines 1)))
|
||||
"* %<%Y-%m-%d %H:%M:%S>%?")))
|
||||
#+END_SRC
|
||||
|
||||
** Refile targets
|
||||
@ -1943,6 +1898,62 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package org-board
|
||||
:defer t
|
||||
: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."
|
||||
(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: "))))
|
||||
(setq org-capture-bookmark-last-url url)
|
||||
(format "[[%s][%s]]" url title)))
|
||||
(defun org-capture-bookmark-after-finalize ()
|
||||
"Runs `org-board-new' on the captured entry.
|
||||
Also saves to Wallabag."
|
||||
(let ((success (not org-note-abort))
|
||||
(key (plist-get org-capture-plist :key))
|
||||
(desc (plist-get org-capture-plist :description)))
|
||||
(when (and success
|
||||
(equal key "b")
|
||||
(equal desc "Bookmark")
|
||||
org-capture-bookmark-last-url)
|
||||
(org-board-new org-capture-bookmark-last-url)
|
||||
(wallabag-add-entry org-capture-bookmark-last-url
|
||||
(cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(let ((entry-url (format "%s/view/%s"
|
||||
wallabag-base-url
|
||||
(alist-get 'id data))))
|
||||
(message "Added bookmark to Wallabag: %s" entry-url)))))
|
||||
(setq org-capture-bookmark-last-url 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))
|
||||
:config
|
||||
;; Use w3m instead of eww to open org-board archived links
|
||||
(advice-add 'org-board-open-with :around
|
||||
(lambda (oldfn filename-string arg &rest args)
|
||||
(if (and filename-string
|
||||
(or (and arg (eq org-board-default-browser 'system))
|
||||
(and (not arg) (eq org-board-default-browser 'eww))))
|
||||
(let ((filename (concat "file://"
|
||||
(s-chop-prefix "file://"
|
||||
filename-string))))
|
||||
(w3m filename t)
|
||||
0)
|
||||
(apply oldfn filename-string arg args))))
|
||||
:general
|
||||
(org-mode-map "C-c b" org-board-keymap))
|
||||
#+END_SRC
|
||||
|
Loading…
Reference in New Issue
Block a user