aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-20 15:56:27 +1100
committerYuchen Pei <hi@ypei.me>2022-10-20 15:56:27 +1100
commite0408b2cb6dd773a512a15c55dfe46e4babed654 (patch)
treec0fe672a7f94cd3eb19510ebbe973d3db8d48ad2
parent179461ba0ec028a408a836c2f277e3f3a998c33a (diff)
org store and capture
-rw-r--r--luwak.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/luwak.el b/luwak.el
index c8e5470..88946f4 100644
--- a/luwak.el
+++ b/luwak.el
@@ -89,6 +89,24 @@ When non-nill, swap the tor-switch in prefix-arg effect."
index))
(reverse index)))
+(defun luwak-guess-title ()
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward "^[^[:space:]]" nil t)
+ (buffer-substring-no-properties (1- (point))
+ (progn (end-of-line 1) (point)))))
+
+(defun luwak-org-store-link ()
+ (when (derived-mode-p 'luwak-mode)
+ (org-link-store-props
+ :type "luwak"
+ :link (plist-get luwak-data :url)
+ :description (luwak-guess-title))))
+
+(org-link-set-parameters "luwak"
+ :follow #'luwak-open
+ :store #'luwak-org-store-link)
+
(defun luwak-open (url)
"Open URL in luwak."
(interactive "sUrl to open: ")