From: Tim Landscheidt <tim@tim-landscheidt.de>
To: emacs-devel@gnu.org
Subject: [PATCH] Query for more header comments in Emacs Lisp header skeleton
Date: Tue, 12 Mar 2024 10:48:54 +0000 [thread overview]
Message-ID: <871q8fohd5.fsf@vagabond.tim-landscheidt.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 488 bytes --]
Hi,
this patch amends the Emacs Lisp header skeleton in
auto-start-alist to also query for "Version:", "URL:" and
"Package-Requires:" header comments.
package-lint (https://github.com/purcell/package-lint/)
warns about using lexical-binding and not requiring Emacs >=
24.1, but as that version was released almost twelve years
ago, I did not include this requirement by default.
The indentation of lisp/autoinsert.el is all over the place,
so I tried to fit in the neighbourhood.
Tim
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Query-for-more-header-comments.patch --]
[-- Type: text/x-patch, Size: 4036 bytes --]
From 4a85882a9a33ab1c80d760e3958b92ced1a6cffc Mon Sep 17 00:00:00 2001
From: Tim Landscheidt <tim@tim-landscheidt.de>
Date: Tue, 12 Mar 2024 10:24:18 +0000
Subject: [PATCH] Query for more header comments
To: emacs-devel@gnu.org
* lisp/autoinsert.el (auto-insert-alist): Query for "Version:",
"URL:" and "Package-Requires:" header comments in Emacs Lisp
header skeleton.
* doc/misc/autotype.texi (Autoinserting): Document here.
---
doc/misc/autotype.texi | 10 +++----
lisp/autoinsert.el | 59 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/doc/misc/autotype.texi b/doc/misc/autotype.texi
index d927816c492..2f21aee3230 100644
--- a/doc/misc/autotype.texi
+++ b/doc/misc/autotype.texi
@@ -304,11 +304,11 @@ Autoinserting
Ada mode files call the Ada header skeleton command. Emacs Lisp
source files insert the usual header, with a copyright of your
-environment variable @env{$ORGANIZATION} or else the name of the
-current user, and prompt for valid keywords describing the contents.
-Files in a @file{bin} directory for which Emacs could determine no
-specialized mode (@pxref{Choosing Modes,,, emacs, The GNU Emacs
-Manual}) are set to Shell script mode.
+environment variable @env{$ORGANIZATION} or else the name of the current
+user, and prompt for a version, a URL, the required packages and valid
+keywords describing the contents. Files in a @file{bin} directory for
+which Emacs could determine no specialized mode (@pxref{Choosing
+Modes,,, emacs, The GNU Emacs Manual}) are set to Shell script mode.
@findex define-auto-insert
In Lisp (@pxref{Init File,,, emacs, The GNU Emacs Manual}) you can use the function
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index f2631422c62..dbbc666730a 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -199,11 +199,68 @@ auto-insert-alist
;; Copyright (C) " (format-time-string "%Y") " "
(getenv "ORGANIZATION") | (progn user-full-name) "
+;; Version: "
+ (let
+ ((minibuffer-help-form
+ (replace-regexp-in-string
+ "\\`.+\n\n\\(\\(?:.*\n\\)*\\)
+Examples of version conversion:\\(?:\n.*\\)*\\'"
+ "\\1"
+ (documentation #'version-to-list)))
+ r)
+ (while
+ (condition-case nil
+ (not (or (string-empty-p (setq r (read-string "Version: ")))
+ (version-to-list r)))
+ (error (message "Please enter a valid version string \
+(C-h for help).")
+ (sit-for 1)
+ t)))
+ r)
+ | -13
+ "
;; Author: " (user-full-name)
'(if (search-backward "&" (line-beginning-position) t)
(replace-match (capitalize (user-login-name)) t t))
'(end-of-line 1) " <" (progn user-mail-address) ">
-;; Keywords: "
+;; URL: "
+(skeleton-read "URL: ") | -9
+"
+;; Package-Requires: ("
+("Package: "
+ "(" str " "
+ (let
+ ((v1
+ (let
+ ((minibuffer-help-form
+ (replace-regexp-in-string
+ "\\`.+\n\n\\(\\(?:.*\n\\)*\\)
+Examples of version conversion:\\(?:\n.*\\)*\\'"
+ "\\1"
+ (documentation #'version-to-list)))
+ r)
+ (while
+ (condition-case nil
+ (not (or (string-empty-p
+ (setq r (read-string "Version: ")))
+ (version-to-list r)))
+ (error
+ (message
+ "Please enter a valid version string (C-h for help).")
+ (sit-for 1)
+ t)))
+ r)))
+ (if (and (not (string-empty-p v1))
+ (not (equal (version-to-list v1) '(0))))
+ (concat "\"" v1 "\") ")
+ (backward-char (+ (length str) 2))
+ (delete-char 1)
+ (forward-char (+ (length str) 1)))))
+-1
+")\n"
+'(if (looking-back ";; Package-Requires: )\n")
+ (delete-backward-char 23))
+";; Keywords: "
'(require 'finder)
;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords)))
'(setq v1 (mapcar (lambda (x) (list (symbol-name (car x))))
--
2.44.0
next reply other threads:[~2024-03-12 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 10:48 Tim Landscheidt [this message]
2024-03-14 10:44 ` [PATCH] Query for more header comments in Emacs Lisp header skeleton Eli Zaretskii
2024-03-14 13:18 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q8fohd5.fsf@vagabond.tim-landscheidt.de \
--to=tim@tim-landscheidt.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.