Hi, I was wanting to leverage elpher-visit-page to automate downloading some gemini files and various other nefarious purposes. I was hoping I could, in an elisp program, do something like this:
```
(elpher-visit-page
"gemini://gem.librehacker.com"
(lambda (data mime)
(let ((coding-system-for-write 'binary))
(with-temp-file "~/Downloads/somefile.gmi"
(insert data)))))
```
But I get error "(wrong-type-argument url 101)".
Evidently, I need to convert my address string to another data structure. Could somebody show me what I need to do, exactly?
--
馃摏 Christopher Howard
馃殌 gemini://gem.librehacker.com
馃寪 http://gem.librehacker.com
讘专讗砖讬转 讘专讗 讗诇讛讬诐 讗转 讛砖诪讬诐 讜讗转 讛讗专抓
hello Christopher,
This function below has been serving me well. I guess it might work
for gemini too, with some changes.
You'll see how you give it an address and it saves the results into a
buffer.
Let me know how it goes?
Jone
(defun jw-get-gopher (url)
(save-excursion
(elpher-process-cleanup)
(get-buffer-create "*elpher*")
(let* ((cleaned-url (string-trim url))
(address (elpher-address-from-url cleaned-url)))
(setq jw-gopher-ready nil)
(with-current-buffer (get-buffer-create "*jw-get-gopher*")
(erase-buffer))
(elpher-get-host-response address 70
(concat
(elpher-gopher-address-selector address)
"\r\n")
(lambda (s)
(with-current-buffer
(get-buffer-create "*jw-get-gopher*")
(erase-buffer)
(insert s)
(replace-string (char-to-string 13) ""
nil (point-max) (point-min))
(setq jw-gopher-ready t))))
(let ((how-long 0)
(too-long 10))
(while (and (not jw-gopher-ready) (< how-long too-long))
(sit-for 0.25)
(setq how-long (+ how-long 0.25))))
(get-buffer-create "*jw-get-gopher*"))))
joneworlds@mailbox.org writes:
> This function below has been serving me well. I guess it might work> for gemini too, with some changes.>> You'll see how you give it an address and it saves the results into a> buffer.>> Let me know how it goes?
Thank you. I have been busy with another project, but am looking at this now. It seems like this could work, but I need to expanded the response processor to deal with Gemini's various response codes. I didn't have enough time during today's lunch break to launch into that.
I am still curious to know if a little tweak could make my simpler, higher-level code work. I saw the function elpher-address-from-url in your coded, so I added it to mine:
```
(defun my-elpher-download-test ()
(elpher-visit-page
(elpher-address-from-url "gemini://gem.librehacker.com")
(lambda (data mime)
(let ((coding-system-for-write 'binary))
(with-temp-file "~/Downloads/somefile.gmi"
(insert data))))))
```
But this fails with
```
(wrong-type-argument sequencep #s(url :type "gemini" :user nil :password nil :host "gem.librehacker.com" :portspec nil :filename "/" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous t))
```
I see in the backtrace that elpher-visit-page passes my address to "elpher-page-address", but elpher-page-address seems to want a sequence, not the hash returned by elpher-address-from-url. docstrings says elpher-page-address wants a "PAGE" but I'm not sure what data structure that is or how to construct it.
--
Christopher Howard