         (show-http-response-status status json)
       (info-message success-message))))
 
-(defun brain-switch-to-buffer (name context)
+(defun switch-to-buffer (name context)
   "activate Brain-mode in all new view buffers created by Brain-mode"
   (switch-to-buffer name)
+  (setq buffer-read-only nil)
   (brain-mode)
   (set-context context))
 

(defun receive-view-internal (status context)
  (let ((json (json-read-from-string (strip-http-headers (buffer-string))))
      (editable (is-readwrite-context context)))
  (debug-message (concat "mode provided: " (get-mode context)))
  (debug-message (concat "editable: " (if editable "T" "F")))
  (debug-message (concat "context before: " (json-encode context)))
  (debug-message (concat "global context before: " (json-encode brain-bufferlocal-context)))
    (if status
      (show-http-response-status status json)
  (debug-message (concat "mode before: " (get-mode)))
      (let (
        (view (get-value 'view json))
        (root-id (get-value 'root json))
        (height (numeric-value json 'height nil)))
          (brain-switch-to-buffer (name-for-view-buffer root-id json) context)
          (receive-context json context)
  (debug-message (concat "context after: " (json-encode context)))
  (debug-message (concat "global context after: " (json-encode brain-bufferlocal-context)))
  (debug-message (concat "root: " root-id))
  (debug-message (concat "json: " (json-encode json)))
          (if (equal (get-mode) brain-const-search-mode)
              ;; Always leave a search view with height 1, rather than that of the last view.
              ;; The user experience is a little unpredictable otherwise.
              (setq brain-current-height 1)
              (if height (setq brain-current-height height)))
          (erase-buffer)
  (debug-message "got the view...")
   (debug-message (concat "mode after: " (get-mode)))
         (write-view editable (get-value 'children view) 0)
          (beginning-of-buffer)
          (setq visible-cursor t)
          ;; Try to move to the corresponding line in the previous view.

    (define-key brain-mode-map (kbd "C-c C-v t")       'brain-set-value-truncation-length-prompt)
    (define-key brain-mode-map (kbd "C-c C-v v")       'brain-toggle-minimize-verbatim-blocks)
    (define-key brain-mode-map (kbd "C-c C-w C-m")     'brain-set-min-weight-prompt)
    (define-key brain-mode-map (kbd "C-c C-w r")       'brain-ripple-query-prompt)
      ;; likely not the greatest shortcut -- w just stands for weird

    (define-key brain-mode-map (kbd "C-c C-w e")       'brain-export-edges-prompt)
    (define-key brain-mode-map (kbd "C-c C-w g")       'brain-export-graphml-prompt)
