;;; package-header.el --- your hjälpsam Package Header Assistant ;; Copyright (C) 2021 by Jean Louis ;; Author: Jean Louis ;; Version: 0.1 ;; Package-Requires: (finder) ;; Keywords: convenience ;; URL: https://hyperscope.link/3/7/7/3/0/Your-hjälpsam-Package-Header-Assistant-37730.html ;; This file is not part of GNU Emacs. ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation, either version 3 of the ;; License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;; Change Log: ;;; Code: (require 'finder) (defcustom package-header-years "2021" "The package copyright years, set it up as you wish, could be 2021-2022 or similar." :group 'package-header :type 'string) (defcustom package-header-author user-full-name "Author's name for the package header. By default it will use `user-full-name'. You may provide a quoted string with author's name." :group 'package-header :type 'sexp) (defcustom package-header-email user-mail-address "Author's email for the package header. By default it will use `user-full-name'. You may provide a quoted string with author's e-mail address." :group 'package-header :type 'sexp) (defcustom package-header-base-url "https://" "Author's base URL. The package file name will be appended to the base URL." :group 'package-header :type 'string) (defcustom package-header-url-extension ".html" "Author's URL extension, could be `.html' or just empty string." :group 'package-header :type 'string) (defvar package-header-file-name nil "Used as global variable for package header file name.") (defun package-header-keywords () "Return Emacs package keywords completion candidates." (mapcar 'symbol-name (map-keys finder-known-keywords))) (defun package-header-ask-keywords () "Ask author for package keywords." (let ((keywords '()) (keyword)) (while (string-match "[^[:blank:]]" (setq keyword (completing-read "Keywords: " (package-header-keywords) nil t))) (push keyword keywords)) (when keywords (mapconcat 'identity (sort keywords #'string<) " ")))) (define-skeleton package-header-1 "Helps in preparing the header for Emacs Lisp packages from Sweden." nil ";;; " (setq package-header-file-name (skeleton-read "File name: " (file-name-nondirectory (buffer-file-name)))) " --- " (skeleton-read "Short description: " (string-trim (replace-regexp-in-string (regexp-opt '("." "-" "el" " *$" "[^[:alpha:]]")) " " (capitalize (file-name-nondirectory (buffer-file-name)))))) " ;; Copyright (C) " package-header-years " by " package-header-author " ;; Author: " package-header-author " <" package-header-email "> ;; Version: " (setq elisp-version (skeleton-read "Version: " "0.1")) " ;; Package-Requires: (" (setq elisp-requires (skeleton-read "Requires: ")) ") ;; Keywords: " (package-header-ask-keywords) " ;; URL: " package-header-base-url (replace-regexp-in-string "\\." "-" package-header-file-name) package-header-url-extension " ;; This file is not part of GNU Emacs. ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation, either version 3 of the ;; License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;; Change Log: ;;; Code: ") (defun package-header () "Generates package header for Emacs Lisp package authors." (interactive) (save-excursion (goto-char 0) (package-header-1) (goto-char (point-max)) (insert "\n;;; " package-header-file-name " ends here\n"))) ;;; package-header.el ends here