2

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)
4

1 回答 1

4

你需要反斜杠转义你的反斜杠。我会从

"/nfs[^ ><()\t\n,'\";:]+\\(:[0-9]+\\)?"
于 2013-09-06T02:02:07.960 回答