aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@bordeaux-inp.fr>2024-03-13 07:57:48 +0100
committerTristan Riehs <tristan.riehs@bordeaux-inp.fr>2024-03-13 07:57:48 +0100
commitac46ac4fc21928238e63dfd3fa9794df86e3b3f5 (patch)
treeadc2245c04ad182d1ebf1ad21d9744c507567d9c
parent2be95a05370d016f87d34bdccc9556a9547338eb (diff)
Add an error handling in create-license
Handle the case where there is no available license.
-rw-r--r--create-license.el21
1 files 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")