In GNU Emacs 22.0.50.37 (i686-pc-linux-gnu, GTK+ Version 2.6.4)
 of 2005-04-30 on dugong
Distributor `The XFree86 Project, Inc', version 11.0.40300001
configured using `configure '--with-gtk''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

When there are read-only text properties in a buffer, occur fails with
"Text is read-only".  If no *Occur* buffer exists before the call, the
failure is in occur-engine when it adds text properties; otherwise the
failure is in occur-1 when erase-buffer is called.

Suggested patch attached, which also marks the *Occur* buffer as
unmodified (cf Emacs 21).

Thanks,

Matt

Index: lisp/replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.208
diff -u -r1.208 replace.el
--- lisp/replace.el	18 Mar 2005 09:59:45 -0000	1.208
+++ lisp/replace.el	5 May 2005 14:19:18 -0000
@@ -977,32 +977,33 @@
     (setq occur-buf (get-buffer-create buf-name))
 
     (with-current-buffer occur-buf
-      (setq buffer-read-only nil)
       (occur-mode)
-      (erase-buffer)
-      (let ((count (occur-engine
-		    regexp active-bufs occur-buf
-		    (or nlines list-matching-lines-default-context-lines)
-		    (and case-fold-search
-			 (isearch-no-upper-case-p regexp t))
-		    list-matching-lines-buffer-name-face
-		    nil list-matching-lines-face t)))
-	(let* ((bufcount (length active-bufs))
-	       (diff (- (length bufs) bufcount)))
-	  (message "Searched %d buffer%s%s; %s match%s for `%s'"
-		   bufcount (if (= bufcount 1) "" "s")
-		   (if (zerop diff) "" (format " (%d killed)" diff))
-		   (if (zerop count) "no" (format "%d" count))
-		   (if (= count 1) "" "es")
-		   regexp))
-	(setq occur-revert-arguments (list regexp nlines bufs)
-	      buffer-read-only t)
-	(if (> count 0)
-	    (progn
-	      (display-buffer occur-buf)
-	      (setq next-error-last-buffer occur-buf))
-	  (kill-buffer occur-buf)))
-      (run-hooks 'occur-hook))))
+      (let ((inhibit-read-only t))
+	(erase-buffer)
+	(let ((count (occur-engine
+		      regexp active-bufs occur-buf
+		      (or nlines list-matching-lines-default-context-lines)
+		      (and case-fold-search
+			   (isearch-no-upper-case-p regexp t))
+		      list-matching-lines-buffer-name-face
+		      nil list-matching-lines-face t)))
+	  (let* ((bufcount (length active-bufs))
+		 (diff (- (length bufs) bufcount)))
+	    (message "Searched %d buffer%s%s; %s match%s for `%s'"
+		     bufcount (if (= bufcount 1) "" "s")
+		     (if (zerop diff) "" (format " (%d killed)" diff))
+		     (if (zerop count) "no" (format "%d" count))
+		     (if (= count 1) "" "es")
+		     regexp))
+	  (setq occur-revert-arguments (list regexp nlines bufs))
+	  (if (> count 0)
+	      (progn
+		(display-buffer occur-buf)
+		(setq next-error-last-buffer occur-buf))
+	    (kill-buffer occur-buf)))
+	(run-hooks 'occur-hook))
+      (setq buffer-read-only t)
+      (set-buffer-modified-p nil))))
 
 (defun occur-engine-add-prefix (lines)
   (mapcar
@@ -1013,7 +1014,6 @@
 (defun occur-engine (regexp buffers out-buf nlines case-fold-search
 			    title-face prefix-face match-face keep-props)
   (with-current-buffer out-buf
-    (setq buffer-read-only nil)
     (let ((globalcount 0)
 	  (coding nil))
       ;; Map over all the buffers
Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.7446
diff -u -r1.7446 ChangeLog
--- lisp/ChangeLog	5 May 2005 11:04:51 -0000	1.7446
+++ lisp/ChangeLog	5 May 2005 14:19:21 -0000
@@ -1,3 +1,11 @@
+2005-05-05  Matt Hodges  <[EMAIL PROTECTED]>
+
+	* replace.el (occur-1): Bind inhibit-read-only so that
+	erase-buffer doesn't barf on read-only text properties (likewise
+	for add-text-properties in occur-engine).  Mark buffer as
+	unmodified.
+	(occur-engine): Don't set buffer-read-only here.
+
 2005-05-05  Juanma Barranquero  <[EMAIL PROTECTED]>
 
 	* emacs-lisp/byte-run.el (define-obsolete-function-alias): Fix
_______________________________________________
Emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to