 (defun tn-set-default-weight ()
     (interactive)
     (let ((r (read-character-as-number)))
-        (set-default-weight (/ r 4))))
+        (set-default-weight (/ r 4.0))))
 
 (defun set-min-weight (s)
     (if (and (in-view) (>= s 0) (<= s 1))
-        (request-view t tn-mode tn-root tn-depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability s tn-max-weight)
+        (request-view t tn-mode tn-root-id tn-depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability s tn-max-weight)
         (error-message
             (concat "min weight " (number-to-string s) " is outside of range [0, 1]"))))
 
 (defun tn-set-min-weight ()
     (interactive)
     (let ((r (read-character-as-number)))
-        (set-min-weight (/ r 4))))
+        (set-min-weight (/ r 4.0))))
 
 
 ;; set sharability ;;;;;;;;;;;;;;;;;;;;;

(global-set-key (kbd "C-c C-d")         'tn-choose-depth)
(global-set-key (kbd "C-c C-f")         'tn-push-point)
(global-set-key (kbd "C-c C-l")         'tn-goto-line)
(global-set-key (kbd "C-c C-s C-d")     'tn-set-default-sharability)
(global-set-key (kbd "C-c C-s C-m")     'tn-set-min-sharability)
(global-set-key (kbd "C-c C-t a")       'tn-browse-target-value-as-url)
(global-set-key (kbd "C-c C-t c")       'tn-copy-target-value-to-clipboard)
(global-set-key (kbd "C-c C-t i")       'tn-target-info)
(global-set-key (kbd "C-c C-t l")       'tn-preview-target-latex-math)
(global-set-key (kbd "C-c C-t r")       'tn-copy-target-reference-to-clipboard)
(global-set-key (kbd "C-c C-t C-a b")   'tn-browse-target-alias)
(global-set-key (kbd "C-c C-t C-b a")   'tn-browse-target-value-in-amazon)
(global-set-key (kbd "C-c C-t C-b e")   'tn-browse-target-value-in-ebay)
(global-set-key (kbd "C-c C-t C-b d")   'tn-browse-target-value-in-delicious)
(global-set-key (kbd "C-c C-t C-b g")   'tn-browse-target-value-in-google)
(global-set-key (kbd "C-c C-t C-b m")   'tn-browse-target-value-in-google-maps)
(global-set-key (kbd "C-c C-t C-b s")   'tn-browse-target-value-in-google-scholar)
(global-set-key (kbd "C-c C-t C-b t")   'tn-browse-target-value-in-twitter)
(global-set-key (kbd "C-c C-t C-b w")   'tn-browse-target-value-in-wikipedia)
(global-set-key (kbd "C-c C-t C-b y")   'tn-browse-target-value-in-youtube)
(global-set-key (kbd "C-c C-t C-p")     'tn-set-target-priority)
(global-set-key (kbd "C-c C-t C-s")     'tn-set-target-sharability)
(global-set-key (kbd "C-c C-t C-w")     'tn-set-target-weight)
(global-set-key (kbd "C-c C-v b")       'tn-refresh-to-backward-view)
(global-set-key (kbd "C-c C-v e")       'tn-enter-edit-view)
(global-set-key (kbd "C-c C-v f")       'tn-refresh-to-forward-view)

(defun tn-refresh-view ()
    (interactive)
    (if (in-view)
        (request-view t tn-mode tn-root-id tn-depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))

(defun tn-enter-edit-view ()
    (interactive)
    (if (and (in-view) (equal tn-mode tn-readonly-mode))
        (request-view t tn-edit-mode tn-root-id tn-depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))

(defun tn-enter-readonly-view ()
    (interactive)
    (if (and (in-view) (equal tn-mode tn-edit-mode))
        (request-view t tn-readonly-mode tn-root-id tn-depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))

(defun tn-choose-depth ()
    (interactive)
    (let ((depth (read-character-as-number)))
            (if (< depth 1) (error-message (concat "depth of " (number-to-string depth) " is too low (must be >= 1)"))
                (if (> depth 5) (error-message (concat "depth of " (number-to-string depth) " is too high (must be <= 5)"))
                    (request-view nil tn-mode tn-root-id depth tn-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))))

(defun tn-refresh-to-forward-view ()
    (interactive)
    (if (in-view)
        (request-view nil tn-mode tn-root-id tn-depth tn-forward-view-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))

(defun tn-refresh-to-backward-view ()
    (interactive)
    (if (in-view)
        (request-view nil tn-mode tn-root-id tn-depth tn-backward-view-style tn-min-sharability tn-max-sharability tn-default-sharability tn-min-weight tn-max-weight)))


;; set weight ;;;;;;;;;;;;;;;;;;;;;;;;;;
