Function: eshell-write-last-dir-ring

eshell-write-last-dir-ring is a byte-compiled function defined in em-dirs.el.gz.

Signature

(eshell-write-last-dir-ring)

Documentation

Write the buffer's eshell-last-dir-ring to a history file.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-dirs.el.gz
(defun eshell-write-last-dir-ring ()
  "Write the buffer's `eshell-last-dir-ring' to a history file."
  (let* ((file eshell-last-dir-ring-file-name)
	 (resolved-file (if (stringp file) (file-truename file))))
    (cond
     ((or (null file)
	  (equal file "")
	  (null eshell-last-dir-ring)
	  (ring-empty-p eshell-last-dir-ring))
      nil)
     ((not (file-writable-p resolved-file))
      (message "Cannot write last-dir-ring file %s" resolved-file))
     (t
      (let* ((ring eshell-last-dir-ring)
	     (index (ring-length ring)))
	(with-temp-buffer
	  (while (> index 0)
	    (setq index (1- index))
	    (insert (ring-ref ring index) ?\n))
	  (insert (eshell/pwd) ?\n)
	  (eshell-with-private-file-modes
	   (write-region (point-min) (point-max) resolved-file nil
			 'no-message))))))))