結論は以下の設定。これを ~/.emacs.d/init.el とかに書いておくと所望するコメントが挿入されました。
(setq user-full-name "Your name")
(setq user-mail-address "Your email address")
(eval-after-load 'autoinsert
'(setq auto-insert-alist
(put-alist
'("\\.el\\'" . "Emacs Lisp header")
'("Short description: "
";;; " (file-name-nondirectory (buffer-file-name)) " --- " str "
;; Copyright (C) " (format-time-string "%Y") " "
(getenv "ORGANIZATION") | (progn user-full-name) "
;; 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: "
'(require 'finder)
'(setq v1 (mapcar (lambda (x) (list (symbol-name (car x))))
finder-known-keywords)
v2 (mapconcat (lambda (x) (format "%12s: %s" (car x) (cdr x)))
finder-known-keywords
"\n"))
((let ((minibuffer-help-form v2))
(completing-read "Keyword, C-h: " v1 nil t))
str ", ") & -2 "
\;; 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 <http://www.gnu.org/licenses/>.
\;;; Commentary:
\;; " _ "
\;;; Code:
\(provide '"
(file-name-base)
")
\;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")
auto-insert-alist)))
以降、設定に至るまでの云々。まずヘッダコメントの雛形はどのように定義されてるのか。
どうやら auto-insert-alist 変数に雛形が保持されているらしく
M-x describe-variable して変数の説明を確認することに。
曰く auto-insert-alist は
(CONDITION . ACTION) または ((CONDITION . DESCRIPTION) . ACTION) な要素からなるリストで、
CONDITION はファイル名にマッチする正規表現かメジャーモードのお名前、
DESCRIPTION はプロンプトか何かに使われる文字、
ACTION は挿入の骨組みになる部分、とある。
auto-insert-alist の初期値は autoinsert.el に定義されていて内容は以下。
ACTION がどの辺りに該当するのかわかりにくい。
(("\\.el\\'" . "Emacs Lisp header")
"Short description: "
";;; " (file-name-nondirectory (buffer-file-name)) " --- " str "
;; Copyright (C) " (format-time-string "%Y") " "
(getenv "ORGANIZATION") | (progn user-full-name) "
;; 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: "
'(require 'finder)
;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords)))
'(setq v1 (mapcar (lambda (x) (list (symbol-name (car x))))
finder-known-keywords)
v2 (mapconcat (lambda (x) (format "%12s: %s" (car x) (cdr x)))
finder-known-keywords
"\n"))
((let ((minibuffer-help-form v2))
(completing-read "Keyword, C-h: " v1 nil t))
str ", ") & -2 "
\;; 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 <http://www.gnu.org/licenses/>.
\;;; Commentary:
\;; " _ "
\;;; Code:
\(provide '"
(file-name-base)
")
\;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")
Autoinserting - Features for Automatic Typing によれば "Short description: "
とそれ以降が ACTION にあたるらしい。
記法は Skeleton Language - Features for Automatic Typing によるもの。
さらに
Skeleton Language - Features for Automatic Typing によれば "Short description: "
はプロンプトに表示される文字で、それより後に続く要素が挿入されていく模様。
要は変数 user-full-name と user-mail-address を設定すればよさそう。
あと This program is… の前の行に This file is not part of GNU Emacs. を挿入してあげればよさげ。
かくかくしかじかで先に説明した設定に至りましたと。
これにて Emacs Lisp なパッケージを量産できるようになるのか。