エディタからエクスプローラーを起動する
- 最近、WordやExcelの仕事ばかりになってしまい、プログラムを書いてない
- ファイル共有先に色々書類を作成するが、フォルダ階層が深くて毎回探すのが面倒
- エディタに色々パスをメモするので、カーソル位置にあるパスをエクスプローラーで開くようにしてみた
xyzzy
- ネットで見つけたのを少し直しただけ
- 行の先頭から最後までをエクスプローラーの引き数に渡す
- フォルダでなくファイルの場合は、/selectを付ける
- そういえば、新人さんの目標に「関数型言語を使えるようになる」っていうのがあったけど、自分はまだ使えてないな
;;; open-explorer (defun open-explorer (fn) (flet ((get-arg () (if fn (if (file-directory-p fn) (concat "/e," (map-slash-to-backslash fn)) (concat "/e,/select," (map-slash-to-backslash fn))) (concat "/e," (map-slash-to-backslash (si:system-root)))) )) (call-process (concat (get-windows-directory) "explorer " (get-arg))) ) ) ;;; open path in current position with explorer (C-x x) (C-3) (defun open-path-with-explorer () (interactive) (let (path) (save-excursion (beginning-of-line) (setq path (buffer-substring (point) (progn (end-of-line) (point))))) (open-explorer path) ; (message-box path) ) ) (global-set-key '(#\C-x #\x) 'open-path-with-explorer) (global-set-key '(#\C-3) 'open-path-with-explorer)
参考
- xyzzy からエクスプローラを開く | The Yak Shaver
http://yak-shaver.blogspot.com/2011/04/xyzzy_8.html - xyzzy の音 - ファイル操作
http://hie.s64.xrea.com/xyzzy/note/file-handling.html#open-cursor-path
カーソル位置にあるパスを解釈してファイルを開いたりする