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.
This commit is contained in:
Alex Schroeder 2021-03-27 22:52:08 +01:00
parent fd76095f83
commit 49f273459b
1 changed files with 1 additions and 18 deletions

View File

@ -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)