Hi,

Cecil Westerhof <[email protected]> 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.

Thanks,
Ludo’.


Reply via email to