summaryrefslogtreecommitdiff
path: root/rt-liberation-org.el
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2021-07-26 15:23:23 +1000
committerYuchen Pei <me@ypei.me>2021-07-26 15:23:23 +1000
commitb601ed675fa6ff247e61b8907dbbd41bbd32bcdd (patch)
treeb18005ebdae3b0f9118a548ce8f0d4a20dc734e7 /rt-liberation-org.el
parent4168946a884a48683f37d58d04284ef8f752e865 (diff)
Adding functionality storing an rt org link in ticket browser mode.
Diffstat (limited to 'rt-liberation-org.el')
-rw-r--r--rt-liberation-org.el25
1 files changed, 22 insertions, 3 deletions
diff --git a/rt-liberation-org.el b/rt-liberation-org.el
index 74530b1..1e59f15 100644
--- a/rt-liberation-org.el
+++ b/rt-liberation-org.el
@@ -33,7 +33,7 @@
(require 'org)
(defun rt-org-open (link)
- "Open the rt LINK.
+ "Opens the rt LINK.
Open the rt ticket (for links starting with 'id:') or run
the query (for links starting with 'query:')."
(require 'rt-liberation)
@@ -47,12 +47,31 @@
(rt-liber-browse-query (match-string 1 link)))
(t (error "Unrecognized link type '%s'" link))))
+(defun rt-org-store-link ()
+ "Stores an rt link in ticket-browser mode."
+ (require 'rt-liberation)
+ (let* (
+ (ticket (get-text-property (point) 'rt-ticket))
+ (link (concat "rt:id:" (rt-liber-ticket-id-only ticket)))
+ (subject (cdr (assoc "Subject" ticket)))
+ )
+ (org-link-add-props
+ :link link
+ :description subject
+ )
+ (when ticket link)
+ ))
+
;; org-add-link-type is obsolete as of org-mode 9. Instead we will use the
;; org-link-set-parameters method
(if (fboundp 'org-link-set-parameters)
(org-link-set-parameters "rt"
- :follow #'rt-org-open)
- (org-add-link-type "rt" rt-org-open))
+ :follow #'rt-org-open
+ :store #'rt-org-store-link
+ )
+ (org-add-link-type "rt" rt-org-open)
+ (add-hook 'org-store-link-functions 'rt-org-store-link)
+ )
;;; _
(provide 'rt-liberation-org)