summaryrefslogtreecommitdiffhomepage
path: root/eos
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-01-30 05:15:10 +0000
committerjao <jao@gnu.org>2021-01-30 05:15:10 +0000
commitc1649be9e82738e76967a5995e3e4890cf35170c (patch)
tree23faf1e799fda394a487e1c8a6aa760dc6ca5998 /eos
parent52f9319be526c255059fca3f721af8ac7a11abf8 (diff)
downloadelibs-c1649be9e82738e76967a5995e3e4890cf35170c.tar.gz
elibs-c1649be9e82738e76967a5995e3e4890cf35170c.tar.bz2
embark targts: org links
Diffstat (limited to 'eos')
-rw-r--r--eos/jao-embark-targets.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/eos/jao-embark-targets.el b/eos/jao-embark-targets.el
index 0461769..1887b79 100644
--- a/eos/jao-embark-targets.el
+++ b/eos/jao-embark-targets.el
@@ -27,6 +27,24 @@
(require 'embark)
(declare-function w3m-anchor "w3m")
+(declare-function org-link-any-re "ol")
+(declare-function org-open-link-from-string "ol")
+(declare-function org-in-regexp "org-macs")
+
+(defun jao-embark-targets--org-link ()
+ (when (derived-mode-p 'org-mode)
+ (when (org-in-regexp org-link-any-re)
+ (let ((lnk (match-string-no-properties 2)))
+ (if (string-match-p "http://.+" lnk)
+ (cons 'url lnk)
+ (cons 'org-link (match-string-no-properties 0)))))))
+
+(embark-define-keymap jao-embark-targets-org-link-map
+ "Actions for org links"
+ ((kbd "RET") org-open-link-from-string))
+
+(add-to-list 'embark-target-finders #'jao-embark-targets--org-link)
+(add-to-list 'embark-keymap-alist '(org-link . jao-embark-targets-org-link-map))
(defvar jao-embark-targets-video-url-rx
(format "^https?://\\(?:www\\.\\)?%s/.+"