summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2021-07-27 18:57:18 +1000
committerYuchen Pei <me@ypei.me>2021-07-27 18:57:18 +1000
commit38509b84f7ea0dfed2186a454ba2a82e12c0e590 (patch)
tree1c275bb6dcb31637165c7cc269fc3f25cffe1f41
parent8dd984effdc99dda0426ac715e7e34c90422be20 (diff)
updated open and store link to allow open and store sections.
rt:id:ticket-id/history-id
-rw-r--r--rt-liberation-org.el36
1 files changed, 25 insertions, 11 deletions
diff --git a/rt-liberation-org.el b/rt-liberation-org.el
index 70dd536..15a0451 100644
--- a/rt-liberation-org.el
+++ b/rt-liberation-org.el
@@ -38,18 +38,30 @@
the query (for links starting with 'query:')."
(require 'rt-liberation)
(cond
- ((string-match "^id:\\([^#]+\\)\\(#\\(.+\\)\\)?" link)
- (let ((id (match-string 1 link))
- (section (string-to-number (or (match-string 3 link) "0"))))
+ ((string-match "^id:\\([^/]+\\)\\(/\\(.+\\)\\)?" link)
+ (let (
+ (id (match-string 1 link))
+ (history-id (match-string 3 link))
+ )
(rt-liber-browse-query (format "id = \"%s\"" id))
(rt-liber-next-ticket-in-browser)
(rt-liber-ticket-at-point)
- (dotimes (unused section)
- (rt-liber-viewer2-next-section-in))
- ))
+ (if history-id
+ (let (
+ (current-history-id (alist-get 'id (rt-liber-viewer2-get-section-data)))
+ (previous-history-id nil)
+ )
+ (while (not (or (string-equal history-id current-history-id)
+ (eq current-history-id previous-history-id)))
+ (setq previous-history-id current-history-id)
+ (rt-liber-viewer2-next-section-in)
+ (setq current-history-id (alist-get 'id (rt-liber-viewer2-get-section-data)))
+ )
+ ))))
((string-match "^query:\\(.+\\)" link)
(rt-liber-browse-query (match-string 1 link)))
- (t (error "Unrecognized link type '%s'" link))))
+ (t (error "Unrecognized link type '%s'" link))
+ ))
(defun rt-org-store-link ()
"Stores an rt link in ticket-browser mode."
@@ -57,10 +69,12 @@
(let ((ticket (or (get-text-property (point) 'rt-ticket)
rt-liber-ticket-local)))
(when ticket
- (let (
- (link (concat "rt:id:" (rt-liber-ticket-id-only ticket)))
- (subject (cdr (assoc "Subject" ticket)))
- )
+ (let* (
+ (ticket-id-link (concat "rt:id:" (rt-liber-ticket-id-only ticket)))
+ (subject (cdr (assoc "Subject" ticket)))
+ (history-id (alist-get 'id (rt-liber-viewer2-get-section-data)))
+ (link (concat ticket-id-link (if history-id (concat "/" history-id) "")))
+ )
(org-link-add-props
:link link
:description subject