Function: dired-restore-positions

dired-restore-positions is a byte-compiled function defined in dired.el.gz.

Signature

(dired-restore-positions POSITIONS)

Documentation

Restore POSITIONS saved with dired-save-positions.

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-restore-positions (positions)
  "Restore POSITIONS saved with `dired-save-positions'."
  (let* ((buf-file-pos (nth 0 positions))
	 (buffer (nth 0 buf-file-pos))
         (prevs (nth 2 positions)))
    (unless (and (nth 1 buf-file-pos)
		 (dired-goto-file (nth 1 buf-file-pos)))
      (goto-char (point-min))
      (forward-line (1- (nth 2 buf-file-pos)))
      (dired-move-to-filename))
    (dolist (win-file-pos (nth 1 positions))
      ;; Ensure that window still displays the original buffer.
      (when (eq (window-buffer (nth 0 win-file-pos)) buffer)
	(with-selected-window (nth 0 win-file-pos)
	  (unless (and (nth 1 win-file-pos)
		       (dired-goto-file (nth 1 win-file-pos)))
            (goto-char (point-min))
	    (forward-line (1- (nth 2 win-file-pos)))
	    (dired-move-to-filename)))))
    (when prevs
      (with-current-buffer buffer
        (save-excursion
          (dolist (prev prevs)
            (let ((point (nth 0 prev)))
              ;; Sanity check of the point marker.
              (when (and (markerp point)
                         (eq (marker-buffer point) buffer))
                (unless (and (nth 1 prev)
                             (dired-goto-file (nth 1 prev)))
                  (goto-char (point-min))
                  (forward-line (1- (nth 2 prev))))
                (dired-move-to-filename)
                (move-marker point (point) buffer)))))))))