                         (if error
                             (error-message error)
                             (error-message msg)))
-		         (refresh-view-new hack-url tn-view-mode))))))))
-
-(defun decrease-link-weight ()
+		         (refresh-view-new hack-url tn-mode))))))))
+
+(defun tn-decrease-link-weight ()
     (interactive)
     (let ((link (current-link)))
         (if link


(defun receive-view-internal (status mode)
    (let ((json (json-read-from-string (strip-http-headers (buffer-string))))
          (editable (equal mode readwrite-view-mode)))
        (if status
            (let ((msg (cdr (assoc 'message json)))
                (error (cdr (assoc 'error json))))

                (browse-url (funcall value-to-url value)))
            (no-target))))

(defun tn-browse-target-value-as-url ()
    (interactive)
    (browse-target-value (lambda (value)
        value)))

(defun tn-browse-target-value-in-amazon ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://www.amazon.com/s?ie=UTF8&index=blended&link_code=qs&field-keywords=" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-ebay ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://www.ebay.com/sch/i.html?_nkw=" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-delicious ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://www.delicious.com/search?p=" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-google ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://www.google.com/search?ie=UTF-8&q=" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-google-scholar ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://scholar.google.com/scholar?q=" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-twitter ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://twitter.com/#!/search/" (w3m-url-encode-string value)))))

(defun tn-browse-target-value-in-wikipedia ()
    (interactive)
    (browse-target-value (lambda (value)
        (concat "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" (w3m-url-encode-string value)))))


(global-set-key (kbd "C-c a")           'tn-visit-url-at-point)
(global-set-key (kbd "C-c d")           'tn-debug)
(global-set-key (kbd "C-c e")           'tn-export)
(global-set-key (kbd "C-c l")           'tn-visit-link)
(global-set-key (kbd "C-c p")           'tn-push-view)
(global-set-key (kbd "C-c q")           'tn-search)
(global-set-key (kbd "C-c r")           'tn-refresh-view)
(global-set-key (kbd "C-c t")           'tn-visit-target)
(global-set-key (kbd "C-c C-d ,")       'tn-decrease-depth)
(global-set-key (kbd "C-c C-d .")       'tn-increase-depth)
(global-set-key (kbd "C-c C-l i")       'tn-link-info)
(global-set-key (kbd "C-c C-l C-s ,")   'tn-decrease-link-sharability)
(global-set-key (kbd "C-c C-l C-s .")   'tn-increase-link-sharability)
(global-set-key (kbd "C-c C-l C-w ,")   'tn-decrease-link-weight)
(global-set-key (kbd "C-c C-l C-w .")   'tn-increase-link-weight)
(global-set-key (kbd "C-c C-s ,")       'tn-decrease-default-sharability)
(global-set-key (kbd "C-c C-s .")       'tn-increase-default-sharability)
(global-set-key (kbd "C-c C-s C-[ ,")   'tn-decrease-min-sharability)
(global-set-key (kbd "C-c C-s C-[ .")   'tn-increase-min-sharability)
(global-set-key (kbd "C-c C-s C-] ,")   'tn-decrease-max-sharability)
(global-set-key (kbd "C-c C-s C-] .")   'tn-increase-max-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-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 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 i")       'tn-target-info)
(global-set-key (kbd "C-c C-t C-s ,")   'tn-decrease-target-sharability)
(global-set-key (kbd "C-c C-t C-s .")   'tn-increase-target-sharability)
(global-set-key (kbd "C-c C-t C-w ,")   'tn-decrease-target-weight)
(global-set-key (kbd "C-c C-t C-w .")   'tn-increase-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)
(global-set-key (kbd "C-c C-v h")       'tn-refresh-to-hybrid-view)
(global-set-key (kbd "C-c C-v l")       'tn-refresh-to-links-view)
(global-set-key (kbd "C-c C-v r")       'tn-enter-readonly-view)
(global-set-key (kbd "C-c C-v t")       'tn-refresh-to-targets-view)
(global-set-key (kbd "C-c C-w ,")       'tn-decrease-default-weight)
(global-set-key (kbd "C-c C-w .")       'tn-increase-default-weight)
(global-set-key (kbd "C-c C-w C-[ ,")   'tn-decrease-min-weight)
(global-set-key (kbd "C-c C-w C-[ .")   'tn-increase-min-weight)
(global-set-key (kbd "C-c C-w C-] ,")   'tn-decrease-max-weight)
(global-set-key (kbd "C-c C-w C-] .")   'tn-increase-max-weight)


;; Note: these should perhaps be local settings
