Subject: Re: Use of .lisp Extension

From: [email-masked] (Don Cohen)
Date: Wed, 11 Jan 95 16:00:06 -0800

My understanding is that this problem has recently been solved.
That is to say, you can avoid solving the problem yourself IF you
have a new enough version.  In particular, if the version is new
enough to have *source-file-types* defined, just do:

 (push (make-pathname :type "lisp") *source-file-types*)

Otherwise, the fix involves copying and modifying the source of load.
Here's my version:

#+clisp ; redefine load to allow different extensions to be found
(in-package :system)
#+clisp
(progn
 (defvar *load-types*
   (loop for x in '("lisp" "lsp" "fas") collect (make-pathname :type x)))

 (defun new-load (filename
             &key (verbose *load-verbose*) (print *load-print*)
	     (if-does-not-exist t) (echo *load-echo*) (compiling nil))
  (let ((stream
          (if (streamp filename)
            filename
            (or (open (setq filename (pathname filename))
                  :direction :input-immutable
                  :element-type 'string-char
                  :if-does-not-exist nil
                )
                ; Datei mit genau diesem Namen nicht vorhanden.
                ; Suche unter den Dateien mit demselben Namen und den
                ; Extensions "LSP", "FAS" die neueste:
                (let ((present-files
                        (search-file filename
				     ; '(#".lsp" #".fas")
				     *load-types*)))
                  (if (endp present-files)
                    nil
                    (open (setq filename (first present-files))
                          :direction :input-immutable
                          :element-type 'string-char  )) ) )   ) ) )
    (if stream
      (let ((input-stream
              (if echo
                (make-echo-stream stream *standard-output*)
                stream
            ) )
            ; :verbose, :print und :echo wirken nicht rekursiv - dazu
            ; hat man ja gerade die Special-Variablen *load-verbose* etc.
            ;(*load-verbose* verbose)
            ;(*load-print* print)
            ;(*load-echo* echo)
            (*load-pathname* (if (pathnamep filename) filename nil))
            (*load-truename* (if (pathnamep filename) (truename filename) nil))
            (*package* *package*) ; *PACKAGE* binden
            (*readtable* *readtable*) ; *READTABLE* binden
            (end-of-file "EOF")) ; einmaliges Objekt
        (when verbose
          (fresh-line)
          (write-string (DEUTSCH ";; Datei "
                         ENGLISH ";; Loading file "
                         FRANCAIS ";; Chargement du fichier ") )
          (princ filename)
          (write-string (DEUTSCH " wird geladen..."
                         ENGLISH " ..."
                         FRANCAIS " ...") ) )
        (block nil
          (unwind-protect
            (tagbody weiter
              (when echo (fresh-line))
              (let ((obj (read input-stream nil end-of-file)))
                (when (eql obj end-of-file) (return-from nil))
                (setq obj
                  (multiple-value-list
                    (cond ((compiled-function-p obj) (funcall obj))
                          (compiling (funcall (compile-form obj nil nil nil nil nil)))
                          (t (eval obj))  ) ) )
                (when print (when obj (print (first obj)))) )
              (go weiter) )
            (close stream) (close input-stream) ) )
        (when verbose
          (fresh-line)
          (write-string (DEUTSCH ";; Datei "
                         ENGLISH ";; Loading of file "
                         FRANCAIS ";; Le fichier ") )
          (princ filename)
          (write-string (DEUTSCH " ist geladen."
                         ENGLISH " is finished."
                         FRANCAIS " est chargi.") ) )
        t )
      (if if-does-not-exist
        (error-of-type 'file-error
          :pathname filename
          (DEUTSCH "Ein Datei mit Namen ~A gibt es nicht."
           ENGLISH "A file with name ~A does not exist"
           FRANCAIS "Il n'existe pas de fichier de nom ~A.")
          filename )
        nil )) ) )
 (setf (symbol-function 'load) (symbol-function 'new-load)))

---

From: haible (Bruno Haible)
Date: Thu, 12 Jan 95 16:47:20 +0100

[Forwarded from Jeff Bishop <[email-masked]>.]

> (push (make-pathname :type "lisp") *source-file-types*)

That's encouraging, but why not make future versions of CLISP handle the
.lisp case automatically?  It might be a good idea to throw in .lis as well,
since
that is all that will be left of the filename when a .lisp file is copied to
a FAT drive.
Jeff Bishop
Department of Linguistics
BIRL (BIRL Industrial Research Laboratory)

---

From: haible (Bruno Haible)
Date: Thu, 12 Jan 95 17:00:54 +0100

Ray Liere <[email-masked]> says:

> Does anyone know of a relatively
> easy way to have clisp recognize ".lisp" as well as ".lsp" as legal?

As has already been pointed out, the following does magic:

   (push '#".lisp" sys::*source-file-types*)

> I am currently using the method of simply renaming all of the sources,
> but would like to avoid that in the future if possible.

Under Unix, renaming is not a big pain:
#!/bin/sh
for f in `find . -name '*.lisp' -print`; do ln $f `basename $f .lisp`.lsp; done

> .lisp case automatically?

Because I want CLISP to support its features across platforms, and I can't
support the .lisp extension on DOS.

> It might be a good idea to throw in .lis as well, since that is all
> that will be left of the filename when a .lisp file is copied to a FAT drive.

This would be dangerous, since ".lis" is the extension of the listing files
produced by  (compile-file ... :listing t).

                    Bruno Haible
                    [email-masked]