I intend to commit this by tomorrow.
Please note the region-active-p checking workaround hunks have been
removed now that I submitted a patch to fix `region-active-p' itself.
Thanks to Ben and Hrvoje for that advice.
Best regards,
Adrian
xemacs-21.5-clean ChangeLog patch:
Diff command: cvs -q diff -U 0
Files affected: lisp/ChangeLog
Index: lisp/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
retrieving revision 1.643
diff -u -U0 -r1.643 ChangeLog
--- lisp/ChangeLog 22 Feb 2005 07:16:06 -0000 1.643
+++ lisp/ChangeLog 22 Feb 2005 23:32:26 -0000
@@ -0,0 +1,7 @@
+2005-02-20 Adrian Aichner <adrian(a)xemacs.org>
+
+ * replace.el (operate-on-non-matching-lines): Append matching
+ lines to temp buffer to avoid prohibitive GC as a result of
+ enormous string consing.
+ * replace.el (operate-on-matching-lines): Ditto.
+
xemacs-21.5-clean source patch:
Diff command: cvs -f -z3 -q diff -u -w -N
Files affected: lisp/replace.el
Index: lisp/replace.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/replace.el,v
retrieving revision 1.10
diff -u -w -r1.10 replace.el
--- lisp/replace.el 12 May 2003 05:12:10 -0000 1.10
+++ lisp/replace.el 22 Feb 2005 23:29:52 -0000
@@ -247,7 +247,9 @@
(let ((matched-text nil)
(curmatch-start (point))
- (limit (copy-marker (point-max))))
+ (limit (copy-marker (point-max)))
+ (matched-text-buffer (generate-new-buffer " *matched-text*"))
+ lines-matched)
;; Limit search if limits were specified.
(when end (setq limit (copy-marker end)))
@@ -259,7 +261,7 @@
;; curmatch-start is first char not preserved by previous match.
(if (not (re-search-forward regexp limit 'move))
(let ((curmatch-end limit))
- (setq matched-text (concat matched-text (buffer-substring curmatch-start
curmatch-end)))
+ (append-to-buffer matched-text-buffer curmatch-start curmatch-end)
(if delete (delete-region curmatch-start curmatch-end)))
(let ((curmatch-end (save-excursion (goto-char (match-beginning 0))
(beginning-of-line)
@@ -267,7 +269,7 @@
;; Now curmatch-end is first char preserved by the new match.
(if (< curmatch-start curmatch-end)
(progn
- (setq matched-text (concat matched-text (buffer-substring
curmatch-start curmatch-end)))
+ (append-to-buffer matched-text-buffer curmatch-start curmatch-end)
(if delete (delete-region curmatch-start curmatch-end))))))
(setq curmatch-start (save-excursion (forward-line 1)
(point)))
@@ -277,14 +279,15 @@
;; If any lines were matched and KILL is non-nil, insert the
;; matched lines into the kill ring.
+ (setq matched-text (buffer-string matched-text-buffer))
(if (and matched-text kill) (kill-new matched-text))
;; Return the number of matched lines.
- (with-temp-buffer
- ;; Use concat to make a string even if matched-text is nil.
- (insert (concat matched-text))
- (count-lines (point-min) (point-max)))
- ))))
+ (setq lines-matched
+ (with-current-buffer matched-text-buffer
+ (count-lines (point-min) (point-max))))
+ (kill-buffer matched-text-buffer)
+ lines-matched))))
(define-function 'keep-lines 'delete-non-matching-lines)
(defun delete-non-matching-lines (regexp)
@@ -358,8 +361,9 @@
(let ((matched-text nil)
(curmatch-start nil)
(curmatch-end nil)
- (limit nil))
-
+ (limit nil)
+ (matched-text-buffer (generate-new-buffer " *matched-text*"))
+ lines-matched)
;; Limit search if limits were specified.
(when beg (goto-char beg))
(when end (setq limit (copy-marker end)))
@@ -370,17 +374,17 @@
(beginning-of-line)
(point)))
(setq curmatch-end (progn (forward-line 1) (point)))
- (setq matched-text (concat matched-text (buffer-substring curmatch-start
curmatch-end)))
+ (append-to-buffer matched-text-buffer curmatch-start curmatch-end)
(if delete (delete-region curmatch-start curmatch-end)))
-
+ (setq matched-text (buffer-string matched-text-buffer))
(if (and matched-text kill) (kill-new matched-text))
;; Return the number of matched lines.
- (with-temp-buffer
- ;; Use concat to make a string even if matched-text is nil.
- (insert (concat matched-text))
- (count-lines (point-min) (point-max)))
- ))))
+ (setq lines-matched
+ (with-current-buffer matched-text-buffer
+ (count-lines (point-min) (point-max))))
+ (kill-buffer matched-text-buffer)
+ lines-matched))))
(define-function 'flush-lines 'delete-matching-lines)
(defun delete-matching-lines (regexp)
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/