annotate lisp/dired/dired-vms.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; dired-vms.el - VMS support for dired. Revision: 1.17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1990, 1992 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
17 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
18 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
19 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Id: dired-vms.el,v 1.17 1991/09/09 16:54:03 sk RelBeta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You'll need vmsproc.el for this function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (autoload 'subprocess-command-to-buffer "vmsproc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (setq dired-subdir-regexp "^ *Directory \\([][:.A-Z-0-9_$;<>]+\\)\\(\\)[\n\r]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defconst dired-vms-filename-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 "\\(\\([_A-Z0-9$]?\\|[_A-Z0-9$][_A-Z0-9$---]*\\)\\.[_A-Z0-9$---]*;+[0-9]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "Regular expression to match for a valid VMS file name in Dired buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 Stupid freaking bug! Position of _ and $ shouldn't matter but they do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 Having [A-Z0-9$_] bombs on filename _$$CHANGE_LOG$.TXT$ and $CHANGE_LOG$.TX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Other orders of $ and _ seem to all work just fine.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (setq dired-re-mark "^[^ \n\t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar dired-directory-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "DIRECTORY/SIZE/DATE/PROT"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Directory command for dired under VMS.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; requires vmsproc.el to work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defun dired-ls (file switches &optional wildcard full-directory-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "Insert ls output of FILE,formatted according to SWITCHES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Optional third arg WILDCARD means treat FILE as shell wildcard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Optional fourth arg FULL-DIRECTORY-P means file is a directory and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 switches do not contain `d'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 SWITCHES default to dired-listing-switches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 This is the VMS version of this UNIX command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 The SWITCHES and WILDCARD arguments are ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Uses dired-directory-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (save-restriction;; Must drag point along:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (subprocess-command-to-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (concat dired-directory-command " " file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (if full-directory-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Just the file line if no full directory required:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (re-search-forward dired-subdir-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (re-search-forward (concat "^" dired-vms-filename-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (delete-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (delete-region (point) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defun dired-insert-headerline (dir) ; redefinition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; VMS dired-ls makes its own headerline, but we must position the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; cursor where dired-insert-subdir expects it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; This does not check whether the headerline matches DIR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (re-search-forward dired-subdir-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (goto-char (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun dired-make-absolute (file &optional dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;"Convert FILE (a pathname relative to DIR) to an absolute pathname."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; This should be good enough for ange-ftp, but might easily be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; redefined (for VMS?).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; It should be reasonably fast, though, as it is called in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; dired-get-filename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (concat (or dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (dired-current-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun dired-make-relative (file &optional dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; In VMS we don't want relative names at all because of search path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; logical names. Also, we never need to raise an error when a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; `doesn't belong' in this buffer (like in the Unix case).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun dired-in-this-tree (file dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;"Is FILE part of the directory tree starting at DIR?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Under VMS, file="DEV:[foo.bar]zod", dir="DEV:[foo]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (or (string= (substring dir -1) "\]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (string= (substring dir -1) "\:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (error "Not a directory: %s" dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (string-match (concat "^" (regexp-quote (substring dir 0 -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun dired-vms-split-filename (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (if (string-match;; "DEV:[DIR]FIL" \1=DEV \2=DIR \3=FIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "^\\([.A-Z-0-9_$;]*\\):?[[<]\\([.A-Z-0-9_$;]*\\)[]>]\\([.A-Z-0-9_$;]*\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (mapcar '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (substring file (match-beginning x) (match-end x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 '(1 2 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; Must use this in dired-noselect instead of expand-file-name and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; Taken from the VMS dired version by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;Roland Roberts BITNET: roberts@uornsrl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Nuclear Structure Research Lab INTERNET: rbr4@uhura.cc.rochester.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; 271 East River Road UUCP: rochester!ur-cc!uhura!rbr4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; Rochester, NY 14267 AT&T: (716) 275-8962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun dired-noselect (dirname &optional switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "Like M-x dired but returns the dired buffer as value, does not select it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (setq dirname (dired-fix-directory dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (dired-internal-noselect dirname switches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun dired-fix-directory (dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "Fix up dirname to be a valid directory name and return it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq dirname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (expand-file-name (or dirname (setq dirname default-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (let ((end (1- (length dirname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 bracket colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if (or (char-equal ?\] (elt dirname end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (char-equal ?\: (elt dirname end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 dirname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq bracket (string-match "\\]" dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq colon (string-match "\\:" dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (setq end (string-match "\\.DIR" dirname (or bracket colon)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let ((newdir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if bracket (concat (substring dirname 0 bracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (if colon (concat (substring dirname 0 (1+ colon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 "["))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (concat newdir (substring dirname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (1+ (or bracket colon)) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if bracket (substring dirname 0 (1+ bracket))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (if colon (substring dirname 0 (1+ colon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 default-directory))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; Versions are not yet supported in dired.el (as of version 4.53):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;(setq dired-file-version-regexp "[.;][0-9]+$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun dired-move-to-filename (&optional raise-error eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "In dired, move to first char of filename on this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Returns position (point) or nil if no filename on this line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; This is the VMS version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (or eol (setq eol (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (re-search-forward (concat " " dired-vms-filename-regexp) eol t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (if raise-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (error "No file on this line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun dired-move-to-end-of-filename (&optional no-error eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; Assumes point is at beginning of filename,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; thus the rwx bit re-search-backward below will succeed in *this* line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; So, it should be called only after (dired-move-to-filename t).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; case-fold-search must be nil, at least for VMS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; On failure, signals an error or returns nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; This is the VMS version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (let (opoint flag ex sym hidden case-fold-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (or eol (setq eol (save-excursion (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (setq hidden (and selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (save-excursion (search-forward "\r" eol t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (if hidden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (re-search-forward dired-vms-filename-regexp eol t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (or no-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (not (eq opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (error (if hidden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "File line is hidden, type \\[dired-hide-subdir] to unhide")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "No file on this line")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (if (eq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defun dired-tree-lessp (dir1 dir2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (setq dir1 (substring (file-name-as-directory dir1) 0 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 dir2 (substring (file-name-as-directory dir2) 0 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((components-1 (dired-split "[:.]" dir1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (components-2 (dired-split "[:.]" dir2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (while (and components-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 components-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (equal (car components-1) (car components-2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq components-1 (cdr components-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 components-2 (cdr components-2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let ((c1 (car components-1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (c2 (car components-2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (cond ((and c1 c2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (string-lessp c1 c2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ((and (null c1) (null c2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 nil) ; they are equal, not lessp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((null c1) ; c2 is a subdir of c1: c1<c2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ((null c2) ; c1 is a subdir of c2: c1>c2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (t (error "This can't happen"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun dired-insert-subdir-validate (dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (let ((alist dired-subdir-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (found nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (while (and alist (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq item (car alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 alist (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq found (dired-in-this-tree dirname (car item))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (error "%s: directory not in this buffer" dirname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun dired-insert-subdir-newpos (new-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Find pos for new subdir, according to tree order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (let ((alist (reverse dired-subdir-alist)) elt dir pos new-pos found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (setq elt (car alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 alist (cdr alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 dir (car elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 pos (dired-get-subdir-min elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (or (and found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (or (dired-in-this-tree dir found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq alist nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (and (dired-in-this-tree new-dir dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq found dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (dired-tree-lessp dir new-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; Insert NEW-DIR after DIR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq new-pos (dired-get-subdir-max elt)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (goto-char new-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; want a separating newline between subdirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (or (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun dired-between-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (or (equal (following-char) 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (progn (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (or (looking-at "Total of")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (equal (following-char) 32))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun dired-buffers-for-dir (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; Return a list of buffers that dired DIR (top level or in-situ subdir).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; The list is in reverse order of buffer creation, most recent last.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; As a side effect, killed dired buffers for DIR are removed from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; dired-buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq dir (file-name-as-directory dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let ((alist dired-buffers) result elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq elt (car alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; In Unix we only looked into the buffer when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; (dired-in-this-tree dir (car elt)) returned non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; In VMS we have to look into each buffer because it doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; necessarily contain only the tree starting at the top level directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (let ((buf (cdr elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (if (buffer-name buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (assoc dir (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 dired-subdir-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq result (cons buf result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; else buffer is killed - clean up:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq dired-buffers (delq elt dired-buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 result))