]> code.delx.au - gnu-emacs/blob - lisp/emacs-lisp/gulp.el
(with-current-buffer): Correct indentation property.
[gnu-emacs] / lisp / emacs-lisp / gulp.el
1 ;;; gulp.el --- Ask for updates for Lisp packages
2
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4
5 ;; Author: Sam Shteingold <shteingd@math.ucla.edu>
6 ;; Maintainer: FSF
7 ;; Keywords: maintenance
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; Search the emacs/{version}/lisp directory for *.el files, extract the
29 ;; name of the author or maintainer and send him e-mail requesting
30 ;; update.
31
32 ;;; Code:
33
34 (defvar gulp-discard "^;+ *Maintainer: *FSF *$"
35 "*The regexp matching the packages not requiring the request for updates.")
36
37 (defvar gulp-tmp-buffer "*gulp*" "The name of the temporary buffer.")
38
39 (defvar gulp-max-len 2000
40 "*Distance into a Lisp source file to scan for keywords.")
41
42 (defvar gulp-request-header
43 (concat
44 "This message was created automatically.
45 A new version of GNU Emacs, "
46 (format "%d.%d" emacs-major-version (+ emacs-minor-version 1))
47 ", is entering the pretest state,
48 and it is high time to submit the updates to the various emacs packages.
49 You're listed as the maintainer of the following package(s):\n\n")
50 "*The starting text of a gulp message.")
51
52 (defvar gulp-request-end
53 (concat
54 "\nIf you have any changes since the version in the previous release ("
55 (format "%d.%d" emacs-major-version emacs-minor-version)
56 "),
57 please send them to me ASAP.
58
59 Thanks.")
60 "*The closing text in a gulp message.")
61
62 (defun gulp-send-requests (dir &optional time)
63 "Send requests for updates to the authors of Lisp packages in directory DIR.
64 For each maintainer, the message consists of `gulp-request-header',
65 followed by the list of packages (with modification times if the optional
66 prefix argument TIME is non-nil), concluded with `gulp-request-end'.
67
68 You can't edit the messages, but you can confirm whether to send each one.
69
70 The list of addresses for which you decided not to send mail
71 is left in the `*gulp*' buffer at the end."
72 (interactive "DRequest updates for Lisp directory: \nP")
73 (save-excursion
74 (set-buffer (get-buffer-create gulp-tmp-buffer))
75 (let ((m-p-alist (gulp-create-m-p-alist
76 (directory-files dir nil "^[^=].*\\.el$" t)
77 dir))
78 ;; Temporarily inhibit undo in the *gulp* buffer.
79 (buffer-undo-list t)
80 mail-setup-hook msg node)
81 (while (setq node (car m-p-alist))
82 (setq msg (gulp-create-message (cdr node) time))
83 (setq mail-setup-hook
84 '(lambda ()
85 (mail-subject)
86 (insert "It's time for Emacs updates again")
87 (goto-char (point-max))
88 (insert msg)))
89 (mail nil (car node))
90 (if (y-or-n-p "Send? ") (mail-send)
91 (kill-this-buffer)
92 (set-buffer gulp-tmp-buffer)
93 (insert (format "%s\n\n" node)))
94 (setq m-p-alist (cdr m-p-alist))))
95 (set-buffer gulp-tmp-buffer)
96 (setq buffer-undo-list nil)))
97
98
99 (defun gulp-create-message (rec time)
100 "Return the message string for REC, which is a list like (FILE TIME)."
101 (let (node (str gulp-request-header))
102 (while (setq node (car rec))
103 (setq str (concat str "\t" (car node)
104 (if time (concat "\tLast modified:\t" (cdr node)))
105 "\n"))
106 (setq rec (cdr rec)))
107 (concat str gulp-request-end)))
108
109
110 (defun gulp-create-m-p-alist (flist dir)
111 "Create the maintainer/package alist for files in FLIST in DIR.
112 That is a list of elements, each of the form (MAINTAINER PACKAGES...)."
113 (save-excursion
114 (let (mplist filen node mnt-tm mnt tm)
115 (get-buffer-create gulp-tmp-buffer)
116 (set-buffer gulp-tmp-buffer)
117 (setq buffer-undo-list t)
118 (while flist
119 (setq fl-tm (gulp-maintainer (setq filen (car flist)) dir))
120 (if (setq tm (cdr fl-tm) mnt (car fl-tm));; there is a definite maintainer
121 (if (setq node (assoc mnt mplist));; this is not a new maintainer
122 (setq mplist (cons (cons mnt (cons (cons filen tm) (cdr node)))
123 (delete node mplist)))
124 (setq mplist (cons (list mnt (cons filen (cdr fl-tm))) mplist))))
125 (message "%s -- %s" filen fl-tm)
126 (setq flist (cdr flist)))
127 (erase-buffer)
128 mplist)))
129
130 (defun gulp-maintainer (filenm dir)
131 "Return a list (MAINTAINER TIMESTAMP) for the package FILENM in directory DIR."
132 (save-excursion
133 (let* ((fl (concat dir filenm)) mnt
134 (timest (format-time-string "%Y-%m-%d %a %T %Z"
135 (elt (file-attributes fl) 5))))
136 (set-buffer gulp-tmp-buffer)
137 (erase-buffer)
138 (insert-file-contents fl nil 0 gulp-max-len)
139 (goto-char 1)
140 (if (re-search-forward gulp-discard nil t)
141 (setq mnt nil) ;; do nothing, return nil
142 (goto-char 1)
143 (if (and (re-search-forward "^;+ *Maintainer: \\(.*\\)$" nil t)
144 (> (length (setq mnt (match-string 1))) 0))
145 () ;; found!
146 (goto-char 1)
147 (if (re-search-forward "^;+ *Author: \\(.*\\)$" nil t)
148 (setq mnt (match-string 1))))
149 (if (= (length mnt) 0) (setq mnt nil))) ;; "^;; Author: $" --> nil
150 (cons mnt timest))))
151
152 ;;; gulp.el ends here