Function: ffap-file-exists-string

ffap-file-exists-string is a byte-compiled function defined in ffap.el.gz.

Signature

(ffap-file-exists-string FILE &optional NOMODIFY)

Documentation

Return FILE (maybe modified) if the file exists, else nil.

When using jka-compr (a.k.a. auto-compression-mode(var)/auto-compression-mode(fun)), the returned name may have a suffix added from ffap-compression-suffixes. The optional NOMODIFY argument suppresses the extra search.

Source Code

;; Defined in /usr/src/emacs/lisp/ffap.el.gz
(defun ffap-file-exists-string (file &optional nomodify)
  ;; Early jka-compr versions modified file-exists-p to return the
  ;; filename, maybe modified by adding a suffix like ".gz".  That
  ;; broke the interface of file-exists-p, so it was later dropped.
  ;; Here we document and simulate the old behavior.
  "Return FILE (maybe modified) if the file exists, else nil.
When using jka-compr (a.k.a. `auto-compression-mode'), the returned
name may have a suffix added from `ffap-compression-suffixes'.
The optional NOMODIFY argument suppresses the extra search."
  (cond
   ((or (not file)			; quietly reject nil
	(zerop (length file)))		; and also ""
    nil)
   ((file-exists-p file) file)		; try unmodified first
   ;; three reasons to suppress search:
   (nomodify nil)
   ((not (rassq 'jka-compr-handler file-name-handler-alist)) nil)
   ((member (file-name-extension file t) ffap-compression-suffixes) nil)
   (t					; ok, do the search
    (let ((list ffap-compression-suffixes) try ret)
      (while list
	(if (file-exists-p (setq try (concat file (car list))))
	    (setq ret try list nil)
	  (setq list (cdr list))))
      ret))))