annotate lisp/efs/efs-ms-unix.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents
children 8b8b7f3559a2 8619ce7e4c50
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-ms-unix.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Version: $Revision: 1.1 $
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: efs support for the Microsoft PC FTP server in unix mode.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; Author: Sandy Rutherford <sandy@tsmi19.sissa.it>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; Created: Thu Aug 19 08:31:15 1993 by sandy on ibm550
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;; Modified: Sun Nov 27 18:37:00 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 (provide 'efs-ms-unix)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 (require 'efs)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 (defconst efs-ms-unix-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 (concat (substring "$efs release: 1.15 $" 14 -2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 "/"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 (substring "$Revision: 1.1 $" 11 -2)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 (defvar efs-ms-unix-month-and-time-regexp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 (concat
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 " \\([0-9]+\\) +" ; file size
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 "\\|Nov\\|Dec\\) [ 0-3][0-9]"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 " +\\([ 012][0-9]:[0-6][0-9]\\|[12][90][0-9][0-9]\\) +"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 ;;; entry points
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 (efs-defun efs-fix-path ms-unix (path &optional reverse)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 ;; Convert PATH from UNIX-ish to MS-UNIX.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 (if reverse
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (concat "/" path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 (substring path 1)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (efs-defun efs-fix-dir-path ms-unix (dirpath)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 ;; Convert a path from UNIX-ish to MS-UNIX for a dir listing
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 (if (string-equal dirpath "/")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (error "Cannot grok disk names.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (setq dirpath (substring dirpath 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 (if (string-match "/$" dirpath)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (concat dirpath "*")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 dirpath))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (defmacro efs-ms-unix-parse-file-line ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 ;; Extract the filename, size, and permission string from the current
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 ;; line of a dired-like listing. Assumes that the point is at
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 ;; the beginning of the line, leaves it just before the size entry.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 ;; Returns a list (name size perm-string nlinks owner).
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 ;; If there is no file on the line, returns nil.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (` (let ((eol (save-excursion (end-of-line) (point)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 name size modes nlinks owner)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (skip-chars-forward " 0-9" eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (looking-at efs-modes-links-owner-regexp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (setq modes (buffer-substring (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (match-end 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 nlinks (string-to-int (buffer-substring (match-beginning 2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 (match-end 2)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 owner (buffer-substring (match-beginning 3) (match-end 3)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (re-search-forward efs-ms-unix-month-and-time-regexp eol t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 (setq name (buffer-substring (point) eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 size (string-to-int (buffer-substring (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 (match-end 1))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 (list name size modes nlinks owner)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 (efs-defun efs-parse-listing ms-unix (host user dir path &optional switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 ;; Parse the current buffer which is assumed to be output from
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 ;; the Microsoft FTP server in unix mode.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 ;; Return a hashtable as the result. SWITCHES are never used,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 ;; but they must be specified in the argument list for compatibility
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 ;; with the unix version of this function.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 ;; HOST = remote host name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 ;; USER = user name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 ;; DIR = directory in as a full remote path
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80 ;; PATH = directory in full efs path syntax
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 ;; SWITCHES = ls switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 (goto-char (point-min))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (if (re-search-forward efs-ms-unix-month-and-time-regexp nil t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 (let ((tbl (efs-make-hashtable))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 size modes nlinks dir-p owner file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (beginning-of-line)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 (while (setq file (efs-ms-unix-parse-file-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 (setq size (nth 1 file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 modes (nth 2 file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 nlinks (nth 3 file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 owner (nth 4 file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 file (car file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 dir-p (= (string-to-char modes) ?d))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (if (and dir-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 (string-match "/$" file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 (setq file (substring file 0 -1)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (efs-put-hash-entry file (list dir-p size owner modes nlinks) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (forward-line 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (efs-put-hash-entry "." '(t) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (efs-put-hash-entry ".." '(t) tbl)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 tbl))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 ;;; Tree Dired
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 ;; ms-unix does not have a total line
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (efs-defun efs-dired-insert-headerline ms-unix (dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 ;; MTS has no total line, so we insert a blank line for
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 ;; aesthetics.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (insert "\n")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (forward-char -1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (efs-real-dired-insert-headerline dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (efs-defun efs-dired-manual-move-to-filename ms-unix
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (&optional raise-error bol eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 ;; In dired, move to the first char of filename on this line.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 ;; Returns (point) or nil if raise-error is nil, and there is no
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 ;; no filename on this line.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 ;; This version is for ms-unix.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (or eol (setq eol (save-excursion (skip-chars-forward "^\r\n") (point))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (let (case-fold-search)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 (if bol
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 (goto-char bol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (skip-chars-backward "^\n\r")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 (setq bol (point)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 (if (re-search-forward efs-ms-unix-month-and-time-regexp eol t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (point)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (and raise-error (error "No file on this line")))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (efs-defun efs-dired-manual-move-to-end-of-filename ms-unix
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 (&optional no-error bol eol)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 ;; Assumes point is at the beginning of filename.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 ;; So, it should be called only after (dired-move-to-filename t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 ;; On failure signals an error, or returns nil.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 ;; This is the ms-unix version.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 (let ((opoint (point)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 (and selective-display
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 (null no-error)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (eq (char-after
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 (1- (or bol (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 (skip-chars-backward "^\r\n")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 (point)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 ?\r)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 ;; File is hidden or omitted.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 ((dired-subdir-hidden-p (dired-current-directory))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 (error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 (substitute-command-keys
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150 "File line is hidden. Type \\[dired-hide-subdir] to unhide.")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 ((error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 (substitute-command-keys
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 "File line is omitted. Type \\[dired-omit-toggle] to un-omit.")))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 (if (eolp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 (goto-char opoint)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 (if no-error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 (error "No file on this line")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160 (end-of-line)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (if (char-equal (preceding-char) ?/)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162 (forward-char -1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163 (point))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
165 ;;; end of efs-ms-unix.el