From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-user@gnu.org
Subject: Re: How to convert from Emacs Lisp to Guile
Date: Sun, 20 Jun 2010 19:51:26 +0200 [thread overview]
Message-ID: <87iq5dego1.fsf@ambire.localdomain> (raw)
In-Reply-To: <877hlt3ip5.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sun, 20 Jun 2010 16:03:02 +0200")
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
() ludo@gnu.org (Ludovic Courtès)
() Sun, 20 Jun 2010 16:03:02 +0200
Would you feel like documenting it in the manual and adding test cases?
For Guile 1.4.x, there is already (online) documentation:
http://www.gnuvola.org/software/guile/doc/Module-Index.html
Where do you suggest this be placed in the Guile 2.x manual?
Please find attached the (simple) test cases file.
Tips on how/where to integrate it into Guile 2.x welcome.
For the record, i am willing to relax licensing from GPLv3+ to LGPL
for all changes relating to porting forward Guile 1.4.x stuff, so
you don't need to worry about that aspect.
thi
_____________________________________________________________
[-- Attachment #2: gap-buffer.test --]
[-- Type: application/octet-stream, Size: 3726 bytes --]
;;; gap-buffer.test -*- scheme -*-
;; Copyright (C) 2004, 2007, 2009 Thien-Thi Nguyen
;;
;; This file is part of GUILE
;;
;; GUILE is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GUILE 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 General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
(use-modules (ice-9 gap-buffer))
(define gb:test:number 0)
(defmacro check-gb (point point-min point-max buffer-string)
`(begin
(set! gb:test:number (1+ gb:test:number))
(pass-if (fs "~A gb->string" gb:test:number)
(string=? (gb->string gb) ,buffer-string))
(pass-if (fs "~A gb-point" gb:test:number)
(= (gb-point gb) ,point))
(pass-if (fs "~A gb-point-min" gb:test:number)
(= (gb-point-min gb) ,point-min))
(pass-if (fs "~A gb-point-max" gb:test:number)
(= (gb-point-max gb) ,point-max))))
(let ((gb (make-gap-buffer)))
(check-gb 1 1 1 "")
(gb-insert-string! gb "nothing is real")
(check-gb 16 1 16 "nothing is real")
(gb-insert-char! gb #\space)
(gb-insert-char! gb #\newline)
(check-gb 18 1 18 "nothing is real \n")
(gb-delete-char! gb 0) ; does nothing
(check-gb 18 1 18 "nothing is real \n")
(gb-delete-char! gb 5) ; does nothing
(check-gb 18 1 18 "nothing is real \n")
(gb-delete-char! gb -5)
(check-gb 13 1 13 "nothing is r")
(pass-if "goto-char 0" (zero? (gb-goto-char gb 0)))
(check-gb 1 1 13 "nothing is r")
(pass-if "goto-char 14" (= (gb-goto-char gb 14) 14))
(check-gb 13 1 13 "nothing is r")
(let ()
(define (check-port-output beg end exp)
(do ((pos (gb-point-min gb) (1+ pos)))
((= pos (gb-point-max gb)))
(pass-if (fs "port-output(~A) ~A ~A" pos beg end)
(string=? exp (call-with-tmpfile
(lambda (p) (gb->port! gb p beg end)))))))
(check-port-output 1 13 "nothing is r")
(check-port-output 3 11 "thing is")
(check-port-output 1 10 "nothing i")
(check-port-output 7 13 "g is r")
(pass-if "port-output"
(string=? "nothing is r" (call-with-tmpfile
(lambda (p) (gb->port! gb p))))))
(gb-goto-char gb 1)
(gb-insert-char! gb #\Z)
(check-gb 2 1 14 "Znothing is r")
(gb-delete-char! gb 1)
(gb-goto-char gb 4)
(gb-insert-char! gb #\t)
(gb-delete-char! gb 1)
(gb-goto-char gb (gb-point-max gb))
(gb-insert-string! gb "adical!")
(check-gb 20 1 20 "Zotting is radical!")
(gb-goto-char gb 8)
(with-output-to-port (make-gap-buffer-port gb)
(lambda ()
(display #\space) (display "hello world!")
(newline) (display "Hacking")))
(check-gb 29 1 41 "Zotting hello world!\nHacking is radical!")
(gb-filter-lines! gb cdr)
(check-gb 20 1 20 "Hacking is radical!")
(gb-goto-char gb (gb-point-max gb))
(gb-insert-char! gb #\newline)
(check-gb 21 1 21 "Hacking is radical!\n")
(gb-filter-lines! gb (lambda (lines)
(map (lambda (ln)
(number->string (string-length ln)))
lines)))
(check-gb 5 1 5 "19\n0")
(gb-erase! gb)
(check-gb 1 1 1 ""))
;;; gap-buffer.test ends here
next prev parent reply other threads:[~2010-06-20 17:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-18 8:48 How to convert from Emacs Lisp to Guile Cecil Westerhof
2010-06-18 15:07 ` Ludovic Courtès
2010-06-18 17:19 ` Thien-Thi Nguyen
2010-06-20 14:03 ` Ludovic Courtès
2010-06-20 17:51 ` Thien-Thi Nguyen [this message]
2010-06-20 19:06 ` Ludovic Courtès
2010-06-20 19:33 ` Thien-Thi Nguyen
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=87iq5dego1.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=guile-user@gnu.org \
--cc=ludo@gnu.org \
/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).