Function: try-complete-file-name-partially

try-complete-file-name-partially is a byte-compiled function defined in hippie-exp.el.gz.

Signature

(try-complete-file-name-partially OLD)

Documentation

Try to complete text as a file name, as many characters as unique.

The argument OLD has to be nil the first call of this function. It returns t if a unique, possibly partial, completion is found, nil otherwise.

Source Code

;; Defined in /usr/src/emacs/lisp/hippie-exp.el.gz
(defun try-complete-file-name-partially (old)
  "Try to complete text as a file name, as many characters as unique.
The argument OLD has to be nil the first call of this function.  It
returns t if a unique, possibly partial, completion is found, nil
otherwise."
  (let ((expansion ()))
    (if (not old)
	(progn
	  (he-init-string (he-file-name-beg) (point))
	  (let ((name-part (file-name-nondirectory he-search-string))
		(dir-part (expand-file-name (or (file-name-directory
						 he-search-string) ""))))
	    (if (and (not (equal he-search-string ""))
		     (file-directory-p dir-part))
		(setq expansion (file-name-completion name-part
						      dir-part)))
	    (if (or (eq expansion t)
		    (string= expansion name-part)
		    (he-string-member expansion he-tried-table))
		(setq expansion ())))))

    (if (not expansion)
	(progn
	  (if old (he-reset-string))
	  ())
	(let ((filename (he-concat-directory-file-name
			 (file-name-directory he-search-string)
			 expansion)))
	  (he-substitute-string filename)
	  (setq he-tried-table (cons expansion (cdr he-tried-table)))
	  t))))