guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: slib and scm_shell() conflicts


From: William Xu
Subject: Re: slib and scm_shell() conflicts
Date: Fri, 24 Feb 2006 23:05:22 +0800
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Seems it's some config problem or what, i'm not sure. But here's how i
made it at least work.

To load SLIB, use something like, 

(use-modules (ice-9 slib))
(require 'printf)

But don't load this directly: 

;; (load-from-path "/usr/share/slib/init/guile.init")

Instead, when it says something not found, like `user-vicinity', simply
cut them from guile.init and paste it to ice-9/slib.scm. Total changes
i've made are: 

williamxu:~/share/guile/1.9/ice-9$ diff -u slib.scm.orig slib.scm
--- slib.scm.orig       2006-02-24 22:53:59.936000000 +0800
+++ slib.scm    2006-02-24 22:55:07.760000000 +0800
@@ -6,12 +6,12 @@
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
 ;;;; version 2.1 of the License, or (at your option) any later version.
-;;;; 
+;;;;
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ;;;; Lesser General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU Lesser General Public
 ;;;; License along with this library; if not, write to the Free Software
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
@@ -233,6 +233,60 @@
 (define slib:load-source slib:load)
 (define defmacro:load slib:load)
 
+;; by xwl(cut from slib/guile.init)
+(define (user-vicinity)
+  (case (software-type)
+    ((vms)     "[.]")
+    (else      "")))
+
+(define with-load-pathname
+  (let ((exchange
+        (lambda (new)
+          (let ((old program-vicinity))
+            (set! program-vicinity new)
+            old))))
+    (lambda (path thunk)
+      (define old #f)
+      (define vic (pathname->vicinity path))
+      (dynamic-wind
+         (lambda () (set! old (exchange (lambda () vic))))
+         thunk
+         (lambda () (exchange old))))))
+
+(define (pathname->vicinity pathname)
+  (let loop ((i (- (string-length pathname) 1)))
+    (cond ((negative? i) "")
+         ((vicinity:suffix? (string-ref pathname i))
+          (substring pathname 0 (+ i 1)))
+         (else (loop (- i 1))))))
+
+(define (program-vicinity)
+  (define clp (current-load-port))
+  (if clp
+      (pathname->vicinity (port-filename clp))
+      (slib:error 'program-vicinity " called; use slib:load to load")))
+
+;;; (software-type) should be set to the generic operating system type.
+;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
+(define software-type
+  (if (string<? (version) "1.6")
+      (lambda () 'UNIX)
+      (lambda () 'unix)))
+
+(define vicinity:suffix?
+  (let ((suffi
+        (case (software-type)
+          ((amiga)                             '(#\: #\/))
+          ((macos thinkc)                      '(#\:))
+          ((ms-dos windows atarist os/2)       '(#\\ #\/))
+          ((nosve)                             '(#\: #\.))
+          ((unix coherent plan9)               '(#\/))
+          ((vms)                               '(#\: #\]))
+          (else
+           (warn "require.scm" 'unknown 'software-type (software-type))
+           "/"))))
+    (lambda (chr) (and (memv chr suffi) #t))))
+
 (define slib-parent-dir
   (let* ((path (%search-load-path "slib/require.scm")))
     (if path

-- 
William




reply via email to

[Prev in Thread] Current Thread [Next in Thread]