summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2021-06-17 11:29:34 +1000
committerYuchen Pei <me@ypei.me>2021-06-17 11:29:34 +1000
commit4168946a884a48683f37d58d04284ef8f752e865 (patch)
tree3691569eac7430ca7928bea78f8502376524b8c2
parentac02bc9d463da1ac3028b3ade5d4c89bd7d1204d (diff)
Adding initial org integration rt-liberation-org.
- Adding org hyperlinks and support for following the link: rt:id:<id> opens ticket with ticket id <id> in rt-liberation-viewer-mode rt:query:<query string> opens query results in rt-liberation-browser-mode - Will add support for storing the link in a follow up commit
-rw-r--r--rt-liberation-org.el59
1 files changed, 59 insertions, 0 deletions
diff --git a/rt-liberation-org.el b/rt-liberation-org.el
new file mode 100644
index 0000000..74530b1
--- /dev/null
+++ b/rt-liberation-org.el
@@ -0,0 +1,59 @@
+;;; rt-liberation-org.el --- Org integration for rt-liberation -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
+
+;; Author: Yuchen Pei <hi@ypei.me>
+;; Maintainer: Yoni Rabkin <yrk@gnu.org>
+
+;; This file is a part of rt-liberation.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3 of the
+;; License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public
+;; License along with this program; if not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;; MA 02111-1307, USA.
+
+;;; Installation and Use:
+;;
+;; Detailed instructions for installation and use can be found in the
+;; rt-liberation manual, in the doc/ directory of the distribution.
+
+;;; History:
+;;
+;; Started near the end of 2008.
+(require 'org)
+
+(defun rt-org-open (link)
+ "Open the rt LINK.
+ Open the rt ticket (for links starting with 'id:') or run
+ the query (for links starting with 'query:')."
+ (require 'rt-liberation)
+ (cond
+ ((string-match "^id:\\(.+\\)" link)
+ (let (
+ (ticket-alist (list (cons "id" (concat "ticket/" (match-string 1 link)))))
+ )
+ (rt-liber-viewer2-display-ticket-history ticket-alist (current-buffer))))
+ ((string-match "^query:\\(.+\\)" link)
+ (rt-liber-browse-query (match-string 1 link)))
+ (t (error "Unrecognized link type '%s'" 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))
+
+;;; _
+(provide 'rt-liberation-org)
+;;; rt-liberation-org.el ends here