Make Jira Ticket Names a Link Using Embark
June 23, 2022

In this post I want to share a little way I extended Embark so that I could quickly navigate from Jira tickets to its corresponding URL. For this, you should have Embark installed. The extension is as follows:

(defvar jira-prefix "WORK")

(defun jira-link ()
  "Target a JIRA link of the form WORK-#."
  (save-excursion
    (let* ((beg (progn (skip-chars-backward "[:alnum:]-") (point)))
           (end (progn (skip-chars-forward "[:alnum:]-") (point)))
           (str (buffer-substring-no-properties beg end)))
      (save-match-data
        (when (string-match (format "\\(%s-[[:digit:]]+\\).*" jira-prefix) str)
          `(url
            ,(format "https://reifyhealth.atlassian.net/browse/%s" (match-string 1 str))
            ,beg . ,end))))))

(use-package embark
  :ensure t
  :bind
  ;; ... bindings here ...
  :init
  ;; ... init config here ...
  :config
  ;; ... config here ...
  (add-to-list 'embark-target-finders #'jira-link))

Just set jira-prefix to you ticket prefix and it should work.