From: [email-masked]
Date: Fri, 27 Jan 95 11:28:22 -0500

Hello all:

Under both OS/2 2.1 and OS/2 3.0 (Warp), I have had problems
editing CLISP .lsp files and CLISP function definitions, e.g.
#'my-func

The value I set for *editor* is "E:\\OS2\\APPS\\EPM.EXE"

In "user2.lsp" the following functions are defined:

;;; I edited 'edit-file' for this note only, in order to
;;; cut out the irrelevant clutter; this function definition
;;; shows the basic OS/2 platform code.

(defun edit-file (file)
    (execute *editor* (namestring file))
)

(defun ed (&optional arg &aux funname sym fun def)
  (if (null arg)
    (edit-file "")
    (if (or (pathnamep arg) (stringp arg))
      (edit-file arg)
      (if (and (cond ((function-name-p arg) (setq funname arg) t)
                     ((functionp arg) (function-name-p (setq funname (sys::%record-ref 

arg 0))))
                     (t nil)
               )
               (fboundp (setq sym (get-funname-symbol funname)))
               (or (setq fun (macro-function sym))
                   (setq fun (symbol-function sym))
               )
               (functionp fun)
               (or (function-name-p arg) (eql fun arg))
               (setq def (get sym 'sys::definition))
          )
        (let ((tempfile (editor-tempfile)))
          (with-open-file (f tempfile :direction :output)
            (pprint (car def) f)
            (terpri f) (terpri f)
          )
          (let ((date (file-write-date tempfile)))
            (edit-file tempfile)
            (when (> (file-write-date tempfile) date)
              (with-open-file (f tempfile :direction :input)
                (let ((*package* *package*) ; *PACKAGE* binden
                      (end-of-file "EOF")) ; einmaliges Objekt
                  (loop
                    (let ((obj (read f nil end-of-file)))
                      (when (eql obj end-of-file) (return))
                      (print (evalhook obj nil nil (cdr def)))
              ) ) ) )
              (when (compiled-function-p fun) (compile funname))
          ) )
          funname
        )
        (error-of-type 'error
          (DEUTSCH "~S ist nicht editierbar."
           ENGLISH "~S cannot be edited."
           FRANCAIS "~S ne peut pas ˆtre ‚dit‚.")
          arg
) ) ) ) )

In particular, I have observed two problems.

First, it appears that the expression (when (> (file-write-date tempfile) date)
is never true so 'funname' is simply returned and the lisp code in the
edited file is never read and compiled: thus, the net effect is no editing.

The second, and even more serious, problem is that subsequent sessions with
CLISP simply crash (when the 'ed' function is called) with an Access Violation
in one of the OS/2 system DLLs, a DLL belonging to the EPM OS/2 system
editor, I believe. That is, when the 'ed' function launches the EPM editor
via the 'execute' system function, the EPM process crashes.

In order to use the EPM external editor via the CLISP 'ed' function,
I have had to modify the 'edit-file' function definition as follows:

(defun edit-file (file)
    (shell (string-concat *editor* " " (namestring file)))
)

This version:

  (a) runs EPM synchronously (thereby allowing the 'ed' function
      to read and compile the edited lisp code in the file
      'lisptemp.lsp')

  (b) does not crash EPM

By the way, if I attempt to use to other OS/2 system editor,
E.EXE, 'edit-file' returns NIL and it appears to me that this
editor cannot be successfully run either.

To sum up, I assume that their must be:

    1. a problem with the CLISP 'execute' function
    2. a problem with the looping timestamp-checking
       code in the 'ed' function ?

==========================================================
Could those in the know please investigate these problems?
Have others successfully used the EPM (or even E) OS/2
system editors in conjunction with CLISP ?
==========================================================

I am running the August 1994 version of CLISP for OS/2.
The only possibly relevant modification that I have made
to CLISP is that I have CLISP read the CONTROL-Z character
as a SPACE, otherwise the CLISP 'load' function craps out with
an error (here I am following a solution recommended in the
CLISP archive).

==========================================================
    Please respond...

               Chris Graham
               VisualAge Software Consulting
==========================================================