     
 (defun refresh-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
-
-(defun refresh-view-new (url)
-    (url-retrieve url 'receive-view))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
+
+(defun refresh-view-new (url mode)
+    (url-retrieve url (receive-view mode)))
+
+(defun to-edit-view ()
+    (interactive)
+    (if (and (in-view) (equal tn-view-mode readonly-view-mode))
+        (request-view readwrite-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
+
+(defun to-readonly-view ()
+    (interactive)
+    (if (and (in-view) (equal tn-view-mode readwrite-view-mode))
+        (request-view readonly-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun decrease-depth ()
     (interactive)
-    (if view-root
-        (request-view view-root (- view-depth 1) view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root (- view-depth 1) view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun increase-depth ()
     (interactive)
-    (if view-root
-        (request-view view-root (+ view-depth 1) view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root (+ view-depth 1) view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun refresh-to-forward-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth (to-forward-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth (to-forward-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun refresh-to-backward-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth (to-backward-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth (to-backward-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun refresh-to-hybrid-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth (to-hybrid-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth (to-hybrid-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun refresh-to-links-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth (to-links-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth (to-links-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun refresh-to-targets-view ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth (to-targets-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth (to-targets-style view-style) view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun decrease-default-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight (- view-default-weight 0.25))
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight (- view-default-weight 0.25))))
 
 (defun increase-default-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight (+ view-default-weight 0.25))
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight view-max-weight (+ view-default-weight 0.25))))
 
 (defun decrease-min-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability (- view-min-weight 0.25) view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability (- view-min-weight 0.25) view-max-weight view-default-weight)))
 
 (defun increase-min-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability (+ view-min-weight 0.25) view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability (+ view-min-weight 0.25) view-max-weight view-default-weight)))
 
 (defun decrease-max-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight (- view-max-weight 0.25) view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight (- view-max-weight 0.25) view-default-weight)))
 
 (defun increase-max-weight ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight (+ view-max-weight 0.25) view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability view-default-sharability view-min-weight (+ view-max-weight 0.25) view-default-weight)))
 
 (defun decrease-default-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability (- view-default-sharability 0.25) view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability (- view-default-sharability 0.25) view-min-weight view-max-weight view-default-weight)))
 
 (defun increase-default-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability view-max-sharability (+ view-default-sharability 0.25) view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability view-max-sharability (+ view-default-sharability 0.25) view-min-weight view-max-weight view-default-weight)))
 
 (defun decrease-min-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style (- view-min-sharability 0.25) view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style (- view-min-sharability 0.25) view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun increase-min-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style (+ view-min-sharability 0.25) view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style (+ view-min-sharability 0.25) view-max-sharability view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun decrease-max-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability (- view-max-sharability 0.25) view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability (- view-max-sharability 0.25) view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 (defun increase-max-sharability ()
     (interactive)
-    (if view-root
-        (request-view view-root view-depth view-style view-min-sharability (+ view-max-sharability 0.25) view-default-sharability view-min-weight view-max-weight view-default-weight)
-        (not-in-view)))
+    (if (in-view)
+        (request-view tn-view-mode view-root view-depth view-style view-min-sharability (+ view-max-sharability 0.25) view-default-sharability view-min-weight view-max-weight view-default-weight)))
 
 
 ;; UPDATES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun push-view ()
     (interactive)
+    (if (in-edit-view)
     (let (
         (entity (buffer-string)))
         ;; The received view may very well differ from the pushed view in terms of line numbering,


;; BUFFERS / VARIABLES ;;;;;;;;;;;;;;;;;

;; Buffer-local variables. Given them initial, global bindings so they're defined before there are actual view buffers.
(setq view-depth 3)
(setq view-root nil)

                        (if error
                            (error-message error)
                            (error-message msg)))
		         (refresh-view-new hack-url tn-view-mode))))))))

(defun decrease-link-weight ()
    (interactive)
