Function: dun-cd
dun-cd is a byte-compiled function defined in dunnet.el.gz.
Signature
(dun-cd ARGS)
Source Code
;; Defined in /usr/src/emacs/lisp/play/dunnet.el.gz
(defun dun-cd (args)
(if (not (car args))
(dun-mprincl "Usage: cd <path>")
(let ((tcdpath dun-cdpath)
(tcdroom dun-cdroom)
path-elements)
(setq dun-badcd nil)
(condition-case nil
(setq path-elements (dun-get-path (car args) nil))
(error (dun-mprincl "Invalid path")
(setq dun-badcd t)))
(dolist (pe path-elements)
(when (and (not dun-badcd)
(not (string= pe ".")))
(cond
((string= pe "..")
(cond
((> tcdroom 0) ;In a room
(setq tcdpath "/rooms")
(setq tcdroom -2))
((memq tcdroom '(-2 -3 -4)) ; In /rooms,/usr,root
(setq tcdpath "/")
(setq tcdroom -3))
((= tcdroom -10)
(setq tcdpath "/usr")
(setq tcdroom -4))))
((string= pe "/")
(setq tcdpath "/")
(setq tcdroom -3))
((= tcdroom -4)
(if (not (string= pe "toukmond"))
(dun-nosuchdir)
(setq tcdpath "/usr/toukmond")
(setq tcdroom -10)))
((or (= tcdroom -10) (> tcdroom 0)) (dun-nosuchdir))
((= tcdroom -3)
(cond
((string= pe "rooms")
(setq tcdpath "/rooms")
(setq tcdroom -2))
((string= pe "usr")
(setq tcdpath "/usr")
(setq tcdroom -4))
(t (dun-nosuchdir))))
((= tcdroom -2)
(let (room-check)
(dolist (x dun-visited)
(setq room-check (nth x dun-room-shorts))
(when (string= room-check pe)
(setq tcdpath (concat "/rooms/" room-check))
(setq tcdroom x))))
(when (= tcdroom -2)
(dun-nosuchdir))))))
(if dun-badcd
-2
(setq dun-cdpath tcdpath)
(setq dun-cdroom tcdroom)
0))))