Function: dired-goto-file-1

dired-goto-file-1 is a byte-compiled function defined in dired.el.gz.

Signature

(dired-goto-file-1 FILE FULL-NAME LIMIT)

Documentation

Advance to the Dired listing labeled by FILE; return its position.

Return nil if the listing is not found. If FILE contains characters that would not appear in a Dired buffer, search using the quoted forms of those characters.

FULL-NAME specifies the actual file name the listing must have, as returned by dired-get-filename. LIMIT is the search limit.

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-goto-file-1 (file full-name limit)
  "Advance to the Dired listing labeled by FILE; return its position.
Return nil if the listing is not found.  If FILE contains
characters that would not appear in a Dired buffer, search using
the quoted forms of those characters.

FULL-NAME specifies the actual file name the listing must have,
as returned by `dired-get-filename'.  LIMIT is the search limit."
  (let (str)
    (setq str (string-replace "\^m" "\\^m"  file))
    (setq str (string-replace "\\" "\\\\" str))
    (and (dired-switches-escape-p dired-actual-switches)
	 (string-match-p "[ \t\n]" str)
	 ;; FIXME: to fix this for embedded control characters etc, we
	 ;; should escape everything that `ls -b' does.
	 (setq str (string-replace " " "\\ "  str)
	       str (string-replace "\t" "\\t" str)
	       str (string-replace "\n" "\\n" str)))
    (let ((found nil)
	  ;; filenames are preceded by SPC, this makes the search faster
	  ;; (e.g. for the filename "-").
	  (search-string (concat " " str)))
      (while (and (not found)
		  (search-forward search-string limit 'move))
	;; Check that we are in the right place.  Match could have
	;; BASE just as initial substring or in permission bits etc.
	(if (equal full-name (dired-get-filename nil t))
	    (setq found (dired-move-to-filename))
	  (forward-line 1)))
      found)))