尝试让emacs像这样按钮化按钮
/ NFS /路径/到/文件 / NFS /路径/到/ file_with_line_number:40
但不是带尾随冒号的路径 / NFS /路径/到/文件:
这不起作用
(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)
答案 0 :(得分:4)
你需要反斜杠 - 逃避你的反斜杠。我从
开始"/nfs[^ ><()\t\n,'\";:]+\\(:[0-9]+\\)?"