maeshimaの日記

メモ書きです

rinariコードリーディング rinari-root

143-151行。default-directory(カレントディレクトリ?)から始めてconfig/environment.rbが見つかるまでディレクトリを上に上がって調べてる。

(defun rinari-root (&optional dir home)
  (or dir (setq dir default-directory))
  (if (file-exists-p (expand-file-name
		      "environment.rb" (expand-file-name "config" dir)))
      dir
    (let ((new-dir (expand-file-name (file-name-as-directory "..") dir)))
      ;; regexp to match windows roots, tramp roots, or regular posix roots
      (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir)
	(rinari-root new-dir)))))