From: William Xu <william.xwl@gmail.com>
Subject: Re: slib and scm_shell() conflicts
Date: Fri, 24 Feb 2006 23:05:22 +0800 [thread overview]
Message-ID: <87pslcssp9.fsf@www.williamxu.com> (raw)
In-Reply-To: <87k6bqwe7x.fsf@www.williamxu.com> (William Xu's message of "Mon, 20 Feb 2006 17:50:58 +0800")
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
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
prev parent reply other threads:[~2006-02-24 15:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-20 9:50 slib and scm_shell() conflicts William Xu
2006-02-21 1:00 ` Kevin Ryde
2006-02-21 3:34 ` William Xu
2006-02-21 9:28 ` Ken Raeburn
2006-02-24 8:45 ` Ludovic Courtès
2006-02-24 15:05 ` William Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pslcssp9.fsf@www.williamxu.com \
--to=william.xwl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).