static-sites/bases/do-blog/resources/documents/lisp/fetch-jira-summary-from-jir...

1.8 KiB
Executable File

Fetch jira summary from JIRA-ID under cursor with emacs

.. title: Fetch jira summary from JIRA-ID under cursor with emacs .. slug: fetch-jira-summary-from-jira-id-under-cursor-with-emacs .. date: 2016-11-10 10:45:13 UTC .. tags: lisp, emacs .. category: lisp .. link: .. description: Example to insert jira comment and link at cursor position in emacs .. type: text

The below snippet will grab the JIRA-ID under your cursor and use it to look up the summary and past it next to the JIRA-ID.

You need to have org-jira installed because this makes use of org-jira-get-issue-by-id to look up the ticket details.

(defun org-jira-get-summary ()
  "insert summary next to ticket id from jira"
  (interactive)
  (let ((jira_id (thing-at-point 'symbol)))
    (forward-symbol 1)
    (insert (format " - %s" 
      (cdr (assoc 'summary (car (org-jira-get-issue-by-id jira_id))))))))

This next snippet does the same as the first except it also replaces the ID with a link back to jira

(defun org-jira-get-summary-url ()
  "insert summary next to ticket id from jira with url link"
  (interactive)
  (let ((jira_id (thing-at-point 'symbol)))
    (sp-kill-symbol 1)
    (insert (format "[[%s][%s]] - %s" (concatenate 'string jiralib-url "browse/" jira_id) jira_id  
      (cdr (assoc 'summary (car (org-jira-get-issue-by-id jira_id))))))))

You will need to also place the code below some where to make the jira methods available, hopefully these will be merged directly into org jira soon.

(require 'org-jira)