aboutsummaryrefslogtreecommitdiff
path: root/luwak.el
diff options
context:
space:
mode:
Diffstat (limited to 'luwak.el')
-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: ")