Skip to content

Instantly share code, notes, and snippets.

@miyamuko
Created August 12, 2010 02:59
Show Gist options
  • Select an option

  • Save miyamuko/520222 to your computer and use it in GitHub Desktop.

Select an option

Save miyamuko/520222 to your computer and use it in GitHub Desktop.
find-file で環境変数込みのパスを開けるようにする #xyzzy
;; find-file で環境変数込みのパスを開けるようにする
;; (find-file "%SystemRoot%/system32/drivers/etc/hosts")
(defun find-file-expand-env-hook (filename)
(when (and filename
(not (file-exist-p filename)))
(let ((replaced nil))
(while (string-matchp "%\\([a-z]+\\)%" filename)
(setf filename (substitute-string filename (match-string 0)
(map-backslash-to-slash (si:getenv (match-string 1))))
replaced t))
(when replaced
(ed::find-file-internal filename)))))
(add-hook '*before-find-file-hook* 'find-file-expand-env-hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment