From f2860c3b2d20fdc456b0bf554ab846e34c4458da Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=89tienne=20Deparis?= Date: Tue, 24 Nov 2020 08:49:20 +0100 Subject: [PATCH] Avoid a crash when saving a new bookmark and elpher-bookarks-file dir is missing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As the ‘elpher-bookmarks-file’ is customizable, one can set it to a non-existent dir (like ‘~/.emacs.d/etc/elpher/bookrmarks’). This commit just check that the directory part of ‘elpher-bookrmarks-file’ exists before trying to save it. --- elpher.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elpher.el b/elpher.el index 4c34f52..9ac3fc0 100644 --- a/elpher.el +++ b/elpher.el @@ -1618,6 +1618,9 @@ bookmark list, while URL is the url of the entry." (defun elpher-save-bookmarks (bookmarks) "Record the bookmark list BOOKMARKS to the user's bookmark file. Beware that this completely replaces the existing contents of the file." + (let ((bookmark-dir (file-name-directory elpher-bookmarks-file))) + (unless (file-directory-p bookmark-dir) + (make-directory bookmark-dir))) (with-temp-file elpher-bookmarks-file (erase-buffer) (insert "; Elpher bookmarks file\n\n" -- 2.20.1