Commit | Line | Data |
---|---|---|
3ecaf18e RS |
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 | |
23 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | ||
25 | ;;; Commentary: | |
26 | ||
27 | ;; Search the emacs/{version}/lisp directory for *.el files, extract the | |
28 | ;; name of the author or maintainer and send him e-mail requesting | |
29 | ;; update. | |
30 | ||
31 | ;;; Code: | |
32 | ||
3ecaf18e RS |
33 | (defvar gulp-discard "^;+ *Maintainer: *FSF *$" |
34 | "*The regexp matching the packages not requiring the request for updates.") | |
35 | ||
3ecaf18e RS |
36 | (defvar gulp-tmp-buffer " *gulp*" "The name of the temporary buffer.") |
37 | ||
38 | (defvar gulp-max-len 2000 | |
30585116 | 39 | "*Distance into a Lisp source file to scan for keywords.") |
3ecaf18e RS |
40 | |
41 | (defvar gulp-request-header | |
42 | "This message was created automatically. | |
43 | Apparently, you are the maintainer of the following package(s):\n\n" | |
30585116 | 44 | "*Text to use at the start of a message sent to request updates.") |
3ecaf18e RS |
45 | |
46 | (defvar gulp-request-end | |
47 | "\nIf your copy is newer than mine, please email me the patches ASAP.\n\n" | |
30585116 | 48 | "*Text to add at the end of a message sent to request updates.") |
3ecaf18e | 49 | |
30585116 RS |
50 | (defun gulp-send-requests (dir) |
51 | "Send requests for updates to the authors of Lisp packages in directory DIR. | |
3ecaf18e RS |
52 | The prepared message consists of `gulp-request-header', followed by the |
53 | list of packages with modification times, concluded with `gulp-request-end'. | |
30585116 | 54 | You can't edit the message, but you can confirm whether to send it. |
3ecaf18e | 55 | The list of rejected addresses will be put into `gulp-tmp-buffer'." |
30585116 RS |
56 | (interactive "DRequest updates for Lisp directory: ") |
57 | (let ((m-p-alist (gulp-create-m-p-alist | |
58 | (directory-files dir nil "\\.el$" t))) | |
59 | mail-setup-hook msg node) | |
3ecaf18e RS |
60 | (while (setq node (car m-p-alist)) |
61 | (setq msg (gulp-create-message (cdr node))) | |
62 | (setq mail-setup-hook '(lambda () (goto-char (point-max)) (insert msg))) | |
63 | (mail nil (car node)) | |
64 | (if (y-or-n-p "Send? ") (mail-send) | |
65 | (kill-this-buffer) | |
66 | (set-buffer gulp-tmp-buffer) | |
67 | (insert (format "%s\n\n" node))) | |
68 | (setq m-p-alist (cdr m-p-alist))))) | |
69 | ||
70 | (defun gulp-create-message (rec) | |
71 | "Return the message string for REC, which is a list like (FILE TIME)." | |
72 | (let (node (str gulp-request-header)) | |
73 | (while (setq node (car rec)) | |
74 | (setq str (concat str "\t" (car node) "\tLast modified:\t" (cdr node) "\n")) | |
75 | (setq rec (cdr rec))) | |
76 | (concat str gulp-request-end))) | |
77 | ||
78 | (defun gulp-create-m-p-alist (flist) | |
79 | "Create the maintainer/package alist for files in FLIST. | |
80 | List of elements (MAINTAINER . (LIST of PACKAGES))" | |
81 | (let (mplist filen node fl-tm) | |
82 | (get-buffer-create gulp-tmp-buffer) | |
83 | (while flist | |
84 | (setq fl-tm (gulp-maintainer (setq filen (car flist)))) | |
85 | (if (setq mnt (car fl-tm));; there is a definite maintainer | |
86 | (if (setq node (assoc mnt mplist));; this is not a new maintainer | |
87 | (setq mplist (cons (cons (car node) | |
88 | (cons (cons filen (cdr fl-tm)) | |
89 | (cdr node))) | |
90 | (delete node mplist))) | |
91 | (setq mplist (cons (list mnt (cons filen (cdr fl-tm))) mplist)))) | |
92 | (message "%s -- %s" filen fl-tm) | |
93 | (setq flist (cdr flist))) | |
94 | (set-buffer gulp-tmp-buffer) | |
95 | (erase-buffer) | |
96 | mplist)) | |
97 | ||
98 | (defun gulp-maintainer (filenm) | |
99 | "Return a list (MAINTAINER TIMESTAMP) for the package FILENM." | |
100 | (save-excursion | |
101 | (let* ((fl (concat gulp-search-path filenm)) mnt | |
102 | (timest (format-time-string "%Y-%m-%d %a %T %Z" | |
103 | (elt (file-attributes fl) 5)))) | |
104 | (set-buffer gulp-tmp-buffer) | |
105 | (erase-buffer) | |
106 | (insert-file-contents fl nil 0 gulp-max-len) | |
107 | (goto-char 1) | |
108 | (if (re-search-forward gulp-discard nil t) | |
109 | (setq mnt nil) ;; do nothing, return nil | |
110 | (goto-char 1) | |
111 | (if (and (re-search-forward "^;+ *Maintainer: \\(.*\\)$" nil t) | |
112 | (> (length (setq mnt (match-string 1))) 0)) | |
113 | () ;; found! | |
114 | (goto-char 1) | |
115 | (if (re-search-forward "^;+ *Author: \\(.*\\)$" nil t) | |
116 | (setq mnt (match-string 1)))) | |
117 | (if (= (length mnt) 0) (setq mnt nil))) ;; "^;; Author: $" --> nil | |
118 | (cons mnt timest)))) | |
119 | ||
120 | ;;; gulp.el ends here |