annotate lisp/prim/cleantree.el @ 138:6608ceec7cf8 r20-2b3

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