一直以来对于w3m、tramp、dired等与shell关系密切的mode不是很了解,没有仔细读过代码。但总觉得应该是调用shell命令,再将shell命令的输出重定向到emacs中进行处理。今天在网上看到了相关的方法:
- 调用shell命令
(defun zj-open-directory-with-explorer () "在windows中用explorer浏览当前目录" (interactive) (shell-command "explorer.exe .") (browse-url "www.google.cn") )
- 处理shell命令输出
(defun zj-display-directory-files () "执行shell命令并处理它的输出。这里为显示当前目录下的文件" (interactive) (message (shell-command-to-string "ls -l")) )