Linking to Trac tickets in email

Since I do a lot of referring to Trac ticket numbers in email messages, most visibly on the xmlroff-list mailing list, I wrote an Emacs function that finds the Trac ticket references in the current buffer and inserts a sorted list of the ticket references and their URLs at the end of the buffer.

The code (if WordPress hasn’t done too much damage to it) is:

(defvar trac-base ""
  "Base to use when inserting links to trac tickets in email.")

(defun trac-base-xmlroff ()
  (setq trac-base "")
  (message trac-base))

(defun insert-trac-links ()
  "Insert links for Trac links."
  (let ((ticket-alist)
         (changeset-alist '()))
    (goto-char (point-min))
         "#([0-9]+)" nil t)
      (setq ticket-alist
              (add-to-list 'ticket-alist
 		   (match-beginning 1)
 		   (match-end 1))))))
    (goto-char (point-max))
    (insert "\\n")
    (dolist (ticket (sort ticket-alist '<))
      (insert (format
        "#%s %s/ticket/%s\\n"
        ticket trac-base ticket)))))

I have a separate `trac-base-xxx' function for setting `trac-base' for each Trac that I regularly use, and I use GNUS customizations to call the appropriate `trac-base-xxx' function when I enter specific email folders.

One Reply to “Linking to Trac tickets in email”

  1. A later rendition that moved the “/ticket/” to the individual ‘trac-base’ URLs makes this be equally useful for linking to Bugzilla tickets since the ‘trac-base’ can then be of the form “””.

Comments are closed.