 ;;; Code:
 
 (require 'cl-lib)
+
+(autoload 'rvm-use-default "rvm" nil t)
 
 (defvar github-markdown-servers '() "The servers we have running.")
 (defvar github-markdown-server-port 7494 "The next available server port.")

    (with-temp-buffer
      (insert-file-contents file-name)
      (goto-char (point-min))
      (if (= (search-forward-regexp "^---" 6 't) 4)
        (progn
          (goto-char (+ (point-min) 3))
          (if (search-forward-regexp "^---" (point-max) 't)
            (let ((bound (point)))
              (goto-char (point-min))
              (if (search-forward-regexp "^permalink: \\(.*\\)$" bound 't)
                (setq path-name (match-string 1)))))))))
  path-name)

(defun jekyll-fix-path-name (file-name path-name)
  "Work out the pathname that FILE-NAME will be served at (PATH-NAME is our best guess right now)."
  (setq path-name (replace-regexp-in-string "\\.md$" ".html" path-name))
  (jekyll-get-permalink-from-file file-name
    (cond
      ((string-match "^/_posts/\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)-[0-9][0-9]-\\(.*\\)" path-name)


(defun github-markdown-server-start (directory port file-name)
  "Start a github-markdown-server for DIRECTORY on PORT and open FILE-NAME."
  (rvm-use-default)
  (setenv "LANG" "en_US.UTF-8")
  (let ((cmd (concat
               "github-markdown-server"
               " --directory=" (shell-quote-argument directory)
