emacs is über

| | Comments (2)

My current favorite emacs hack, thanks to SeanO. This extends find-file-at-point (which I have bound to C-x C-p) to automatically look a bit further for a line number and use it if available:

(defadvice find-file-at-point (around goto-line compile activate)
  (let ((line (and (looking-at ".*:\\([0-9]+\\)")
                   (string-to-number (match-string 1)))))
    ad-do-it
    (and line (goto-line line))))

2 Comments

Excellent idea.

But please note, that parse-integer is not emacs lisp function (it's Common Lisp, and is defined for emacs in calendar code). So I've changed your code. I had to replace (parse-integer ...) with (car (read-from-string ...)).

You're right. I posted the version from his wiki page, not the one I used. Tho, I use string-to-number. I've corrected the post itself.

Leave a comment