Regex 如何让emacs正则表达式识别带行号和不带行号的路径
试图让emacs像这样对路径进行按钮化 /nfs/path/to/file /nfs/path/to/file,行号:40 但不是带尾随冒号的路径 /nfs/path/to/file: 这不管用Regex 如何让emacs正则表达式识别带行号和不带行号的路径,regex,emacs,elisp,Regex,Emacs,Elisp,试图让emacs像这样对路径进行按钮化 /nfs/path/to/file /nfs/path/to/file,行号:40 但不是带尾随冒号的路径 /nfs/path/to/file: 这不管用 (defun buttonize-buffer-nfs-with-line () "Turn all file paths with line numbers into buttons." (interactive) (save-excursion (goto-char (point
(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)
(使用第()行取消按钮化缓冲区nfs)
“将所有带有行号的文件路径转换为按钮。”
(互动)
(省去远足
(转到字符(最小点))
(while(research forward)“\(/nfs[^\>\你需要反斜杠来摆脱你的反斜杠
"/nfs[^ ><()\t\n,'\";:]+\\(:[0-9]+\\)?"
“/nfs[^>你需要反斜杠来摆脱你的反斜杠
"/nfs[^ ><()\t\n,'\";:]+\\(:[0-9]+\\)?"
“/nfs[^>太好了。行了。太好了。行了。