annotate lisp/hyperbole/hpath.el @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents 8619ce7e4c50
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 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: hpath.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Hyperbole support routines for handling UNIX paths.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: comm, hypermedia, unix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 1-Nov-91 at 00:44:23
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
12 ;; LAST-MOD: 20-Mar-97 at 11:52:51 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (defvar hpath:rfc "/anonymous@ds.internic.net:rfc/rfc%s.txt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 "*String to be used in the call: (hpath:rfc rfc-num)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
20 to create an path to the RFC document for `rfc-num'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (defvar hpath:suffixes '(".gz" ".Z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 "*List of filename suffixes to add or remove within (hpath:exists-p) calls.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (defvar hpath:tmp-prefix "/tmp/remote-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 "*Pathname prefix to attach to remote files copied locally for use with external viewers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defun hpath:absolute-to (path &optional default-dirs)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
33 "Returns PATH as an absolute path relative to one directory from optional DEFAULT-DIRS or `default-directory'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 Returns PATH unchanged when it is not a valid path or when DEFAULT-DIRS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 is invalid. DEFAULT-DIRS when non-nil may be a single directory or a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 directories. The first one in which PATH is found is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (if (not (and (stringp path) (hpath:is-p path nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (if (not (cond ((null default-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (setq default-dirs (cons default-directory nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ((stringp default-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (setq default-dirs (cons default-dirs nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ((listp default-dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (let ((rtn) dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (while (and default-dirs (null rtn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq dir (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (file-name-as-directory (car default-dirs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 rtn (expand-file-name path dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 default-dirs (cdr default-dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (or (file-exists-p rtn) (setq rtn nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (or rtn path)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defun hpath:ange-ftp-at-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "Returns an ange-ftp pathname that point is within or nil.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
57 See the `ange-ftp' or `efs' Elisp packages for pathname format details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Always returns nil if (hpath:ange-ftp-available-p) returns nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if (hpath:ange-ftp-available-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((user (hpath:ange-ftp-default-user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (setq path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (skip-chars-backward "^[ \t\n\"`'\(\{<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ((hpath:url-at-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (if (string-equal
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
68 (buffer-substring (match-beginning 2) (match-end 2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "ftp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; user
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
73 (if (match-beginning 3)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (buffer-substring
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
75 (match-beginning 3) (match-end 3))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (concat user "@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; domain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (hpath:delete-trailer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
79 (buffer-substring (match-beginning 4) (match-end 4)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; path
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
82 (if (match-beginning 6)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
83 (buffer-substring (match-beginning 6)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
84 (match-end 6))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; else ignore this other type of WWW path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; user, domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ((looking-at "/?[^/:@ \t\n\^M\"`']+@[^/:@ \t\n\^M\"`']+:[^]@ \t\n\^M\"`'\)\}]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; @domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ((looking-at "@[^/:@ \t\n\^M\"`']+:[^]@ \t\n\^M\"`'\)\}]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (concat "/" user (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ((and (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "/?\\(\\([^/:@ \t\n\^M\"`']+\\):[^]@:, \t\n\^M\"`'\)\}]*\\)[] \t\n\^M,.\"`'\)\}]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (setq path (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (string-match "[^.]\\.[^.]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (buffer-substring (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (concat "/" user "@" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; host and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ((and (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "/\\([^/:@ \t\n\^M\"`']+:[^]@:, \t\n\^M\"`'\)\}]*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (setq path (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (concat "/" user "@" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (hpath:delete-trailer path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun hpath:ange-ftp-p (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "Returns non-nil iff PATH is an ange-ftp pathname.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
114 See the `ange-ftp' or `efs' Elisp package for pathname format details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Always returns nil if (hpath:ange-ftp-available-p) returns nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (and (stringp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (or (featurep 'ange-ftp) (featurep 'efs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (let ((user (hpath:ange-ftp-default-user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ((hpath:url-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (string-equal
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
124 (substring path (match-beginning 2) (match-end 2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "ftp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; user
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
129 (if (match-beginning 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
130 (substring path (match-beginning 3) (match-end 3))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (concat user "@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; domain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (hpath:delete-trailer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
134 (substring path (match-beginning 4) (match-end 4)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; path
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
137 (if (match-beginning 6)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
138 (substring path (match-beginning 6)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
139 (match-end 6))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; else ignore this other type of WWW path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; user, domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ((string-match "/?[^/:@ \t\n\^M\"`']+@[^/:@ \t\n\^M\"`']+:[^]@ \t\n\^M\"`'\)\}]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (substring path (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; @domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((string-match "@[^/:@ \t\n\^M\"`']+:[^]@ \t\n\^M\"`'\)\}]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (concat "/" user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (substring path (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; domain and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ((and (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "/?\\(\\([^/:@ \t\n\^M\"`']+\\):[^]@:, \t\n\^M\"`'\)\}]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq result (substring path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (string-match "[^.]\\.[^.]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (substring path (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (concat "/" user "@" result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; host and path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ((and (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "/\\([^/:@ \t\n\^M\"`']+:[^]@:, \t\n\^M\"`'\)\}]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq result (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (concat "/" user "@" result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (hpath:delete-trailer result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun hpath:at-p (&optional type non-exist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Returns delimited path or non-delimited ange-ftp path at point, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 World wide web urls are treated as non-paths so they are handled elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Delimiters may be: double quotes, open and close single quote, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Texinfo file references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 If optional TYPE is the symbol 'file or 'directory, then only that path type is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 accepted as a match. Only locally reachable paths are checked for existence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 With optional NON-EXIST, nonexistent local paths are allowed.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
180 Absolute pathnames must begin with a `/' or `~'. Relative pathnames
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
181 must begin with a `./' or `../' to be recognized."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond (;; Local file URLs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (hpath:is-p (hargs:delimited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "file://localhost" "[ \t\n\^M\"\'\}]" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ((hpath:ange-ftp-at-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ((hpath:www-at-p) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ((hpath:is-p (or (hargs:delimited "\"" "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; Filenames in Info docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (hargs:delimited "\`" "\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; Filenames in TexInfo docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (hargs:delimited "@file{" "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 type non-exist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
194 (defun hpath:display-buffer (buffer &optional display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
195 "Displays BUFFER at optional DISPLAY-WHERE location or at hpath:display-where.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
196 BUFFER may be a buffer or a buffer name.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
197
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
198 See documentation of `hpath:display-buffer-alist' for valid values of DISPLAY-WHERE.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
199 Returns non-nil iff buffer is actually displayed."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
200 (interactive "bDisplay buffer: ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
201 (if (stringp buffer) (setq buffer (get-buffer buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
202 (if (null buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
203 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
204 (if (null display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
205 (setq display-where hpath:display-where))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
206 (funcall (car (cdr (or (assq display-where
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
207 hpath:display-buffer-alist)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
208 (assq 'other-window
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
209 hpath:display-buffer-alist))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
210 buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
211 t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
212
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
213 (defun hpath:display-buffer-other-frame (buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
214 "Displays BUFFER, in another frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
215 May create a new frame, or reuse an existing one.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
216 See documentation of `hpath:display-buffer' for details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
217 Returns the dispalyed buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
218 (interactive "bDisplay buffer in other frame: ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
219 (if (= (length (frame-list)) 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
220 (select-frame (make-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
221 (other-frame 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
222 (if (br-in-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
223 (br-to-view-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
224 (switch-to-buffer buffer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
225
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
226 (defun hpath:find (filename &optional display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
227 "Edits file FILENAME using user customizable settings of display program and location.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 FILENAME may start with a special prefix character which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 handled as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 !filename - execute as a non-windowed program within a shell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 &filename - execute as a windowed program;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 -filename - load as an Emacs Lisp program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
235 Otherwise, if FILENAME matches a regular expression in the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
236 `hpath:find-alist,' the associated external display program is invoked.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
237 If not, `hpath:display-alist' is consulted for a specialized internal
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
238 display function to use. If no matches are found there,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
239 `hpath:display-where-alist' is consulted using the optional argument,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
240 DISPLAY-WHERE (a symbol) or if that is nil, the value of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
241 `hpath:display-where', and the matching display function is used.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
242 Returns non-nil iff file is displayed within a buffer (not with an external
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 program)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (interactive "FFind file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (let (modifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if (string-match hpath:prefix-regexp filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq modifier (aref filename 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 filename (substring filename (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq filename (hpath:substitute-value filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (cond (modifier (cond ((eq modifier ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (hact 'exec-shell-cmd filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ((eq modifier ?&)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (hact 'exec-window-cmd filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ((eq modifier ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (load filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (t (let ((find-program (hpath:find-program filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (cond ((stringp find-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (hact 'exec-window-cmd find-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ((hypb:functionp find-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (funcall find-program filename)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
263 t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (t (setq filename (hpath:validate filename))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
265 (if (null display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
266 (setq display-where hpath:display-where))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
267 (funcall (car (cdr (or (assq display-where
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
268 hpath:display-where-alist)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
269 (assq 'other-window
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
270 hpath:display-where-alist))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
271 filename)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
274 (defun hpath:find-line (filename line-num &optional display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
275 "Edits file FILENAME with point placed at LINE-NUM.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
276
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
277 `hpath:display-where-alist' is consulted using the optional argument,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
278 DISPLAY-WHERE (a symbol) or if that is nil, the value of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
279 `hpath:display-where', and the matching display function is used to determine
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
280 where to display the file, e.g. in another frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
281 Always returns t."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
282 (interactive "FFind file: ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
283 ;; Just delete any special characters preceding the filename, ignoring them.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
284 (if (string-match hpath:prefix-regexp filename)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
285 (setq filename (substring filename (match-end 0))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
286 (setq filename (hpath:substitute-value filename)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
287 filename (hpath:validate filename))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
288 (if (null display-where)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
289 (setq display-where hpath:display-where))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
290 (funcall (car (cdr (or (assq display-where
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
291 hpath:display-where-alist)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
292 (assq 'other-window
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
293 hpath:display-where-alist))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
294 filename)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
295 (if (integerp line-num)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
296 (progn (widen) (goto-line line-num)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
297 t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
298
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
299 (defun hpath:find-other-frame (filename)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
300 "Edits file FILENAME, in another frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
301 May create a new frame, or reuse an existing one.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
302 See documentation of `hpath:find' for details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
303 Returns the buffer of displayed file."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
304 (interactive "FFind file in other frame: ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
305 (if (= (length (frame-list)) 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
306 (select-frame (make-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
307 (other-frame 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
308 (if (br-in-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
309 (br-to-view-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
310 (find-file filename))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
311
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
312 (defun hpath:find-other-window (filename)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
313 "Edits file FILENAME, in another window or using an external program.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
314 May create a new window, or reuse an existing one; see the function display-buffer.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
315 See documentation of `hpath:find' for details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
316 Returns non-nil iff file is displayed within a buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (interactive "FFind file in other window: ")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
318 (hpath:find filename 'other-window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defun hpath:is-p (path &optional type non-exist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "Returns PATH if PATH is a Unix path, else nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 If optional TYPE is the symbol 'file or 'directory, then only that path type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 is accepted as a match. The existence of the path is checked only for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 locally reachable paths (Info paths are not checked). Single spaces are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 permitted in middle of existing pathnames, but not at the start or end. Tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 and newlines are converted to space before the pathname is checked, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 normalized path form is what is returned for PATH. With optional NON-EXIST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 nonexistent local paths are allowed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((rtn-path path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (suffix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (and (stringp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; Path may be a link reference with other components other than a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; pathname. These components always follow a comma, so strip them,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; if any, before checking path.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (if (string-match "[ \t\n\^M]*," path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (setq rtn-path (concat (substring path 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 "%s" (substring path (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 path (substring path 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq rtn-path (concat rtn-path "%s")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (if (string-match hpath:prefix-regexp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (setq path (substring path (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
343 (not (or (string-equal path "")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (string-match "\\`\\s \\|\\s \\'" path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; Convert tabs and newlines to space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq path (hbut:key-to-label (hbut:label-to-key path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (or (not (string-match "[()]" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (string-match "\\`([^ \t\n\^M\)]+)[ *A-Za-z0-9]" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (if (string-match "\\${[^}]+}" path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (setq path (hpath:substitute-value path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (not (string-match "[\t\n\^M\"`'{}|\\]" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (or (not (hpath:www-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (string-match "^ftp:" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (let ((remote-path (string-match "@.+:\\|^/.+:\\|.+:/" path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (cond (remote-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (cond ((eq type 'file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (not (string-equal "/" (substring path -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ((eq type 'directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (string-equal "/" (substring path -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ((or (and non-exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;; Info or ange-ftp path, so don't check for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (string-match "[()]" path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (hpath:ange-ftp-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (setq suffix (hpath:exists-p path t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; Don't allow spaces in non-existent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; pathnames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (not (string-match " " path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (setq suffix (hpath:exists-p path t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (cond ((eq type 'file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (not (file-directory-p path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ((eq type 'directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (file-directory-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
378 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
379 ;; Quote any but last %s within rtn-path.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
380 (setq rtn-path (hypb:replace-match-string "%s" rtn-path "%%s")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
381 rtn-path (hypb:replace-match-string "%%s\\'" rtn-path "%s"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
382 ;; Return path if non-nil return value.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
383 (if (stringp suffix);; suffix could = t, which we ignore
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
384 (if (string-match
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
385 (concat (regexp-quote suffix) "%s") rtn-path)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
386 ;; remove suffix
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
387 (concat (substring rtn-path 0 (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
388 (substring rtn-path (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
389 ;; add suffix
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
390 (format rtn-path suffix))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
391 (format rtn-path ""))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun hpath:relative-to (path &optional default-dir)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
394 "Returns PATH relative to optional DEFAULT-DIR or `default-directory'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Returns PATH unchanged when it is not a valid path."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if (not (and (stringp path) (hpath:is-p path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq default-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (file-name-as-directory (or default-dir default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 path (expand-file-name path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (and path default-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (if (string-equal "/" default-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let ((end-dir (min (length path) (length default-dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ((string-equal (substring path 0 end-dir) default-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (concat "./" (substring path end-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ((progn (setq default-dir (file-name-directory (directory-file-name default-dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 end-dir (min (length path) (length default-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (string-equal (substring path 0 end-dir) default-dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (concat "../" (substring path end-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ((progn (setq default-dir (file-name-directory (directory-file-name default-dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 end-dir (min (length path) (length default-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (string-equal (substring path 0 end-dir) default-dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (concat "../../" (substring path end-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (t path)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun hpath:rfc (rfc-num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "Return pathname to textual rfc document indexed by RFC-NUM.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
421 See the documentation of the `hpath:rfc' variable."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (format hpath:rfc rfc-num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun hpath:substitute-value (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "Substitutes matching value for Emacs Lisp variables and environment variables in PATH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Returns path with variable values substituted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (substitute-in-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (hypb:replace-match-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 "\\${[^}]+}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (lambda (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let* ((var-group (substring path match start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (var-name (substring path (+ match 2) (1- start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (rest-of-path (substring path start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (sym (intern-soft var-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (if (file-name-absolute-p rest-of-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq rest-of-path (substring rest-of-path 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (and sym (boundp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (directory-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (hpath:substitute-dir var-name rest-of-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 var-group))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun hpath:substitute-var (path)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
446 "Replaces up to one match in PATH with first matching variable from `hpath:variables'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if (not (and (stringp path) (string-match "/" path) (hpath:is-p path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (setq path (hpath:symlink-referent path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (let ((new-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (vars hpath:variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 result var val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (while (and vars (null new-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq var (car vars) vars (cdr vars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (if (boundp var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (progn (setq val (symbol-value var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (cond ((stringp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (hpath:substitute-var-name var val path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (setq new-path result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ((null val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ((listp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (while (and val (null new-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (if (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (hpath:substitute-var-name var (car val) path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq new-path result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (setq val (cdr val))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
468 (t (error "(hpath:substitute-var): `%s' has invalid value for hpath:variables" var))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (or new-path path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; The following function recursively resolves all UNIX links to their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; final referents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; Works with Apollo's variant and other strange links like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; /usr/local -> $(SERVER_LOCAL)/usr/local, /usr/bin ->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; ../$(SYSTYPE)/usr/bin and /tmp -> `node_data/tmp. It also handles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; relative links properly as in /usr/local/emacs -> gnu/emacs which must
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
479 ;; be resolved relative to the `/usr/local' directory.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
480 ;; It will fail on Apollos if the `../' notation is used to move just
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
481 ;; above the `/' directory level. This is fairly uncommon and so the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; problem has not been fixed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defun hpath:symlink-referent (linkname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 "Returns expanded file or directory referent of LINKNAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 LINKNAME should not end with a directory delimiter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 Returns nil if LINKNAME is not a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 Returns LINKNAME unchanged if it is not a symbolic link but is a pathname."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (if (stringp linkname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (or (file-symlink-p linkname) linkname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defun hpath:symlink-expand (referent dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 "Returns expanded file or directory REFERENT relative to DIRNAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (let ((var-link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (dir dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (while (string-match "\\$(\\([^\)]*\\))" referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (setq var-link (getenv (substring referent (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 referent (concat (substring referent 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 var-link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (substring referent (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; If referent is not an absolute path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (let ((nd-abbrev (string-match "`node_data" referent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (and nd-abbrev (= nd-abbrev 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (setq referent (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;; Prepend node name given in dirname, if any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (and (string-match "^//[^/]+" dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (substring dirname 0 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "/sys/" (substring referent 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (while (string-match "\\(^\\|/\\)\\.\\.\\(/\\|$\\)" referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; Match to "//.." or "/.." at the start of link referent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (while (string-match "^\\(//\\.\\.\\|/\\.\\.\\)\\(/\\|$\\)" referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (setq referent (substring referent (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; Match to "../" or ".." at the start of link referent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (while (string-match "^\\.\\.\\(/\\|$\\)" referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq dir (file-name-directory (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 referent (concat dir (substring referent (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; Match to rest of "../" in link referent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (while (string-match "[^/]+/\\.\\./" referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (setq referent (concat (substring referent 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (substring referent (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (and (/= (aref referent 0) ?~)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (/= (aref referent 0) ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (setq referent (expand-file-name referent dirname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 referent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defun hpath:validate (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 "Returns PATH if PATH is a valid, readable path, else signals error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Info and ange-ftp remote pathnames are considered readable without any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 validation checks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 Default-directory should be equal to current Hyperbole button source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 directory when called, so that PATH is expanded relative to it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (cond ((not (stringp path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (error "(hpath:validate): \"%s\" is not a pathname." path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ((or (string-match "[()]" path) (hpath:ange-ftp-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; info or ange-ftp path, so don't validate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ((if (not (hpath:www-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; Otherwise, must not be a WWW link ref and must be a readable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;; path.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (let ((return-path (hpath:exists-p path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (and return-path (file-readable-p return-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 return-path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (t (error "(hpath:validate): \"%s\" is not readable." path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (defun hpath:url-at-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 "Return world-wide-web universal resource locator (url) that point immediately precedes or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 Use buffer-substring with match-beginning and match-end on the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 groupings:
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
550 1 = optional `URL:' literal
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
551 2 = access protocol
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
552 4 = optional username
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
553 4 = host and domain to connect to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
554 5 = optional port number to use
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
555 6 = optional pathname to access."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
556 ;; WWW URL format: [URL:]<protocol>:/[<user>@]<domain>[:<port>][/<path>]
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
557 ;; or [URL:]<protocol>://[<user>@]<domain>[:<port>][<path>]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; Avoid [a-z]:/path patterns since these may be disk paths on OS/2, DOS or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;; Windows.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
560 (if (looking-at "\\(URL:\\)?\\([a-zA-Z][a-zA-Z]+\\)://?\\([^@/: \t\n\^M]+@\\)?\\([^/:@ \t\n\^M\"`']+\\)\\(:[0-9]+\\)?\\([/~][^]@ \t\n\^M\"`'\)\}>]*\\)?")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (save-excursion
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
562 (goto-char (match-end 0))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
563 (skip-chars-backward ".,?#!*()")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
564 (buffer-substring (match-beginning 2) (point)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun hpath:url-p (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 "Return t if OBJ is a world-wide-web universal resource locator (url) string, else nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 Use string-match with match-beginning and match-end on the following groupings:
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
569 1 = optional `URL:' literal
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
570 2 = access protocol
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
571 3 = optional username
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
572 4 = host and domain to connect to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
573 5 = optional port number to use
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
574 6 = optional pathname to access."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
575 ;; WWW URL format: [URL:]<protocol>:/[<user>@]<domain>[:<port>][/<path>]
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
576 ;; or [URL:]<protocol>://[<user>@]<domain>[:<port>][<path>]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 ;; Avoid [a-z]:/path patterns since these may be disk paths on OS/2, DOS or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; Windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (and (stringp obj)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
580 (string-match "\\`<?\\(URL:\\)?\\([a-zA-Z][a-zA-Z]+\\)://?\\([^@/: \t\n\^M]+@\\)?\\([^/:@ \t\n\^M\"`']+\\)\\(:[0-9]+\\)?\\([/~][^]@ \t\n\^M\"`'\)\}>]*\\)?>?\\'"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (defun hpath:www-at-p (&optional include-start-and-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "Returns a world-wide-web link reference that point is within or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 With optional INCLUDE-START-AND-END-P non-nil, returns list of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (link-string begin-position end-position)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (skip-chars-backward "^[ \t\n\"`'\(\{<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (cond ((not include-start-and-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (hpath:url-at-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ((hpath:url-at-p)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
593 (list (buffer-substring (match-beginning 2) (match-end 0))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
594 (match-beginning 2)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
595 (match-end 0))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun hpath:www-p (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Returns non-nil iff PATH is a world-wide-web link reference."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (and (stringp path) (hpath:url-p path) path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defun hpath:ange-ftp-available-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Return t if the ange-ftp or efs package is available, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 Either the package must have been loaded already or under versions of Emacs
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
608 19, it must be set for autoloading via `file-name-handler-alist'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (or (featurep 'ange-ftp) (featurep 'efs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (and (boundp 'file-name-handler-alist) ; v19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (or (rassq 'ange-ftp-hook-function file-name-handler-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (rassq 'efs-file-handler-function file-name-handler-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (defun hpath:ange-ftp-default-user ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 "Return default user account for remote file access with ange-ftp or efs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 Returns \"anonymous\" if neither ange-ftp-default-user nor efs-default-user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 is set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (cond ((and (boundp 'ange-ftp-default-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (stringp ange-ftp-default-user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ange-ftp-default-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ((and (boundp 'efs-default-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (stringp efs-default-user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 efs-default-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (t "anonymous")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (defun hpath:delete-trailer (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "Return string minus any trailing .?#!*() characters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (if (and (stringp string) (> (length string) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (string-match "[.?#!*()]+\\'" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (substring string 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defun hpath:exists-p (path &optional suffix-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 "Return PATH if it exists. (This does not mean you can read it.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 If PATH exists with or without a suffix from hpath:suffixes, then that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 pathname is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 With optional SUFFIX-FLAG and PATH exists, return suffix added or removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 from path or t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (let ((return-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (suffix) suffixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (if (file-exists-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq return-path path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setq suffixes hpath:suffixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (while suffixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (setq suffix (car suffixes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if (string-match (concat (regexp-quote suffix) "\\'") path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Remove suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (setq return-path (substring path 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; Add suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (setq return-path (concat path suffix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (if (file-exists-p return-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (setq suffixes nil);; found a match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (setq suffix nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 suffixes (cdr suffixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 return-path nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (if return-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (if suffix-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (or suffix t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 return-path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun hpath:find-program (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "Return shell or Lisp command to execute to display FILENAME or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Return nil if FILENAME is a directory name.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
669 See also documentation for `hpath:find-alist' and `hpath:display-alist'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (let ((cmd))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (cond ((and (stringp filename) (file-directory-p filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ((stringp (setq cmd (hpath:match filename hpath:find-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (let ((orig-path filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;; If filename is a remote path, we have to copy it to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; temporary local file and then display that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (if (hpath:ange-ftp-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (copy-file orig-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (setq filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (concat hpath:tmp-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (file-name-nondirectory orig-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; Permit %s substitution of filename within program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (if (string-match "[^%]%s" cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (format cmd filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (concat cmd " " filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ((null cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (hpath:match filename hpath:display-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (t cmd))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (defun hpath:match (filename regexp-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 "If FILENAME matches the car of any element in REGEXP-ALIST, return its cdr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 REGEXP-ALIST elements must be of the form (<filename-regexp>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 . <command-to-display-file>). <command-to-display-file> may be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 representing an external window-system command to run or it may be a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 function to call with FILENAME as its single argument."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (let ((cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (while (and (not cmd) regexp-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (if (string-match (car (setq elt (car regexp-alist))) filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (setq cmd (cdr elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (setq regexp-alist (cdr regexp-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 cmd))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (defun hpath:substitute-dir (var-name rest-of-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 "Returns a dir for VAR-NAME using REST-OF-PATH to find match or triggers an error when no match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 VAR-NAME's value may be a directory or a list of directories. If it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 list, the first directory prepended to REST-OF-PATH which produces a valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 local pathname is returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (let (sym val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (cond ((not (stringp var-name))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
713 (error "(hpath:substitute-dir): VAR-NAME arg, `%s', must be a string" var-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ((not (and (setq sym (intern-soft var-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (boundp sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (error "(hpath:substitute-dir): VAR-NAME arg, \"%s\", is not a bound variable"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 var-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ((stringp (setq val (symbol-value sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (if (hpath:validate (expand-file-name rest-of-path val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ((listp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (let ((dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (while (and val (not dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq dir (car val) val (cdr val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (or (and (stringp dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (file-name-absolute-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (file-readable-p (expand-file-name rest-of-path dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (setq dir nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (if dir (hpath:validate (directory-file-name dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (error "(hpath:substitute-dir): Can't find match for \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (concat "${" var-name "}/" rest-of-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (t (error "(hpath:substitute-dir): Value of VAR-NAME, \"%s\", must be a string or list" var-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun hpath:substitute-var-name (var-symbol var-dir-val path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 "Replaces with VAR-SYMBOL any occurrences of VAR-DIR-VAL in PATH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Replacement is done iff VAR-DIR-VAL is an absolute path.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 If PATH is modified, returns PATH, otherwise returns nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (if (and (stringp var-dir-val) (file-name-absolute-p var-dir-val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (let ((new-path (hypb:replace-match-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (regexp-quote (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (or var-dir-val default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 path (concat "${" (symbol-name var-symbol) "}/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (equal new-path path) nil new-path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (defvar hpath:prefix-regexp "\\`[-!&][ ]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 "Regexp matching command characters which may precede a pathname.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 These are used to indicate how to display or execute the pathname.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 - means evaluate it as Emacs Lisp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ! means execute it as a shell script
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 & means run it under the current window system.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (provide 'hpath)