Function: speedbar-goto-this-file

speedbar-goto-this-file is a byte-compiled function defined in speedbar.el.gz.

Signature

(speedbar-goto-this-file FILE)

Documentation

If FILE is displayed, go to this line and return t.

Otherwise do not move and return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/speedbar.el.gz
(defun speedbar-goto-this-file (file)
  "If FILE is displayed, go to this line and return t.
Otherwise do not move and return nil."
  (let ((directory (substring (file-name-directory (expand-file-name file))
			 (length (expand-file-name default-directory))))
	(dest (point)))
    (save-match-data
      (goto-char (point-min))
      ;; scan all the directories
      (while (and directory (not (eq directory t)))
	(if (string-match "^[/\\]?\\([^/\\]+\\)" directory)
	    (let ((pp (match-string 1 directory)))
	      (if (save-match-data
		    (re-search-forward (concat "> " (regexp-quote pp) "$")
				       nil t))
		  (setq directory (substring directory (match-end 1)))
		(setq directory nil)))
	  (setq directory t)))
      ;; find the file part
      (if (or (not directory) (string= (file-name-nondirectory file) ""))
	  ;; only had a dir part
	  (if directory
	      (progn
		(speedbar-position-cursor-on-line)
		t)
	    (goto-char dest) nil)
	;; find the file part
	(let ((nd (file-name-nondirectory file)))
	  (if (re-search-forward
	       (concat "] \\(" (regexp-quote nd)
		       "\\)\\(" speedbar-indicator-regex "\\)$")
	       nil t)
	      (progn
		(speedbar-position-cursor-on-line)
		t)
	    (goto-char dest)
	    nil))))))