annotate lisp/efs/efs-tops-20.el @ 199:169c0442b401 r20-3b26

Import from CVS: tag r20-3b26
author cvs
date Mon, 13 Aug 2007 10:00:33 +0200
parents 9f59509498e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: efs-tops-20.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
6 ;; Version: #Revision: 1.1 $
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Description: TOPS-20 support for efs
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; Author: Sandy Rutherford <sandy@math.ubc.ca, sandy@itp.ethz.ch>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; Created: Fri Oct 23 08:52:00 1992
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;; Modified: Sun Nov 27 18:43:45 1994 by sandy on gandalf
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;; Language: Emacs-Lisp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;;; This file is part of efs. See efs.el for copyright
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;;; (it's copylefted) and warrranty (there isn't one) information.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 (require 'efs)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 (provide 'efs-tops-20)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 (defconst efs-tops-20-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 (concat (substring "$efs release: 1.15 $" 14 -2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 "/"
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
25 (substring "#Revision: 1.1 $" 11 -2)))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 ;;;; ------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 ;;;; TOPS-20 support
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 ;;;; ------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 (efs-defun efs-send-pwd tops-20 (host user &optional xpwd)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 ;; pwd doesn't work for tops-20. Need to get the cwd from a dir listing
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 ;; this function returns the cwd in tops-20 syntax
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 (let* ((temp (efs-make-tmp-name host nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 (cmd (concat "dir * " (cdr temp)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 dir u-dir full-dir result)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 (if (null (and (car (setq result (efs-raw-send-cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (efs-get-process host user)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 "Getting TOPS-20 PWD")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (condition-case ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 (delete-file (car temp)) (error nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 (car (setq result
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (efs-raw-send-cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 (efs-get-process host user)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 "Trying to get TOPS-20 PWD, again."))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (set-buffer (get-buffer-create
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 efs-data-buffer-name))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 (erase-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (if (or (file-readable-p (car temp))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (sleep-for efs-retry-time)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 (file-readable-p (car temp)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 ;; Try again.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (insert-file-contents (car temp))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (efs-error host user
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (format
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 "list data file %s not readable" (car temp))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 ;; get the cwd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 (goto-char (point-min))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (if (looking-at "[^ /:]+:<[^<>/ ]+>")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 (setq dir (buffer-substring (match-beginning 0)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 (match-end 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 u-dir (efs-internal-directory-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 (efs-fix-path 'tops-20 dir t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 full-dir (format efs-path-format-string
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 user host u-dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 ;; cache the files too
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 (efs-set-files full-dir
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 (efs-parse-listing
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 'tops-20 host user u-dir full-dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 (efs-add-to-ls-cache full-dir nil (buffer-string) t))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (efs-del-tmp-name (car temp)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 (cons dir (nth 1 result))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 (efs-defun efs-fix-path tops-20 (path &optional reverse)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 ;; Convert PATH from UNIX-ish to tops-20. If REVERSE given, then
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 ;; do just that.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 (if reverse
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 (if (string-match "^\\([^:]+:\\)?<\\([^>.][^>]*\\)>.*$" path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (let ((device (and (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 (substring path (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 (match-end 1))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (dir (substring path (match-beginning 2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (match-end 2)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (file (substring path (1+ (match-end 2)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (while (string-match "\\." dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (setq dir (concat (substring dir 0 (match-beginning 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 "/"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 (substring dir (match-end 0)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 (if device
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (setq dir (concat "/" device "/" dir)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (concat dir file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (error "path %s didn't match tops-20 syntax" path))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (if (string-match "^\\(/[^:/]+:/\\)?\\([^./]+/\\)*\\([^/]*\\)$" path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 (let ((device (and (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (substring path 1 (1- (match-end 1)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 (dir (and (match-beginning 2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 (substring path (match-beginning 2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 (1- (match-end 2)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (file (substring path (match-beginning 3)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (match-end 3))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (if dir
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (while (string-match "/" dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (setq dir (concat (substring dir 0 (match-beginning 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 "."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (substring dir (match-end 0)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (if device
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (concat device "<" dir ">" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 (concat "<" dir ">" file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (if device
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 (error "%s is invalid relative syntax for tops-20" path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (error "path %s is invalid syntax for tops-20" path)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 (efs-defun efs-fix-dir-path tops-20 (dir-path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 ;; Convert a path from UNIX-ish to Tops-20 fir a dir listing.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (cond ((string-equal "/" dir-path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 (error "Can't list tops-20 devices"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 ((string-match "/[^:/]+:/$" dir-path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (error "Can't list all root directories on a tops-20 device"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 ((efs-fix-path 'tops-20 dir-path nil))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 ;; In tops-20 listings, the filename starts immediatley after the date regexp.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (defconst efs-tops-20-date-regexp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 (concat
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 " [1-3]?[0-9]-\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 "\\|Nov\\|Dec\\)-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (efs-defun efs-parse-listing tops-20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 (host user dir path &optional switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 ;; Parse the current buffer which is assumed to be a TOPS-20 directory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 ;; listing, and return a hashtable as the result.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 ;; HOST = remote host name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 ;; USER = user name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 ;; DIR = directory in as a full remote path
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 ;; PATH = directory in full efs path syntax
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 ;; SWITCHES = ls switches (not relevant here)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 (let ((tbl (efs-make-hashtable))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150 file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 (goto-char (point-min))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 (if (looking-at " *[^/:]+:<\\([^/.<>]+\\.\\)+> *$")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 ;; looking at the directory name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (forward-line 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 (while (re-search-forward efs-tops-20-date-regexp nil t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 (setq file (buffer-substring (point)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 (progn (end-of-line) (point))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 (if (string-match "\\.DIRECTORY\\.[0-9]+$" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160 ;; deal with directories
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (efs-put-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162 (substring file 0 (match-beginning 0)) '(t) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163 (efs-put-hash-entry file '(nil) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164 ;; sans extension
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
165 (if (string-match "\\.[0-9]+$" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
166 (efs-put-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
167 (substring file 0 (match-beginning 0)) '(nil) tbl)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
168 (forward-line 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
169 (efs-put-hash-entry "." '(t) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
170 (efs-put-hash-entry ".." '(t) tbl))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
171 tbl))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
172
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
173 (efs-defun efs-really-file-p tops-20 (file ent)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
174 ;; Eliminates the version entries
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
175 (or (car ent) ; file-directory-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
176 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
177 (string-match "\\.[0-9]+$" file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
178
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
179 (efs-defun efs-delete-file-entry tops-20 (path &optional dir-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
180 (let ((ignore-case (memq 'tops-20 efs-case-insensitive-host-types)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
181 (if dir-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
182 (let ((path (file-name-as-directory path))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
183 files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
184 (efs-del-hash-entry path efs-files-hashtable ignore-case)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
185 (setq path (directory-file-name path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
186 files (efs-get-hash-entry (file-name-directory path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
187 efs-files-hashtable
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
188 ignore-case))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
189 (if files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
190 (efs-del-hash-entry (efs-get-file-part path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
191 files ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
192 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
193 (let ((file (efs-get-file-part path)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
194 (if (string-match "\\.[0-9]+$" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
195 ;; Only delete explicit versions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
196 (let ((files (efs-get-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
197 (file-name-directory path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
198 efs-files-hashtable ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
199 (if files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
200 (let ((root (substring file 0
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
201 (match-beginning 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
202 (completion-ignore-case ignore-case)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
203 (len (match-beginning 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
204 (efs-del-hash-entry file files ignore-case)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
205 ;; Now we need to check if there are any
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
206 ;; versions left. If not, then delete the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
207 ;; root entry.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
208 (or (all-completions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
209 root files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
210 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
211 (lambda (sym)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
212 (string-match "\\.[0-9]+$"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
213 (symbol-name sym) len))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
214 (efs-del-hash-entry root files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
215 ignore-case)))))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
216 (efs-del-from-ls-cache path t ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
217
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
218 (efs-defun efs-add-file-entry tops-20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
219 (path dir-p size owner &optional modes nlinks mdtm)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
220 ;; The tops-20 version of this function needs to keep track
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
221 ;; of tops-20's file versions.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
222 (let ((ignore-case (memq 'tops-20 efs-case-insensitive-host-types))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
223 (ent (let ((dir-p (null (null dir-p))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
224 (if mdtm
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
225 (list dir-p size owner nil nil mdtm)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
226 (list dir-p size owner)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
227 (if dir-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
228 (let* ((path (directory-file-name path))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
229 (files (efs-get-hash-entry (file-name-directory path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
230 efs-files-hashtable
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
231 ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
232 (if files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
233 (efs-put-hash-entry (efs-get-file-part path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
234 ent files ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
235 (let ((files (efs-get-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
236 (file-name-directory path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
237 efs-files-hashtable ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
238 (if files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
239 (let ((file (efs-get-file-part path)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
240 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
241 (if (string-match "\\.[0-9]+$" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
242 (efs-put-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
243 (substring file 0 (match-beginning 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
244 ent files ignore-case)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
245 ;; Need to figure out what version of the file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
246 ;; is being added.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
247 (let* ((completion-ignore-case ignore-case)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
248 (len (length file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
249 (versions (all-completions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
250 file files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
251 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
252 (lambda (sym)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
253 (string-match "\\.[0-9]+$"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
254 (symbol-name sym) len)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
255 (N (1+ len))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
256 (max (apply
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
257 'max
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
258 (cons 0 (mapcar
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
259 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
260 (lambda (x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
261 (string-to-int (substring x N))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
262 versions)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
263 ;; No need to worry about case here.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
264 (efs-put-hash-entry
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
265 (concat file "." (int-to-string (1+ max))) ent files))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
266 (efs-put-hash-entry file ent files ignore-case)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
267 (efs-del-from-ls-cache path t ignore-case)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
268
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
269 (efs-defun efs-internal-file-name-as-directory tops-20 (name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
270 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
271 (if (string-match "\\.DIRECTORY\\(\\.[0-9>]\\)?$" name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
272 (setq name (substring name 0 (match-beginning 0))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
273 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
274 (file-name-as-directory name))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
275
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
276 ;;; Tree Dired
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
277
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
278 (defconst efs-dired-tops-20-re-dir
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
279 "^[^\n]+\\.DIRECTORY\\(\\.[0-9]+\\)?$")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
280
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
281 (or (assq 'tops-20 efs-dired-re-dir-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
282 (setq efs-dired-re-dir-alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
283 (cons (cons 'tops-20 efs-dired-tops-20-re-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
284 efs-dired-re-dir-alist)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
285
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
286
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
287 (efs-defun efs-dired-manual-move-to-filename tops-20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
288 (&optional raise-error bol eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
289 ;; In dired, move to first char of filename on this line.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
290 ;; Returns position (point) or nil if no filename on this line.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
291 ;; This is the Tops-20 version.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
292 (or eol (setq eol (save-excursion (skip-chars-forward "^\n\r") (point))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
293 (let (case-fold-search)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
294 (if bol
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
295 (goto-char bol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
296 (skip-chars-backward "^\n\r"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
297 (if (re-search-forward efs-tops-20-date-regexp eol t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
298 (point)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
299 (and raise-error (error "No file on this line")))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
300
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
301 (efs-defun efs-dired-manual-move-to-end-of-filename tops-20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
302 (&optional no-error bol eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
303 ;; Assumes point is at beginning of filename.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
304 ;; So, it should be called only after (dired-move-to-filename t).
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
305 ;; On failure, signals an error or returns nil.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
306 ;; This is the Tops-20 version.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
307 (let ((opoint (point)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
308 (and selective-display
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
309 (null no-error)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
310 (eq (char-after
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
311 (1- (or bol (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
312 (skip-chars-backward "^\r\n")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
313 (point)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
314 ?\r)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
315 ;; File is hidden or omitted.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
316 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
317 ((dired-subdir-hidden-p (dired-current-directory))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
318 (error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
319 (substitute-command-keys
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
320 "File line is hidden. Type \\[dired-hide-subdir] to unhide.")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
321 ((error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
322 (substitute-command-keys
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
323 "File line is omitted. Type \\[dired-omit-toggle] to un-omit."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
324 )))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
325 ;; Is this the right character set?
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
326 (skip-chars-forward "-_A-Z0-9$.;")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
327 (if (or (= opoint (point)) (not (memq (following-char) '(?\n ?\r))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
328 (if no-error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
329 nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
330 (error "No file on this line"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
331 (point))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
332
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
333 (efs-defun efs-internal--file-name-sans-versions tops-20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
334 (name &optional keep-backup-version)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
335 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
336 (if (string-match "\\.[0-9]+$" name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
337 (substring name 0 (match-beginning 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
338 name)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
339
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
340 (efs-defun efs-dired-insert-headerline tops-20 (dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
341 ;; TOPS-20 inserts a headerline. I would prefer the headerline
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
342 ;; to be in efs format. This version tries to
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
343 ;; be careful, because we can't count on a headerline
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
344 ;; over ftp, and we wouldn't want to delete anything
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
345 ;; important.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
346 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
347 (if (looking-at "^ wildcard ")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
348 (forward-line 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
349 (if (looking-at "^[ \n\t]*[^:/<>]+:<[^<>/]+> *\n")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
350 (delete-region (point) (match-end 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
351 (insert " " (directory-file-name dir) ":\n\n")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
352
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
353 ;;; end of efs-tops-20.el