Subject: bug#8463: 24.0.50; [PATCH] Direct Edit in *Occur* Buffer

From: Leo <[email-masked]>
Date: Thu, 09 Jun 2011 12:47:00 +0800

On 2011-06-02 07:03 +0800, Glenn Morris wrote:
> 2. After C-x C-q, If I delete some text in the occur buffer, then use
> "undo", when I reach the point at which there is no more to undo, I get:
> "Wrong type argument: markerp, nil" rather than "No further undo information".
>
> Debugger entered--Lisp error: (wrong-type-argument markerp nil)
>   marker-buffer(nil)
>   occur-after-change-function(1 40 39)
>   primitive-undo(1 ((nil font-lock-face underline 1 . 40) (t 0 . 0)))
>   undo-more(1)
>   undo(nil)
>   call-interactively(undo nil nil)

This can be fixed with:

diff --git a/lisp/replace.el b/lisp/replace.el
index 0578ed09..fc2db2ec 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -882,11 +882,11 @@ (define-derived-mode occur-edit-mode occur-mode "Occur-Edit"
 
 (defun occur-after-change-function (beg end length)
   (save-excursion
-    (goto-char beg)
     (let* ((m (get-text-property (line-beginning-position) 'occur-target))
 	   (buf (marker-buffer m))
 	   (col (current-column)))
       (when (= length 0)
+	(goto-char beg)
 	;; Apply occur-target property to inserted (e.g. yanked) text.
 	(put-text-property beg end 'occur-target m)
 	;; Did we insert a newline?  Occur Edit mode can't create new

The cause:

When switching major-mode (in this case occur-edit-mode), an undo entry
containing text-property only change is added due to this line in
occur-mode:

(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)

That line seems useless due to change made in revid 22063400b. If no one
objects, I intend to also remove it.

Leo