all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Query for more header comments in Emacs Lisp header skeleton
@ 2024-03-12 10:48 Tim Landscheidt
  2024-03-14 10:44 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Landscheidt @ 2024-03-12 10:48 UTC (permalink / raw)
  To: emacs-devel

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-14 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12 10:48 [PATCH] Query for more header comments in Emacs Lisp header skeleton Tim Landscheidt
2024-03-14 10:44 ` Eli Zaretskii
2024-03-14 13:18   ` Stefan Monnier

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.