Created
October 26, 2009 14:13
-
-
Save sshirokov/218680 to your computer and use it in GitHub Desktop.
Interim showoff of erlang-yaws.el (Which may be useless)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(require 'erlang-start) | |
;; Run a emacs repl with yaws loaded and configured | |
(defvar yaws-path "~/Applications/YAWS") | |
(defvar yaws-listening-regex "Yaws: Listening") | |
(defvar yaws-extra-paths ()) | |
(defvar yaws-extra-flags ()) | |
(defadvice inferior-erlang-wait-prompt (before send-ret-before-waiting last () activate) | |
(or (with-current-buffer inferior-erlang-buffer (save-excursion | |
(goto-char (process-mark inferior-erlang-process)) | |
(forward-line 0) | |
(looking-at comint-prompt-regexp))) | |
(comint-send-string inferior-erlang-process "\n"))) | |
(defun* erlang-yaws-wait-for-listen (&key (timeout 2) (buffer (current-buffer))) | |
(ignore-errors | |
(while (not (string-match-p yaws-listening-regex (buffer-string))) | |
(or (accept-process-output (get-buffer-process buffer) timeout) | |
(error "Yaws didn't seems to listen before timeout (%s) in %s" timeout buffer))) | |
(comint-send-string (get-buffer-process buffer) "\n") t)) | |
(defun erlang-yaws-do-wait-for-listen () | |
(message "Waiting for yaws to listen...") | |
(if (erlang-yaws-wait-for-listen) | |
(progn (message "Erlang+YAWS Ready") | |
t) | |
(message "Erlang+YAWS load FAILED") | |
nil)) | |
(defun erlang-yaws-get-extra-paths () | |
()) | |
(defun erlang-yaws-get-extra-flags () | |
()) | |
(defun run-erlang-yaws () | |
(interactive) | |
(let ((inferior-erlang-machine-options `("-pa" ,(expand-file-name (concat yaws-path "/lib/yaws/ebin")) | |
,@(or (erlang-yaws-get-extra-paths) '("")) | |
,@(or (erlang-yaws-get-extra-flags) '("")) | |
"-yaws" "debug" | |
"-run" "yaws" | |
"-yaws" "id" "default")) | |
(erlang-shell-mode-hook ())) | |
(add-hook 'erlang-shell-mode-hook 'erlang-yaws-do-wait-for-listen) | |
(run-erlang))) | |
(message "Eval'd") | |
(provide 'erlang-yaws) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment