From: plugd Date: Tue, 9 Aug 2022 00:38:42 +0000 (+1000) Subject: Fixed issue to do with current buffer changing during download. X-Git-Tag: v3.4.3~6 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=78ea2a7bcbe79ab4a775d245f97c2f24e15ac9e0;p=elpher.git Fixed issue to do with current buffer changing during download. Thanks to Troels Henriksen for reporting this issue. --- diff --git a/ISSUES.org b/ISSUES.org index 1cf6229..60c6a99 100644 --- a/ISSUES.org +++ b/ISSUES.org @@ -23,13 +23,16 @@ timer fire up early means that it interferes with requests for user interaction that may appear during the initial connection setup. E.g., asking for approval of uknown TLS certificates. -** OPEN Downloads failing +* Closed Bugs + +** CLOSED Downloads failing +:LOGBOOK: +- State "CLOSED" from "OPEN" [2022-08-09 Tue 10:38] +:END: Downloads fail when focus is shifted away from the elpher buffer before the download has completed. -* Closed Bugs - ** CLOSED Relative Gemini links processed improperly :LOGBOOK: - State "CLOSED" from "OPEN" [2021-08-04 Wed 15:54] diff --git a/elpher.el b/elpher.el index 2a30f99..882ed2a 100644 --- a/elpher.el +++ b/elpher.el @@ -570,7 +570,7 @@ This variable is used by `elpher-show-visited-pages'.") (defun elpher-visit-page (page &optional renderer no-history) "Visit PAGE using its own renderer or RENDERER, if non-nil. Additionally, push PAGE onto the history stack and the list of -previously-visited pages,unless NO-HISTORY is non-nil." +previously-visited pages, unless NO-HISTORY is non-nil." (elpher-save-pos) (elpher-process-cleanup) (unless no-history @@ -869,7 +869,8 @@ the host operating system and the local network capabilities.)" nil force-ipv4)) (t (elpher-network-error address "Connection time-out.")))))) - (proc (if socks (socks-open-network-stream "elpher-process" nil host service) + (proc (if socks + (socks-open-network-stream "elpher-process" nil host service) (make-network-process :name "elpher-process" :host host :family (and (or force-ipv4 @@ -883,6 +884,7 @@ the host operating system and the local network capabilities.)" (cons 'gnutls-x509pki (apply #'gnutls-boot-parameters gnutls-params))))))) + (process-put proc 'elpher-buffer (current-buffer)) (setq elpher-network-timer timer) (set-process-coding-system proc 'binary 'binary) (set-process-query-on-exit-flag proc nil) @@ -926,17 +928,19 @@ the host operating system and the local network capabilities.)" response-processor use-tls t)) (response-string-parts - (elpher-with-clean-buffer - (insert "Data received. Rendering...")) - (funcall response-processor - (apply #'concat (reverse response-string-parts))) - (elpher-restore-pos)) + (with-current-buffer (process-get proc 'elpher-buffer) + (elpher-with-clean-buffer + (insert "Data received. Rendering...")) + (funcall response-processor + (apply #'concat (reverse response-string-parts))) + (elpher-restore-pos))) (t (error "No response from server"))) (error (elpher-network-error address the-error))))) (when socks - (if use-tls (apply #'gnutls-negotiate :process proc gnutls-params)) + (if use-tls + (apply #'gnutls-negotiate :process proc gnutls-params)) (funcall (process-sentinel proc) proc "open\n"))) (error (elpher-process-cleanup)