(Emacs)~license.el separates pure string functions from interactive

This commit is contained in:
2023-10-06 01:19:10 +01:00
parent 300e8cbabd
commit b1ba11dc64

View File

@@ -412,26 +412,35 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>"))) For more information, please refer to <https://unlicense.org>")))
(defun +license/insert-complete-license () (defun +license/choose-copy-of-license ()
(interactive) (interactive)
(let ((choice (completing-read "Choose license: " (mapcar #'car +license/licenses-alist) (let ((choice (completing-read "Choose license: " (mapcar #'car +license/licenses-alist)
nil t))) nil t)))
(insert (car (alist-get choice +license/licenses-alist "" nil #'string=))))) (car (alist-get choice +license/licenses-alist "" nil #'string=))))
(defun +license/insert-copyright-notice () (defun +license/copyright-notice ()
(interactive)
(let ((license-name (or (if (listp +license/license-choice) (let ((license-name (or (if (listp +license/license-choice)
(car +license/license-choice) (car +license/license-choice)
+license/license-choice) +license/license-choice)
"Unlicense"))) "Unlicense")))
(insert (format "Copyright (C) %s %s (format "Copyright (C) %s %s
You may distribute and modify this code under the terms of the %s license.
You should have received a copy of the %s license with this file. If not, please write to: %s." You may distribute and modify this code under the terms of the %s
(format-time-string "%Y") license. You should have received a copy of the %s license with
user-full-name this file. If not, please write to: %s."
license-name (format-time-string "%Y")
license-name user-full-name
user-mail-address)))) license-name
license-name
user-mail-address)))
(defun +license/insert-complete-license ()
(interactive)
(insert (+license/choose-copy-of-license)))
(defun +license/insert-copyright-notice ()
(interactive)
(insert (+license/copyright-notice)))
(provide 'license) (provide 'license)
;;; license.el ends here ;;; license.el ends here