changeset 6566:248eede22658

(Info-suffix-list): Put empty string last. (info-insert-file-contents): Allow filename to already be suffixed.
author Karl Heuer <kwzh@gnu.org>
date Tue, 29 Mar 1994 01:39:51 +0000
parents 97cde7ba7bcb
children baf8fe0c51e3
files lisp/info.el
diffstat 1 files changed, 31 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/info.el	Tue Mar 29 00:57:07 1994 +0000
+++ b/lisp/info.el	Tue Mar 29 01:39:51 1994 +0000
@@ -94,39 +94,47 @@
 (defvar Info-standalone nil
   "Non-nil if Emacs was started solely as an Info browser.")
 
-(defvar Info-suffix-list '( (".info"    . nil)
-			    (""         . nil)
+(defvar Info-suffix-list '( (".info.Z"  . "uncompress")
+			    (".info.Y"  . "unyabba")
+			    (".info.gz" . "gunzip")
+			    (".info.z"  . "gunzip")
+			    (".info"    . nil)
 			    (".Z"       . "uncompress")
 			    (".Y"       . "unyabba")
 			    (".gz"      . "gunzip")
 			    (".z"       . "gunzip")
-			    (".info.Z"  . "uncompress")
-			    (".info.Y"  . "unyabba")
-			    (".info.gz" . "gunzip")
-			    (".info.z"  . "gunzip"))
+			    (""         . nil))
   "List of file name suffixes and associated decoding commands.
 Each entry should be (SUFFIX . STRING); the file is given to
-the command as standard input.  If STRING is nil, no decoding is done.")
+the command as standard input.  If STRING is nil, no decoding is done.
+Because the SUFFIXes are tried in order, the empty string should
+be last in the list.")
 
 (defun info-insert-file-contents (filename &optional visit)
   "Insert the contents of an info file in the current buffer.
 Do the right thing if the file has been compressed or zipped."
-  (if (null (catch 'ok
-	      (mapcar
-	       (function
-		(lambda (x)
-		  (let ((compressed (concat filename (car x))))
-		    (if (file-exists-p compressed)
-			(progn
-			  (insert-file-contents compressed visit)
-			  (if (cdr x)
-			      (let ((buffer-read-only nil))
-				(shell-command-on-region
-				 (point-min) (point-max) (cdr x) t)))
-			  (throw 'ok t))))))
-	       Info-suffix-list)
-	      nil))
-      (error "Can't find %s or any compressed version of it!" filename)))
+  (let ((tail Info-suffix-list)
+	fullname decoder)
+    (if (file-exists-p filename)
+	(progn
+	  (while (and tail
+		      (not (string-match
+			    (concat (regexp-quote (car (car tail))) "$")
+			    filename)))
+	    (setq tail (cdr tail)))
+	  (setq fullname filename
+		decoder (cdr (car tail))))
+      (while (and tail
+		  (not (file-exists-p (concat filename (car (car tail))))))
+	(setq tail (cdr tail)))
+      (setq fullname (concat filename (car (car tail)))
+	    decoder (cdr (car tail)))
+      (or tail
+	  (error "Can't find %s or any compressed version of it!" filename)))
+    (insert-file-contents fullname visit)
+    (if decoder
+	(let ((buffer-read-only nil))
+	  (shell-command-on-region (point-min) (point-max) decoder t)))))
 
 ;;;###autoload
 (defun info (&optional file)