Answers:
browse-url-of-file
给定目录后,使用应该可以工作。
您可以执行如下命令来打开当前文件的目录:
(defun browse-file-directory ()
"Open the current file's directory however the OS would."
(interactive)
(if default-directory
(browse-url-of-file (expand-file-name default-directory))
(error "No `default-directory' to open")))
然后M-x browse-file-directory应在操作系统的文件浏览器中打开目录。
对于MS Windows:
加载库w32-browser.el
并使用命令w32explore
。它完全符合您的要求。请参阅MS Shell Execute。
如果您还使用Dired +,则Dired中M-RET
的文件名或目录名将为其打开Windows资源管理器。
首先将完整路径复制到剪贴板:
;; you need install xsel under Linux
;; xclip has some problem when copying under Linux
(defun copy-yank-str (msg &optional clipboard-only)
(unless clipboard-only (kill-new msg))
(cond
;; display-graphic-p need windows 23.3.1
((and (display-graphic-p) x-select-enable-clipboard)
(x-set-selection 'CLIPBOARD msg))
(t (with-temp-buffer
(insert msg)
(shell-command-on-region (point-min) (point-max)
(cond
((eq system-type 'cygwin) "putclip")
((eq system-type 'darwin) "pbcopy")
(t "xsel -ib")))))))
(defun cp-fullpath-of-current-buffer ()
"copy full path into the yank ring and OS clipboard"
(interactive)
(when buffer-file-name
(copy-yank-str (file-truename buffer-file-name))
(message "file full path => clipboard & yank ring")))