Distracted by Emacs

I write these blog entries in Markdown mode, but markdown-mode in Emacs doesn't stick links at the end of the text the way God intended (and the way footnote-mode does). This is close, but not yet working:

(defun x-hugh-markdown-footnote (description)
  "A Small but Useful(tm) function to add a footnote in Markdown mode.

  FIXME: Not yet working, but close."
  (interactive "sDescription: ")
  (let ((current-line (line-number-at-pos))
        (last-line (line-number-at-pos (point-max)))
        (link (read-string "Link: "))
        (link-number (x-hugh-get-next-link-number)))
    (save-excursion
      (if (> (- last-line current-line) 1)
          ()
        (insert-string "\n"))
      (goto-char (point-max))
      (insert-string (format "\n[%d]: %s" link-number link)))
    (insert-string (format "[%s][%d]" description link-number))))

(defun x-hugh-get-next-link ()
  "Figure out the number for the next link."
  (interactive)
  (save-excursion
    (goto-char (point-max))
    (beginning-of-line)
    (if (looking-at "\\[\\([0-9]\\)]:")
        (eval (+ 1 (string-to-number (match-string 1))))
      (eval 0))))

Right now it craps out with a "Wrong type argument: integer-or-marker-p, nil" when it runs x-hugh-get-next-link. Doubtless I'm doing a bad thing in my half-baked attempt to return a number. But still, close!

(UPDATE: I figured it out! To return a number, wrap it with eval. Fixed above. Working!)

(Believe it or not, I started out to write about Github and bioinformatics. Such is the life of the easily distracted.)

ObMusic: "The Balcony" by The Rumour Said Fire. Reminds me of 60s folk. I like it.