* infohack.el (batch-makeinfo): Provide local implementation of
authorKevin Greiner <kevin.greiner@compsol.cc>
Wed, 19 Mar 2003 07:01:09 +0000 (07:01 +0000)
committerKevin Greiner <kevin.greiner@compsol.cc>
Wed, 19 Mar 2003 07:01:09 +0000 (07:01 +0000)
subst-char-in-region as the built-in implementation is unreliable
on Windows XP (Intermittent failure results in build looping
forever).

texi/infohack.el

index 4fe9949..6e5705a 100644 (file)
        (Info-split))
     (save-buffer)))
 
+(eval-and-compile
+  (when (string-match "windows-nt\\|os/2\\|emx\\|cygwin"
+                      (symbol-name system-type))
+    (defun subst-char-in-region (START END FROMCHAR TOCHAR &optional NOUNDO)
+      "From START to END, replace FROMCHAR with TOCHAR each time it occurs.
+If optional arg NOUNDO is non-nil, don't record this change for undo
+and don't mark the buffer as really changed.
+Both characters must have the same length of multi-byte form."
+      (let ((original-buffer-undo-list buffer-undo-list)
+            (modified (buffer-modified-p)))
+        (if NOUNDO
+            (setq buffer-undo-list t))
+        (goto-char START)
+        (let ((from (char-to-string FROMCHAR))
+              (to (char-to-string TOCHAR)))
+          (while (search-forward from END t)
+            (replace-match to t t)))
+        (if NOUNDO
+            (progn (setq buffer-undo-list original-buffer-undo-list)
+                   (set-buffer-modidifed-p modified)))))))
+
 (defun batch-makeinfo ()
   "Emacs makeinfo in batch mode."
   (infohack (car command-line-args-left))