home *** CD-ROM | disk | FTP | other *** search
- ; dirlib.l - Copyright (c) 1984 by David Morein
- ; this file contains a library of directory functions for unxlisp.
- ;
- ; note - this is an initialization file, see the manual for more info.
- ;
- (status dir_prefix_flag t) ;set the colon prefix flag to T
- (status control_c_hook '/sys/const/control_c_label) ;set the ^C hook
- ;
- ;
- ; global functions:
- ;
- (global
- 'add-to-path
- 'dir
- 'dirq
- 'getpath
- 'globalp
- 'localp
- 'local
- 'pd
- 'pdq
- 'popd
- 'poppath
- 'pushpath
- 'remove-from-path
- 'rmdir
- 'rmdirq
- 'setpath
- 'toplevel)
- ;
- ; dirq - lists a directory, quoting its argument.
- (def dirq (nlambda (&optional (oblist nil))
- (dir oblist)))
- ;
- ; dir - lists a directory.
- ;
- (defun dir (&optional (oblist nil))
- (cond
- ((null oblist) (eval (status current_dir)))
- (t
- (cond
- ((dirp oblist) (eval oblist))
- (t (break "***> DIR or DIRQ: arg not a directory"))))))
- ;
- ;
- ; cdstr - gets the current directory encoded as a string
- ;
- (defun cdstr ()
- (pathstr (status current_dir)))
- ;
- ;
- ; pd - (stands for "push directory")
- ; changes the current directory and
- ; saves the current one on a stack.
- ;
- (defun pd (newdir)
- (pdq newdir))
- ;
- ;
- ; pdq - same as pd except that it quotes its argument
- ;
- (def pdq (nlambda (newdir)
- (progn
- ;
- ;save current directory.
- ;
- (pushprop 'directory (status current_dir) 'dirstack)
- ;
- ;change to new directory.
- ;
- (mcd newdir)
- t)))
- ;
- ;
- ; popd - (stands for "pop directory")
- ; returns to the previous directory
- ;
- (defun popd ()
- (progn
- (cd (get 'directory 'dirstack))
- (popprop 'directory 'dirstack)))
- ;
- ;
- ; setpath - sets the reader's search path
- ;
- (defun setpath (x)
- (status reader_search_path x))
- ;
- ;
- ; getpath - retrieves the reader's search path
- ;
- (defun getpath ()
- (status reader_search_path))
- ;
- ;
- ; remove-from-path - removes a specified directory from
- ; the reader's search path.
- ;
- (defun remove-from-path (x)
- (cond
- ((dirp x)
- (status reader_search_path (delete x (status reader_search_path))))
- (t
- (err "***> REMOVE-FROM-PATH: arg not a directory."))))
- ;
- ;
- (def rmdirq (nlambda (x)
- (rmdir x)))
- ;
- (defun rmdir (x)
- (cond
- ((dirp x)
- (progn
- (remove-from-path x)
- (srmdir x)))
- (t
- (err "***> RMDIR: arg not a directory."))))
- ;
- ;
- ; add-to-path - adds a directory to the reader's search path
- ; if it is not already on it.
- ;
- (defun add-to-path (x)
- (cond
- ((member x (getpath)) (getpath))
- (t (pushpath x))))
- ;
- ;
- ; pushpath - pushes a directory onto the front of
- ; the reader-search-path.
- ;
- (defun pushpath (x)
- (cond
- ((dirp x)
- (status reader_search_path (cons x (status reader_search_path))))
- (t
- (err "***> PUSHPATH: arg not a directory."))))
- ;
- ;
- ; poppath - pops a directory off the reader-search-path
- ;
- (def poppath (nlambda ()
- (status reader_search_path (cdr (status reader_search_path)))))
- ;
- ;
- ; toplevel - user-defined top-level
- ;
- (def toplevel (nlambda (&aux e)
- (catch ('?*toplevel*? 'control_c_label)
- (progn
- (outprompt)
- (setq e (read))
- (prin1 (eval e))
- ))))
- ;
- ;
- ; outprompt - outputs a prompt
- ;
- (def outprompt (nlambda ()
- (progn
- (terpri)
- (prntflp (status current_dir)) ;print current directory
- (princ "->")
- t)))
- ;
- ;
- ; set the system prompt hook:
- ;
- (status top_level_hook 'toplevel)
- ;
- ; note - the following functions are hacks until
- ; bitwise logical functions are implemented:
- ;
- ; globalp - returns T iff its arg is a global symbol:
- ;
- (defun globalp (x)
- (> (getmode x) 0))
- ;
- ;
- ; localp - returns T iff its arg is a local symbol:
- ;
- (defun localp (x)
- (not (globalp x)))
- ;
- ;
- ; local - makes its list of args local
- ;
- (defun local (&rest x)
- (mapcar 'auxlocal x))
- ;
- ;
- ; auxlocal - clears the mode bits associated with a symbol
- ;
- (defun auxlocal (x)
- (setmode x 0x0000))
- ;
- ;
- ; turn on the parenthesis counting flag:
- ;
- (status pcount_flag t)
- ;
- ;
- ; *************************** end of dirlib.l *****************************