本文介绍了在迷你缓冲区中显示当前文件的完整路径的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取我正在使用 emacs 编辑的文件的完整路径.
- 有这样的功能吗?
- 如果没有,获得它的 elisp 函数是什么?
- 如何将结果(路径名)复制到剪贴板以便重复使用?
我使用的是 Mac OS X 和 Aqumacs.
(setq filepath (get-fullpath-current-file)) ???(复制到剪贴板'文件路径)???
添加
(defun 显示文件名 ()在迷你缓冲区中显示完整路径文件名."(交互的)(消息(缓冲区文件名))(kill-new (file-truename buffer-file-name)))(全局设置键 "C-cz" 'show-file-name)结合我得到的两个答案,我可以得到我想要的.感谢您的回答.还有一些问题.
- (file-truename) 有什么用?
- 我可以将路径名复制到系统 (OS) 的剪贴板,而不是终止环,以便我可以将这些信息用于其他应用程序吗?
解决方案
内置函数 buffer-file-name
为您提供文件的完整路径.
最好的办法是让您的 emacs 窗口始终显示您的系统名称和您当前正在编辑的缓冲区的完整路径:
(setq frame-title-format(列表(格式%s %%S: %%j"(系统名称))'(缓冲区文件名%f"(dired-directory dired-directory "%b"))))
你也可以这样做:
(defun show-file-name ()在迷你缓冲区中显示完整路径文件名."(交互的)(消息(缓冲区文件名)))(global-set-key [C-f1] 'show-file-name) ;或者你想要的任何其他键
I need to get the full path of the file that I'm editing with emacs.
- Is there a function for that?
- If not, what would be the elisp function for getting that?
- How can I copy the result (path name) to a clipboard so that I can reuse it?
I'm using Mac OS X and Aqumacs.
(setq filepath (get-fullpath-current-file)) ???
(copy-to-clipboard 'filepath) ???
ADDED
(defun show-file-name () "Show the full path file name in the minibuffer." (interactive) (message (buffer-file-name)) (kill-new (file-truename buffer-file-name)) ) (global-set-key "C-cz" 'show-file-name)
Combining the two answers that I got, I could get what I want. Thanks for the answers. And some more questions.
- What's for (file-truename)?
- Can I copy the path name to System(OS)'s clipboard, not the kill ring so that I can use the info with the other apps?
解决方案
It's the built-in function buffer-file-name
that gives you the full path of your file.
The best thing to do is to have your emacs window to always show your system-name and the full path of the buffer you're currently editing :
(setq frame-title-format
(list (format "%s %%S: %%j " (system-name))
'(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
You can also do something like this :
(defun show-file-name ()
"Show the full path file name in the minibuffer."
(interactive)
(message (buffer-file-name)))
(global-set-key [C-f1] 'show-file-name) ; Or any other key you want
这篇关于在迷你缓冲区中显示当前文件的完整路径的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!