aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-11 11:31:26 +1100
committerYuchen Pei <hi@ypei.me>2022-10-11 11:31:26 +1100
commit7652f876d00152e127a93767581bfedde6be61ce (patch)
tree7753ab90a6a3e0fd3aec8e3b074b155cae4c2239
parent3c337adc87d9ba6b8cb81e04136c73040982fdfb (diff)
display tor status
-rw-r--r--luwak.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/luwak.el b/luwak.el
index ed0f6fe..744fed0 100644
--- a/luwak.el
+++ b/luwak.el
@@ -29,7 +29,14 @@
"Function to rewrite url before loading."
:group 'luwak :type '(function))
-(define-derived-mode luwak-mode special-mode "luwak"
+(defun luwak-mode-name ()
+ (concat "luwak "
+ (cond
+ ((null luwak-data) "Tor unknown")
+ ((plist-get luwak-data :no-tor) "Tor off")
+ (t "Tor on"))))
+
+(define-derived-mode luwak-mode special-mode (luwak-mode-name)
"Major mode for browsing the web using lynx -dump.")
(defvar luwak-mode-map
@@ -64,7 +71,7 @@
(message "Loading %s..." url)
(set-process-sentinel
(luwak-start-process-with-torsocks
- current-prefix-arg
+ no-tor
"luwak-lynx" (luwak-lynx-buffer url)
"lynx" "-dump" "--display_charset" "utf-8" url)
(lambda (process _)
@@ -78,8 +85,11 @@
(luwak-render-links (luwak-get-links)))
(unless (derived-mode-p 'luwak-mode) (luwak-mode))
(if luwak-data
- (plist-put luwak-data :url url)
+ (progn
+ (plist-put luwak-data :url url)
+ (plist-put luwak-data :no-tor no-tor))
(setq luwak-data (list :url url :no-tor no-tor :history-pos 0)))
+ (setq mode-name (luwak-mode-name))
(when cb (funcall cb)))
(display-buffer luwak-buffer))))