From 49f273459b699a3d69135b816128131ed7926c52 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sat, 27 Mar 2021 22:52:08 +0100 Subject: [PATCH] Load saved pages in elpher-buffer-name The old solution didn't really work all that well: you look at a page, then you load the raw copy, you edit it, it finds the buffer containing the raw copy (great!), reloads, it gets redirected to the original page (great!). Then you return to the edit buffer, make a change and save: now it doesn't find the buffer containing the raw copy (since the Elpher buffer is showing the original page after the redirect!) and so a new Elpher buffer gets created, which is then redirected to the original page (now you have two of them). And if you make another edit, you have three, and so on, forever. This is lame. --- gemini-write.el | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/gemini-write.el b/gemini-write.el index 324ed50..9739483 100644 --- a/gemini-write.el +++ b/gemini-write.el @@ -115,19 +115,6 @@ used when writing Gemini pages." :type 'boolean :group 'gemini-mode) -(defun get-elpher-buffer-showing (page) - "Return the first Elpher buffer showing PAGE." - (catch 'buf - (let ((address (elpher-page-address page))) - (dolist (buf (buffer-list)) - (with-current-buffer buf - (when (and (eq major-mode 'elpher-mode) - (or (equal (elpher-page-address elpher-current-page) - address) - (equal (elpher-page-address (car elpher-history)) - address))) - (throw 'buf buf))))))) - (defun gemini-write-get-token (host &optional port) "Get a token from `elpher-gemini-tokens', or `auth-sources' if `gemini-write-use-auth-source' is enabled." (if-let (token (cdr (assoc host elpher-gemini-tokens))) @@ -153,11 +140,7 @@ going to use. Otherwise, a new buffer is used." ;; doesn't change our address, too (let* ((page (copy-sequence elpher-current-page)) (address (elpher-page-address page)) - (buf (or (get-elpher-buffer-showing page) - (with-current-buffer - (generate-new-buffer (default-value 'elpher-buffer-name)) - (elpher-mode) - (current-buffer)))) + (buf (get-buffer-create elpher-buffer-name)) (token (gemini-write-get-token (url-host address))) (data (encode-coding-string (buffer-string) 'utf-8 t))) (switch-to-buffer buf)