aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-20 17:59:55 +1100
committerYuchen Pei <hi@ypei.me>2022-10-20 17:59:55 +1100
commitf12c63b8a531cb62901b0fc8d326e9b615a0b655 (patch)
tree19a70de3c0ffacf56d24b4b30b0b3442cc84a7b3
parente0408b2cb6dd773a512a15c55dfe46e4babed654 (diff)
render a dump buffer
-rw-r--r--luwak.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/luwak.el b/luwak.el
index 88946f4..b2cb42d 100644
--- a/luwak.el
+++ b/luwak.el
@@ -207,9 +207,10 @@ When non-nill, swap the tor-switch in prefix-arg effect."
(defun luwak-reload ()
(interactive)
- (luwak-open-url
- (plist-get luwak-data :url)
- (plist-get luwak-data :no-tor)))
+ (let ((url (plist-get luwak-data :url)))
+ (unless url
+ (error "The current buffer is not associated with any url."))
+ (luwak-open-url url (plist-get luwak-data :no-tor))))
(defun luwak-follow-link (marker)
(let ((url (get-text-property marker 'url)))
@@ -225,6 +226,19 @@ When non-nill, swap the tor-switch in prefix-arg effect."
(funcall luwak-render-link-function i url)
(setq i (1+ i)))))))
+(defun luwak-render-buffer ()
+ "Render the current buffer in luwak mode."
+ (interactive)
+ (let ((dump (buffer-string)))
+ (with-current-buffer (get-buffer-create luwak-buffer)
+ (luwak-open-internal
+ nil
+ dump
+ (or (plist-get luwak-data :history-pos) 0)
+ (or (plist-get luwak-data :no-tor)
+ (xor luwak-tor-switch current-prefix-arg)))
+ (luwak-add-to-history))))
+
(defun luwak-render-link-forward-sexp (idx url)
"Render a link using forward-sexp."
(when (re-search-forward (format "\\[%d\\]" idx) nil t)