是否有一些 emacs lisp 代码会自动在缓冲区中查找 /nfs 文件路径并突出显示/链接到它们?所以点击它们会打开那个文件?
示例路径:/nfs/foo/bar/file.txt
可能已经有一个包可以做到这一点,但我不知道。
这段代码将按钮添加到它认为看起来像文件路径的文本中。您可以添加功能'buttonize-buffer,以find-file-hooks或手动(或有条件)运行它。
(define-button-type 'find-file-button
'follow-link t
'action #'find-file-button)
(defun find-file-button (button)
(find-file (buffer-substring (button-start button) (button-end button))))
(defun buttonize-buffer ()
"turn all file paths into buttons"
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "/[^ \t]*" nil t)
(make-button (match-beginning 0) (match-end 0) :type 'find-file-button))))
; (add-hook 'find-file-hook 'buttonize-buffer) ; uncomment to add to find file
Run Code Online (Sandbox Code Playgroud)
小智 5
尝试内置包 ffap(在点查找文件):
http://www.emacswiki.org/emacs/FindFileAtPoint
http://www.gnu.org/software/emacs/manual/html_node/emacs/FFAP.html
我不使用次要模式,而是将一个键绑定到ffap我在文件名上击中的键。
| 归档时间: |
|
| 查看次数: |
1755 次 |
| 最近记录: |