Allow elpher-go to work without an Elpher ebuffer
authorAlex Schroeder <alex@gnu.org>
Tue, 6 Jul 2021 17:31:32 +0000 (19:31 +0200)
committerAlex Schroeder <alex@gnu.org>
Tue, 6 Jul 2021 17:31:32 +0000 (19:31 +0200)
If elpher-go is the first thing you do, and no *elpher* buffer exists,
you run into an error. Wrapping elpher-visit-page in
elpher-with-clean-buffer fixes this, as this sets up the *elpher*
buffer, and sets elpher-mode.

Alternatively, we could also just set elpher-mode. The key is that we
must do it before elpher-visit-page is called, otherwise this is what
happens: elpher-go → elpher-visit-page → elpher-render-gemini via
elpher-type-map → elpher-render-gemini-map → elpher-with-clean-buffer
which now calls elpher-mode, wiping all the local variables. If,
however, we make sure elpher-mode is active before all of this,
elpher-with-clean-buffer when called from elpher-render-gemini-map
will not call elpher-mode and the local variables remain set.

elpher.el

index 87729f5..50637b0 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -1935,7 +1935,8 @@ When run interactively HOST-OR-URL is read from the minibuffer."
          (address (elpher-address-from-url cleaned-host-or-url))
          (page (elpher-make-page cleaned-host-or-url address)))
     (switch-to-buffer elpher-buffer-name)
-    (elpher-visit-page page)
+    (elpher-with-clean-buffer
+     (elpher-visit-page page))
     nil))
 
 (defun elpher-go-current ()