[Top][All Lists]

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

Re: How to convert from Emacs Lisp to Guile

From: Ludovic Courtès
Subject: Re: How to convert from Emacs Lisp to Guile
Date: Fri, 18 Jun 2010 17:07:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)


Cecil Westerhof <address@hidden> writes:

> At the moment I have the following code in Emacs Lisp:
>       (defun substitute-expression(input-file output-file reg-exp 
> substitute-str)
>         (let ((match-length))
>           (switch-to-buffer (find-file-noselect input-file t t))
>           (buffer-disable-undo)
>           (while (re-search-forward reg-exp nil t)
>             (setq match-length (- (point) (match-beginning 0)))
>             (while (> match-length (length substitute-str))
>               (setq substitute-str (concat substitute-str substitute-str)))
>             (replace-match (substring substitute-str 0 match-length))
>           )
>           (write-region (point-min) (point-max) output-file)))

There’s no such thing as a ‘buffer’ or ‘point’ in Guile so that would
need to be expressed, e.g., as a procedure that opens a file, reads it
line by line, writes modified lines to the output file, etc.

See the (ice-9 regex) and (ice-9 rdelim) modules for useful tools.


reply via email to

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