directoryへジャンプ(その3)
前に書いたものを多少修正
■具体的な変更点
多少コードがスマートになった。(match-string 0)を使った方がスマートだったのでそういう感じにしておいた。
;directoryへジャンプ(したい) ;分かり良さそうに変えておいた。v0.04 (defun goto-directory() (interactive) (let (tmp dir) (save-excursion ;パスらしきものか行頭が出てくるまで後ろに移動して (while (not (looking-at "[CcDd]:[/\\]\\|^.")) (backward-char)) ;パスらしき所を取り出す。 (setq dir (match-string 0)) (goto-char (match-end 0)) ; ex C:/の後ろに移動。 (if (file-exist-p dir);一応取り出したのが存在するか確認して (while (looking-at "[^\t:\*\?\"<>|\\/]*[/\\]") ;サブディレクトリらしき所をtmpへ入れる (setq tmp (match-string 0)) (setq tmp (concat dir tmp)) ; subdirectoryらしきものとくっ付ける (if (and (sub-directory-p tmp dir) (file-exist-p tmp)) ; tmpがまともなディレクトリかcheck (setq dir tmp) ; よさそうならばdirに入れてしまう。 (return)) ; ディレクトリじゃないなら抜ける。 (goto-char (match-end 0)))) ; 次のdirectoryの記述に移動 (cond ((file-exist-p dir) (open-filer) ; ファイラを開く (filer-chdir dir)) (t (plain-error "ない" ))) ))) ; 画面を移動。