From eae5318f4d623309122076cad12402846a91c08c Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <michel@michel-slm.name>
Date: Sat, 15 Aug 2020 16:25:23 -0700
Subject: [PATCH] Ensure certificate directory exists

Before choosing a permanent client certificate, Elpher tries to list
existing certificates. This fails if `elpher-certificate-directory` does
not exist, e.g.

```
---- ERROR -----

When attempting to retrieve gemini://alexschroeder.ch/do/comment/2020-08-14_How_to_comment_using_Elpher:
Opening directory: No such file or directory, /home/michel/.emacs.d/elpher-certificates

----------------

Press 'u' to return to the previous page.
```

Fix by creating the directory unless it exists in
`elpher-list-existing-certificates`.

Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
---
 elpher.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/elpher.el b/elpher.el
index dae1d50..5b0f132 100644
--- a/elpher.el
+++ b/elpher.el
@@ -826,6 +826,8 @@ base for the installed key and certificate files."
 
 (defun elpher-list-existing-certificates ()
   "Return a list of the persistent certificates in `elpher-certificate-directory'."
+  (unless (file-directory-p elpher-certificate-directory)
+    (make-directory elpher-certificate-directory))
   (mapcar
    (lambda (file)
      (file-name-sans-extension file))
-- 
2.20.1