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-#."
    (let* ((beg (progn (skip-chars-backward "[:alnum:]-") (point)))
           (end (progn (skip-chars-forward "[:alnum:]-") (point)))
           (str (buffer-substring-no-properties beg end)))
        (when (string-match (format "\\(%s-[[:digit:]]+\\).*" jira-prefix) str)
            ,(format "" (match-string 1 str))
            ,beg . ,end))))))

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

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