Function: eshell-dirs-initialize

eshell-dirs-initialize is a byte-compiled function defined in em-dirs.el.gz.

Signature

(eshell-dirs-initialize)

Documentation

Initialize the builtin functions for Eshell.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-dirs.el.gz
;;; Functions:

(defun eshell-dirs-initialize ()    ;Called from `eshell-mode' via intern-soft!
  "Initialize the builtin functions for Eshell."
  (setq-local eshell-variable-aliases-list
	(append
	 eshell-variable-aliases-list
         `(("-" ,(lambda (indices)
		   (if (not indices)
		       (unless (ring-empty-p eshell-last-dir-ring)
			 (expand-file-name
			  (ring-ref eshell-last-dir-ring 0)))
		     (expand-file-name
		      (eshell-apply-indices eshell-last-dir-ring indices)))))
	   ("+" "PWD")
	   ("PWD" ,(lambda (_indices)
		     (expand-file-name (eshell/pwd)))
            t)
	   ("OLDPWD" ,(lambda (_indices)
                        (unless (ring-empty-p eshell-last-dir-ring)
			  (expand-file-name
			   (ring-ref eshell-last-dir-ring 0))))
            t)
           ("INSIDE_EMACS" eshell-inside-emacs
            t))))

  (when eshell-cd-on-directory
    (setq-local eshell-interpreter-alist
                (cons (cons (lambda (file _args)
                              (eshell-lone-directory-p file))
                            'eshell-dirs-substitute-cd)
                      eshell-interpreter-alist)))

  (add-hook 'eshell-parse-argument-hook
	    #'eshell-parse-user-reference nil t)
  (if (eshell-under-windows-p)
      (add-hook 'eshell-parse-argument-hook
		#'eshell-parse-drive-letter nil t))

  (when (eshell-using-module 'eshell-cmpl)
    (add-hook 'pcomplete-try-first-hook
	      #'eshell-complete-user-reference nil t))

  (make-local-variable 'eshell-dirstack)
  (make-local-variable 'eshell-last-dir-ring)

  (if eshell-last-dir-ring-file-name
      (eshell-read-last-dir-ring))
  (unless eshell-last-dir-ring
    (setq eshell-last-dir-ring (make-ring eshell-last-dir-ring-size)))

  (add-hook 'eshell-exit-hook #'eshell-write-last-dir-ring nil t)

  (add-hook 'kill-emacs-query-functions #'eshell-save-some-last-dir))