From ac46ac4fc21928238e63dfd3fa9794df86e3b3f5 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Wed, 13 Mar 2024 07:57:48 +0100 Subject: Add an error handling in create-license Handle the case where there is no available license. --- create-license.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/create-license.el b/create-license.el index 92a6f5f..4ee7618 100644 --- a/create-license.el +++ b/create-license.el @@ -54,13 +54,20 @@ dot." The destination file name under DIR is given by `create-license-file-name'." - (interactive (list - default-directory - (completing-read - "License: " - (directory-files create-license-directory nil "^[^\\.].*")))) - (copy-file (expand-file-name name create-license-directory) - (expand-file-name create-license-file-name dir))) + (interactive + (list + default-directory + (let ((files (directory-files create-license-directory nil "^[^\\.].*"))) + (if files + (completing-read "License: " files nil 'require-match) + nil)))) + + (if name + (copy-file (expand-file-name name create-license-directory) + (expand-file-name create-license-file-name dir)) + (message "No license found in \"%s\", you may want to run \ +`create-license-download-common'" + create-license-directory))) (defcustom create-license-common '(("GPL3" . "https://www.gnu.org/licenses/gpl-3.0.txt") -- cgit v1.2.3