home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / xlisp+ / xlisp+.spk / lsp / edit < prev    next >
Lisp/Scheme  |  1992-10-02  |  2KB  |  50 lines

  1. ;;;
  2. ;;; This variable is the default file to edit
  3. ;;;
  4.  
  5. (defvar *edit-file* "")
  6.  
  7. (defvar *editor* "eps")
  8.  
  9. ;;;
  10. ;;; edit a file using the specified editor
  11. ;;; if the file editted was a lisp file (.lsp) load it
  12. ;;;
  13.  
  14. ;; Two versions, the first works when position-if exists and does a better
  15. ;; job   
  16.  
  17. #+:posfcns (defmacro edit (&optional file &aux rfile)
  18.   (read-char)
  19.   (when file (setq *edit-file* (string file)))
  20.   (setq rfile (reverse *edit-file*))
  21.   (when (null (position-if #'(lambda (x) (eq x #\.))
  22.                rfile
  23.                :end 
  24.                (position-if #'(lambda (x) 
  25.                           (or (eq x #\\) (eq x #\/)))
  26.                     rfile)))
  27.     (setq *edit-file* (strcat *edit-file* ".lsp")))
  28.   (unless (system (strcat *editor* " " *edit-file*))
  29.       (error (strcat "Unable to execute: " *editor* " " *edit-file*)))
  30.   (let ((len (length *edit-file*)))
  31.        (when (and (> len 4)
  32.           (string= (string-downcase (subseq *edit-file* (- len 4)))
  33.                ".lsp"))
  34.          (list 'load *edit-file*))))
  35.  
  36. #-:posfcns (defmacro edit (&optional file)
  37.     (read-char)
  38.     (when file (setq *edit-file* (string file)))
  39.     (when (not (member #\.
  40.                (get-output-stream-list
  41.               (make-string-input-stream *edit-file*))))
  42.       (setq *edit-file* (strcat *edit-file* ".lsp")))
  43.     (unless (system (strcat *editor* " " *edit-file*))
  44.           (error (strcat "Unable to execute: " *editor* " " *edit-file*)))
  45.     (let ((len (length *edit-file*)))
  46.       (when (and (> len 4)
  47.          (string= (string-downcase (subseq *edit-file* (- len 4)))
  48.               ".lsp"))
  49.         (list 'load *edit-file*))))
  50.