comparison lisp/info.el @ 13004:0ed37da6f0f3

(Info-suffix-list): Add .inf to MSDOS list. (info-insert-file-contents): Use info-insert-file-contents-1 to set FULLNAME. Use call-process-region to run the decode program. (Info-find-node): Use info-insert-file-contents-1. (info-insert-file-contents-1) [MSDOS]: Don't use the dot in SUFFIX if FILENAME already has one.
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Sep 1995 18:04:02 +0000
parents c465c82e09ff
children 805486dfbc82
comparison
equal deleted inserted replaced
13003:4711396531e8 13004:0ed37da6f0f3
122 122
123 (defvar Info-suffix-list 123 (defvar Info-suffix-list
124 (if (eq system-type 'ms-dos) 124 (if (eq system-type 'ms-dos)
125 '( (".gz" . "gunzip") 125 '( (".gz" . "gunzip")
126 (".z" . "gunzip") 126 (".z" . "gunzip")
127 (".inf" . nil)
127 ("" . nil)) 128 ("" . nil))
128 '( (".info.Z" . "uncompress") 129 '( (".info.Z" . "uncompress")
129 (".info.Y" . "unyabba") 130 (".info.Y" . "unyabba")
130 (".info.gz" . "gunzip") 131 (".info.gz" . "gunzip")
131 (".info.z" . "gunzip") 132 (".info.z" . "gunzip")
150 (let* ((sans-exts (file-name-sans-extension filename)) 151 (let* ((sans-exts (file-name-sans-extension filename))
151 ;; How long is the extension in FILENAME. 152 ;; How long is the extension in FILENAME.
152 (ext-len (- (length filename) (length sans-exts) 1)) 153 (ext-len (- (length filename) (length sans-exts) 1))
153 ;; How many chars of that extension should we keep? 154 ;; How many chars of that extension should we keep?
154 (ext-left (max 0 (- 3 (length suffix))))) 155 (ext-left (max 0 (- 3 (length suffix)))))
156 ;; SUFFIX starts with a dot. If FILENAME already has one,
157 ;; get rid of the one in SUFFIX.
158 (or (and (zerop ext-len)
159 (not (eq (aref filename (1- (length filename))) ?.)))
160 (setq suffix (substring suffix 1)))
155 ;; Get rid of the rest of the extension, and add SUFFIX. 161 ;; Get rid of the rest of the extension, and add SUFFIX.
156 (concat (substring filename 0 (- (length filename) 162 (concat (substring filename 0 (- (length filename)
157 (- ext-len ext-left))) 163 (- ext-len ext-left)))
158 suffix)))) 164 suffix))))
159 165
178 (not (file-exists-p (info-insert-file-contents-1 184 (not (file-exists-p (info-insert-file-contents-1
179 filename (car (car tail)))))) 185 filename (car (car tail))))))
180 (setq tail (cdr tail))) 186 (setq tail (cdr tail)))
181 ;; If we found a file with a suffix, set DECODER according to the suffix 187 ;; If we found a file with a suffix, set DECODER according to the suffix
182 ;; and set FULLNAME to the file's actual name. 188 ;; and set FULLNAME to the file's actual name.
183 (setq fullname (concat filename (car (car tail))) 189 (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
184 decoder (cdr (car tail))) 190 decoder (cdr (car tail)))
185 (or tail 191 (or tail
186 (error "Can't find %s or any compressed version of it" filename))) 192 (error "Can't find %s or any compressed version of it" filename)))
187 ;; check for conflict with jka-compr 193 ;; check for conflict with jka-compr
188 (if (and (featurep 'jka-compr) 194 (if (and (featurep 'jka-compr)
192 (insert-file-contents fullname visit) 198 (insert-file-contents fullname visit)
193 (if decoder 199 (if decoder
194 (let ((buffer-read-only nil) 200 (let ((buffer-read-only nil)
195 (default-directory (or (file-name-directory fullname) 201 (default-directory (or (file-name-directory fullname)
196 default-directory))) 202 default-directory)))
197 (shell-command-on-region (point-min) (point-max) decoder t))))) 203 (call-process-region (point-min) (point-max) decoder t t)))))
198 204
199 ;;;###autoload (add-hook 'same-window-buffer-names "*info*") 205 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
200 206
201 ;;;###autoload 207 ;;;###autoload
202 (defun info (&optional file) 208 (defun info (&optional file)
262 (expand-file-name (downcase filename) (car dirs))) 268 (expand-file-name (downcase filename) (car dirs)))
263 ;; Try several variants of specified name. 269 ;; Try several variants of specified name.
264 (let ((suffix-list Info-suffix-list)) 270 (let ((suffix-list Info-suffix-list))
265 (while (and suffix-list (not found)) 271 (while (and suffix-list (not found))
266 (cond ((file-exists-p 272 (cond ((file-exists-p
267 (concat temp (car (car suffix-list)))) 273 (info-insert-file-contents-1
274 temp (car (car suffix-list))))
268 (setq found temp)) 275 (setq found temp))
269 ((file-exists-p 276 ((file-exists-p
270 (concat temp-downcase (car (car suffix-list)))) 277 (info-insert-file-contents-1
278 temp-downcase (car (car suffix-list))))
271 (setq found temp-downcase))) 279 (setq found temp-downcase)))
272 (setq suffix-list (cdr suffix-list)))) 280 (setq suffix-list (cdr suffix-list))))
273 (setq dirs (cdr dirs))))) 281 (setq dirs (cdr dirs)))))
274 (if found 282 (if found
275 (setq filename found) 283 (setq filename found)