                     (condition-case emdocs-client-list
                         (cons (emdocs-connect-client buffer ip) nil)
                       (file-error 'no-conn))))
-            (when (eq emdocs-client-list 'no-conn)
-              (message "Client could not connect: exiting.")
-              (setq emdocs-mode nil)
-              (emdocs-disconnect))))
+            (if (eq emdocs-client-list 'no-conn)
+                (progn (message "Client could not connect: exiting.")
+                       (setq emdocs-mode nil)
+                       (emdocs-disconnect))
+              (insert "DO AFTER-CHANGE FUNCTIONS"))))
       (message "Not connected to internet: exiting.")
       (setq emdocs-mode nil)
       (emdocs-disconnect))))

;; -*- lexical-binding: t; -*-

(eval-when-compile
  (require 'cl))

;;; globals

(defconst +emdocs-http-port+ 8080
  "docstring")

;;; classes

;;; functions

(defun emdocs-get-internal-ip-address (&optional device-name)
  "Returns ip address of active interface, ignoring loopback. Returns nil if
none active."
  (if device-name
      (format-network-address (car (network-interface-info device-name)) t)
    (let ((network-interfaces (network-interface-list)))

  "docstring"
  (make-local-variable 'emdocs-ip-addr)
  (setq emdocs-ip-addr (read-from-minibuffer "ip: "))
  ;; check for private ips
  (if (or (string-match "^192\\.168\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
          (string-match "^10\\.[0-9]+\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
          (string-match "^172\\.1[6789]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
          (string-match "^172\\.2[0-9]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
          (string-match "^172\\.3[01]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
          (string-equal "" emdocs-ip-addr)
          (string-equal "localhost" emdocs-ip-addr))
      (emdocs-attach-sockets-to-buffer (current-buffer) emdocs-ip-addr)
    (message
"Invalid ip address. Keep in mind emdocs only works for private ip addresses.")
    (setq emdocs-mode nil)))

(defun emdocs-disconnect ()
  "docstring"
  (loop for client in emdocs-client-list
        do (when (and client
                      (not (eq client 'no-conn)))
             (delete-process client)))
  (makunbound 'emdocs-client-list))

(defun emdocs-kill-server ()
  "docstring"
  (interactive)
  (if (and *emdocs-server*
           (not (eq (process-status *emdocs-server*) 'closed)))
      (delete-process *emdocs-server*))
  (setq *emdocs-server* nil))

;;; define mode

