I'm writing a debugger front end, and in that over the course of program execution a number of marks get added inside the source code. In other buffers such as a buffer showing execution history, or a buffer containing backtrace or callstack, I'd like to have in those buffers text information that click through to the source text.
Looking at http://www.gnu.org/software/emacs/manual/html_node/elisp/Clickable-Text.html , the process to add clickable text seems a bit cumbersome.
For example just to set a region of text to be clickable I need something like:
(setq link-start (point))
(insert (format "%s" (realgud-loc-marker loc)))
(setq link-end (point))
(add-text-properties
link-start link-end
'(mouse-face highlight
help-echo "mouse-2: go to this location"))
(setq map (make-sparse-keymap))
(define-key map [mouse-2] 'realgud:follow-link)
(define-key map [mouse-1] 'realgud:follow-link)
(define-key map [follow-link] 'mouse-face)
(put-text-property link-start link-end 'keymap map)
(put-text-property link-start link-end 'loc loc)
And then I also need a definition to realgud:follow-link:
(defun realgud:follow-link(event)
(interactive "e")
(let* ((pos (posn-point (event-end event)))
(loc (get-text-property pos 'loc)))
(if (realgud-loc-p loc)
(realgud-loc-goto loc))))
All of this seems a bit boilerplate and there's a lot of it. I could write my own routines, for this, but since this seems like a pretty basic think to do: link some text in a buffer to a mark somewhere else, I figure there must already be a package that simplifies the above. Is there?