issue with fi-stella.el with proposed patch
"Robert P. Goldman" <[email protected]>
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
I was just working on a CL program that would interface with
PowerLoom, and encountered some problems with my development
environment. When I try to find definitions for a CL function, the
Allegro ELI environment tosses an error. AFAICT, the problem seems to
be that no matter whether I'm trying to find a stella definition or
not, the fi::show-found-definition advice in fi-stella.el steps in and
turns a perfectly servicable filename returned by the Allegro lisp
environment into a nonsensical logical pathname.
The problem is that as far as I can tell, fi::show-found-definition
will invoke stella-file-name *whether or not you have stella loaded*,
once you load fi-stella.el. I.e., if I load fi-stella.el in my .emacs
file, then go on to just work with CL code, then when I use meta-. it
will crash ELI because the "PL:" logical pathname host is undefined.
This means that the stella ELI development can't coexist with vanilla
CL environment.
I believe it would be more elegant if one had some way of stashing
away information about whether a given definition is Stella or
Lisp-native, but I don't know how to do that. In the absence of this,
here's a proposed patch to fi-stella that makes it coexist better:
;;; Wrap these two forms to evaluate in IGNORE-ERRORS so that they
;;; just return NIL, instead of crashing the emacs interface:
(defvar fi-stella-lisp-directory-form
;; Form to evaluate to determine the directory where Lisp translations of
;; STELLA files are stored. We can't evaluate this at initialization time,
;; since STELLA might not yet be up and running.
;; Not sure how to do this right, since the Lisp translations could really
;; go anywhere dependent on the pathname definitions for a particular system.
;; Maybe these should be lists, or should we store the STELLA source file in
;; the Lisp translation instead?
'(fi:eval-in-lisp
"(cl:ignore-errors (CL:namestring (CL:translate-logical-pathname \"PL:native;lisp;\")))"))
(defvar fi-stella-sources-directory-form
;; Form to evaluate to determine the directory where STELLA sources
;; are stored.
'(fi:eval-in-lisp
"(cl:ignore-errors (CL:namestring (CL:translate-logical-pathname \"PL:sources;\")))"))
;;; Modify STELLA-FILE-NAME to give up if it can't find the
;;; stella-lisp-directory or stella-sources-directory. See the catch
;;; and throw forms...
(defun stella-file-name (lisp-file-name)
;; Return the Stella source file of `lisp-file-name' if it exists.
(catch 'no-logical-pathname
(let* ((lisp-name-end
(and (stringp lisp-file-name)
(or (string-match "\\.lisp$" lisp-file-name)
(string-match "\\.slisp$" lisp-file-name)
(string-match "\\.vslisp$" lisp-file-name))))
(lisp-file-directory
(file-name-directory lisp-file-name))
(basename-sans-extension
(file-name-sans-extension (file-name-nondirectory lisp-file-name)))
(lisp-directory (or (eval fi-stella-lisp-directory-form)
(throw 'no-logical-pathname nil)))
(sources-directory (or (eval fi-stella-sources-directory-form)
(throw 'no-logical-pathname nil)))
(stella-file-name nil)
;; Directories to try to find the STELLA source:
(directories
(list lisp-file-directory
(concat sources-directory
(substring lisp-file-directory
(length lisp-directory))))))
(cond
(lisp-name-end
(while directories
(setq stella-file-name
(concat (car directories) basename-sans-extension ".ste"))
(if (file-exists-p stella-file-name)
(setq directories nil)
(setq stella-file-name nil)
(setq directories (cdr directories))))
stella-file-name)))))