Function: Info-find-file

Info-find-file is a byte-compiled function defined in info.el.gz.

Signature

(Info-find-file FILENAME &optional NOERROR NO-POP-TO-DIR)

Documentation

Return expanded FILENAME, or t if FILENAME is "dir".

Optional second argument NOERROR, if t, means if file is not found just return nil (no error).

If NO-POP-TO-DIR, don't try to pop to the info buffer if we can't find a node.

Source Code

;; Defined in /usr/src/emacs/lisp/info.el.gz
(defun Info-find-file (filename &optional noerror no-pop-to-dir)
  "Return expanded FILENAME, or t if FILENAME is \"dir\".
Optional second argument NOERROR, if t, means if file is not found
just return nil (no error).

If NO-POP-TO-DIR, don't try to pop to the info buffer if we can't
find a node."
  (info-initialize)
  ;; Convert filename to lower case if not found as specified.
  ;; Expand it.
  (cond
   ((Info-virtual-call
     (Info-virtual-fun 'find-file filename nil)
     filename noerror))
   ((stringp filename)
    (let (temp temp-downcase found)
      (setq filename (substitute-in-file-name filename))
      (let ((dirs (if (string-match "^\\./" filename)
		      ;; If specified name starts with `./'
		      ;; then just try current directory.
		      '("./")
		    (if (file-name-absolute-p filename)
			;; No point in searching for an
			;; absolute file name
			'(nil)
		      (if Info-additional-directory-list
			  (append Info-directory-list
				  Info-additional-directory-list)
			Info-directory-list)))))
	;; Fall back on the installation directory if we can't find
	;; the info node anywhere else.
	(when installation-directory
	  (setq dirs (append dirs (list (expand-file-name
					 "info" installation-directory)))))
	;; Search the directory list for file FILENAME.
	(while (and dirs (not found))
	  (setq temp (expand-file-name filename (car dirs)))
	  (setq temp-downcase
		(expand-file-name (downcase filename) (car dirs)))
	  ;; Try several variants of specified name.
	  (let ((suffix-list Info-suffix-list)
		(lfn (if (fboundp 'msdos-long-file-names)
			 (msdos-long-file-names)
		       t)))
	    (while (and suffix-list (not found))
	      (cond ((info-file-exists-p
		      (info-insert-file-contents-1
		       temp (car (car suffix-list)) lfn))
		     (setq found temp))
		    ((info-file-exists-p
		      (info-insert-file-contents-1
		       temp-downcase (car (car suffix-list)) lfn))
		     (setq found temp-downcase))
		    ((and (fboundp 'msdos-long-file-names)
			  lfn
			  (info-file-exists-p
			   (info-insert-file-contents-1
			    temp (car (car suffix-list)) nil)))
		     (setq found temp)))
	      (setq suffix-list (cdr suffix-list))))
	  (setq dirs (cdr dirs))))
      (if found
	  (setq filename found)
	(if noerror
	    (setq filename nil)
	  ;; If there is no previous Info file, go to the directory.
	  (when (and (not no-pop-to-dir)
                     (not Info-current-file))
	    (Info-directory))
          (user-error "Info file `%s' does not exist; consider installing it"
                      filename)))
      filename))))