From 38509b84f7ea0dfed2186a454ba2a82e12c0e590 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 27 Jul 2021 18:57:18 +1000 Subject: updated open and store link to allow open and store sections. rt:id:ticket-id/history-id --- rt-liberation-org.el | 36 +++++++++++++++++++++++++----------- 1 file 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 -- cgit v1.2.3