Michael,
On 12/23/05, Michael Sperber <sperber(a)informatik.uni-tuebingen.de> wrote:
I can't find much fault with it, except for the code and work
duplication in between `paths-find-emacs-root' and your
`paths-find-potential-package-root'. My suggestion would be to rename
`paths-find-emacs-root' to `paths-find-invocation-roots' and have it
return a list instead of a single string. Approximately like so
(untested):
(defun paths-find-emacs-root (invocation-directory invocation-name)
"Find the run-time root of XEmacs.
INVOCATION-DIRECTORY is a directory containing the XEmacs executable.
INVOCATION-NAME is the name of the executable itself."
(let* ((executable-file-name (paths-chase-symlink
(concat invocation-directory
invocation-name)))
(executable-directory (file-name-directory executable-file-name))
(maybe-root-1 (file-name-as-directory
(paths-construct-path '("..")
executable-directory)))
(maybe-root-2 (file-name-as-directory
(paths-construct-path '(".." "..")
executable-directory)))
(maybe-root-3 (file-name-as-directory
(paths-construct-path '(".." "..")
executable-directory)))
(maybe-root-4 (file-name-as-directory
(paths-construct-path '(".." ".."
"..") executable-directory))))
(paths-filter #'paths-emacs-root-p
(list maybe-root-1 maybe-root-2 maybe-root-3 maybe-root-4))))
My intuition is that maybe-root-3 and -4 are probably a bad idea to
include under Unix, but we can sort that out once things are working
for you.
Thanks for your help. I should have mentioned that, based on your
earlier suggestions I had previously tried to make
`paths-find-emacs-root' return a list. At that time, I came across an
error like this one during dumping:
Loading e:\acs\software\src\xemacs-21.4-2005-12-23\lisp\dump-paths.el...***
Error in XEmacs initialization
(wrong-type-argument stringp
("e:\\acs\\software\\src\\xemacs-21.4-2005-12-23\\"))
*** Backtrace
really-early-error-handler((wrong-type-argument stringp
("e:\\acs\\software\\src\\xemacs-21.4-2005-12-23\\")))
file-name-as-directory(("e:\\acs\\software\\src\\xemacs-21.4-2005-12-23\\"))
(concat (file-name-as-directory root) suffix base)
(expand-file-name (concat (file-name-as-directory root) suffix base))
(file-name-as-directory (expand-file-name (concat ... suffix base)))
# bind (base suffix root)
paths-construct-emacs-directory(("e:\\acs\\software\\src\\xemacs-21.4-2005-12-23\\")
"lib\\xemacs-21.4.18\\" "lisp")
(let ((path ...)) (if (paths-file-readable-directory-p path) (throw
... path)))
# bind (root)
Based on your encouragement, this time I investigated further and
figured out that `paths-find-emacs-roots' was returning a list whose
first element was a list. dump-paths.el and `normal-top-level' in
startup.el (which call `paths-find-emacs-roots') could not handle that
complexity, so I hacked together a fix to flatten out the list at the
end of `paths-find-emacs-roots' and voila, the code works.
My hack doesn't feel like a particularly good lisp-y approach, so I
would be grateful for any help you or anyone else could offer. Here's
what I did: at the end of `paths-find-emacs-roots' I changed the code
from returning this form:
- (paths-filter #'paths-emacs-root-p potential-installation-roots)))
- (paths-uniq-append invocation-roots
- installation-roots)))
to this:
+ (paths-filter #'paths-emacs-root-p potential-installation-roots))
+ (maybe-not-flat (paths-uniq-append
+ invocation-roots
+ installation-roots)))
+ ; flatten the list and return it
+ (if (listp (car maybe-not-flat))
+ (nconc (car maybe-not-flat) (nthcdr 1 maybe-not-flat))
+ maybe-not-flat)))
It seems to me that the real problem is that `paths-uniq-append' does
not flatten the list it returns and it would be better to fix things
there, I think. Patches gratefully accepted.
One other comment, searching further up in the hierarchy was not
necessary, so I removed `maybe-root-4' from your sample code, and I
changed `maybe-root-3' to point to ../../XEmacs. This is the
directory that config.inc.samp defaults package installation to under
Windows.
The complete patch is attached. Please look this over and send me
your comments.
Thanks for your help.
Regards,
Vin
--
Whoever you are, no matter how lonely,
the world offers itself to your imagination,
calls to you like the wild geese, harsh and exciting--
over and over announcing your place
in the family of things. Mary Oliver