gulp.el 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ;;; gulp.el --- ask for updates for Lisp packages
  2. ;; Copyright (C) 1996, 2001-2012 Free Software Foundation, Inc.
  3. ;; Author: Sam Shteingold <shteingd@math.ucla.edu>
  4. ;; Maintainer: FSF
  5. ;; Keywords: maint
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Search the emacs/{version}/lisp directory for *.el files, extract the
  19. ;; name of the author or maintainer and send him e-mail requesting
  20. ;; update.
  21. ;;; Code:
  22. (defgroup gulp nil
  23. "Ask for updates for Lisp packages."
  24. :prefix "-"
  25. :group 'maint)
  26. (defcustom gulp-discard "^;+ *Maintainer: *FSF *$"
  27. "The regexp matching the packages not requiring the request for updates."
  28. :type 'regexp
  29. :group 'gulp)
  30. (defcustom gulp-tmp-buffer "*gulp*"
  31. "The name of the temporary buffer."
  32. :type 'string
  33. :group 'gulp)
  34. (defcustom gulp-max-len 2000
  35. "Distance into a Lisp source file to scan for keywords."
  36. :type 'integer
  37. :group 'gulp)
  38. (defcustom gulp-request-header
  39. (concat
  40. "This message was created automatically.
  41. I'm going to start pretesting a new version of GNU Emacs soon, so I'd
  42. like to ask if you have any updates for the Emacs packages you work on.
  43. You're listed as the maintainer of the following package(s):\n\n")
  44. "The starting text of a gulp message."
  45. :type 'string
  46. :group 'gulp)
  47. (defcustom gulp-request-end
  48. (concat
  49. "\nIf you have any changes since the version in the previous release ("
  50. (format "%d.%d" emacs-major-version emacs-minor-version)
  51. "),
  52. please send them to me ASAP.
  53. Please don't send the whole file. Instead, please send a patch made with
  54. `diff -c' that shows precisely the changes you would like me to install.
  55. Also please include itemized change log entries for your changes;
  56. please use lisp/ChangeLog as a guide for the style and for what kinds
  57. of information to include.
  58. Thanks.")
  59. "The closing text in a gulp message."
  60. :type 'string
  61. :group 'gulp)
  62. (declare-function mail-subject "sendmail" ())
  63. (declare-function mail-send "sendmail" ())
  64. (defun gulp-send-requests (dir &optional time)
  65. "Send requests for updates to the authors of Lisp packages in directory DIR.
  66. For each maintainer, the message consists of `gulp-request-header',
  67. followed by the list of packages (with modification times if the optional
  68. prefix argument TIME is non-nil), concluded with `gulp-request-end'.
  69. You can't edit the messages, but you can confirm whether to send each one.
  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. (with-current-buffer (get-buffer-create gulp-tmp-buffer)
  74. (let ((m-p-alist (gulp-create-m-p-alist
  75. (directory-files dir nil "^[^=].*\\.el$" t)
  76. dir))
  77. ;; Temporarily inhibit undo in the *gulp* buffer.
  78. (buffer-undo-list t)
  79. mail-setup-hook msg node)
  80. (setq m-p-alist
  81. (sort m-p-alist
  82. (function (lambda (a b)
  83. (string< (car a) (car b))))))
  84. (while (setq node (car m-p-alist))
  85. (setq msg (gulp-create-message (cdr node) time))
  86. (setq mail-setup-hook
  87. (lambda ()
  88. (mail-subject)
  89. (insert "It's time for Emacs updates again")
  90. (goto-char (point-max))
  91. (insert msg)))
  92. (mail nil (car node))
  93. (goto-char (point-min))
  94. (if (y-or-n-p "Send? ") (mail-send)
  95. (kill-this-buffer)
  96. (set-buffer gulp-tmp-buffer)
  97. (insert (format "%s\n\n" node)))
  98. (setq m-p-alist (cdr m-p-alist))))
  99. (set-buffer gulp-tmp-buffer)
  100. (setq buffer-undo-list nil)))
  101. (defun gulp-create-message (rec time)
  102. "Return the message string for REC, which is a list like (FILE TIME)."
  103. (let (node (str gulp-request-header))
  104. (while (setq node (car rec))
  105. (setq str (concat str "\t" (car node)
  106. (if time (concat "\tLast modified:\t" (cdr node)))
  107. "\n"))
  108. (setq rec (cdr rec)))
  109. (concat str gulp-request-end)))
  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 fl-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. (setq flist (cdr flist)))
  126. (erase-buffer)
  127. mplist)))
  128. (defun gulp-maintainer (filenm dir)
  129. "Return a list (MAINTAINER TIMESTAMP) for the package FILENM in directory DIR."
  130. (save-excursion
  131. (let* ((fl (expand-file-name filenm dir)) mnt
  132. (timest (format-time-string "%Y-%m-%d %a %T %Z"
  133. (elt (file-attributes fl) 5))))
  134. (set-buffer gulp-tmp-buffer)
  135. (erase-buffer)
  136. (insert-file-contents fl nil 0 gulp-max-len)
  137. (goto-char 1)
  138. (if (re-search-forward gulp-discard nil t)
  139. (setq mnt nil) ;; do nothing, return nil
  140. (goto-char 1)
  141. (if (and (re-search-forward "^;+ *Maintainer: \\(.*\\)$" nil t)
  142. (> (length (setq mnt (match-string 1))) 0))
  143. () ;; found!
  144. (goto-char 1)
  145. (if (re-search-forward "^;+ *Author: \\(.*\\)$" nil t)
  146. (setq mnt (match-string 1))))
  147. (if (= (length mnt) 0) (setq mnt nil))) ;; "^;; Author: $" --> nil
  148. (cons mnt timest))))
  149. (provide 'gulp)
  150. ;;; gulp.el ends here