annotate lisp/cleantree.el @ 288:e11d67e05968 r21-0b42

Import from CVS: tag r21-0b42
author cvs
date Mon, 13 Aug 2007 10:35:54 +0200
parents d44af0c54775
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; cleantree.el --- Remove out of date .elcs in lisp directories
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Author: Steven L Baur <steve@altair.xemacs.org>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6 ;; Keywords: internal
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
13 ;; any later version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
18 ;; General Public License for more details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;; This code is derived from Gnus based on a suggestion by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30 ;; David Moore <dmoore@ucsd.edu>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34 (defun remove-old-elc-1 (dir &optional seen)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
35 (setq dir (file-name-as-directory dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36 ;; Only scan this sub-tree if we haven't been here yet.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37 (unless (member (file-truename dir) seen)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 (push (file-truename dir) seen)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39 ;; We descend recursively
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
40 (let ((dirs (directory-files dir t nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
41 dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
42 (while (setq dir (pop dirs))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
43 (when (and (not (member (file-name-nondirectory dir) '("." "..")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
44 (file-directory-p dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
45 (remove-old-elc-1 dir seen))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
46 ;; Do this directory.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
47 (let ((files (directory-files dir t ".el$"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
48 file file-c)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
49 (while (setq file (car files))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
50 (setq files (cdr files))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
51 (setq file-c (concat file "c"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
52 (when (and (file-exists-p file-c)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
53 (file-newer-than-file-p file file-c))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
54 (message file-c)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
55 (delete-file file-c))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
56
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
57 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
58 (defun batch-remove-old-elc ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
59 (defvar command-line-args-left)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
60 (unless noninteractive
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
61 (error "`batch-remove-old-elc' is to be used only with -batch"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
62 (let ((dir (car command-line-args-left)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
63 (message "Cleaning out of date .elcs in directory `%s'..." dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
64 (remove-old-elc-1 dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
65 (message "Cleaning out of date .elcs in directory `%s'...done" dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
66 (setq command-line-args-left nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
67
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
68 ;;; cleantree.el ends here