Thursday, 5 September 2013

How to get emacs regular expression to recognize paths with and without line numbers

How to get emacs regular expression to recognize paths with and without
line numbers

Trying to get emacs to buttonize paths like so
/nfs/path/to/file /nfs/path/to/file_with_line_number:40
but not paths with a trailing colon /nfs/path/to/file:
This doesn't work
(defun buttonize-buffer-nfs-with-line ()
"turn all file paths with line numbers into buttons"
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\(/nfs[^ \>\<\(\)\t\n,\'\";:]+?\)\|\(/nfs[^
\>\<\(\)\t\n,\'\";]+:[0-9]+?\)" nil t)
(make-button (match-beginning 0) (match-end 0) :type
'find-file-button))))
(add-hook 'find-file-hook 'buttonize-buffer-nfs-with-line)

No comments:

Post a Comment