comparison lisp/bookmark.el @ 45673:fc6d3747add1

* bookmark.el (bookmark-file-or-variation-thereof): Just use Info-suffix-list, as suggested by Stefan Monnier.
author Karl Fogel <kfogel@red-bean.com>
date Sat, 08 Jun 2002 03:33:09 +0000
parents 0f4506820432
children 0ddf92221535
comparison
equal deleted inserted replaced
45672:1f957476e757 45673:fc6d3747add1
1070 ;; show it in a buffer. 1070 ;; show it in a buffer.
1071 (bookmark-show-annotation bookmark))))) 1071 (bookmark-show-annotation bookmark)))))
1072 1072
1073 1073
1074 (defun bookmark-file-or-variation-thereof (file) 1074 (defun bookmark-file-or-variation-thereof (file)
1075 "Return FILE (a string) if it exists in any reasonable variation, else nil. 1075 "Return FILE if it exists, or return the first variation based on
1076 Reasonable variations are FILE.gz, FILE.Z, FILE.info, FILE.info.gz, etc." 1076 `Info-suffix-list' that exists, else return nil."
1077 (cond 1077 (if (file-exists-p file)
1078 ((file-exists-p file) file) 1078 file
1079 ((file-exists-p (concat file ".Z")) (concat file ".Z")) 1079 (require 'info) ; ensure Info-suffix-list is bound
1080 ((file-exists-p (concat file ".gz")) (concat file ".gz")) 1080 (catch 'found
1081 ((file-exists-p (concat file ".z")) (concat file ".z")) 1081 (mapc (lambda (elt)
1082 ((file-exists-p (concat file ".info")) (concat file ".info")) 1082 (let ((suffixed-file (concat file (car elt))))
1083 ((file-exists-p (concat file ".info.gz")) (concat file ".info.gz")) 1083 (if (file-exists-p suffixed-file)
1084 ((file-exists-p (concat file ".info.Z")) (concat file ".info.Z")) 1084 (throw 'found suffixed-file))))
1085 ((file-exists-p (concat file ".info.z")) (concat file ".info.z")) 1085 Info-suffix-list)
1086 ((vc-backend file) file) ; maybe VC has it? 1086 nil)))
1087 (t nil)))
1088 1087
1089 1088
1090 (defun bookmark-jump-noselect (str) 1089 (defun bookmark-jump-noselect (str)
1091 ;; a leetle helper for bookmark-jump :-) 1090 ;; a leetle helper for bookmark-jump :-)
1092 ;; returns (BUFFER . POINT) 1091 ;; returns (BUFFER . POINT)