emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

occur-hook changing the current buffer


From: Juanma Barranquero
Subject: occur-hook changing the current buffer
Date: Tue, 21 Jun 2005 04:00:39 +0200

In my `occur-hook' I have a custom function which does not save the
current buffer, so the last two lines of `occur-1', i.e.:

      (setq buffer-read-only t)
      (set-buffer-modified-p nil))))

where affecting the wrong buffer (the one searched by `occur', in fact).

Now, I can easily change my function to do the right thing, but I
still feel that `occur-1' should be fixed by using
`save-current-buffer' around the call to "(run-hooks 'occur-hook). The
rationale being that setting the modified flag to nil on the wrong
buffer can lead to data loss.

Opinions?

-- 
                    /L/e/k/t/u


Index: replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.212
diff -u -2 -r1.212 replace.el
--- replace.el  8 Jun 2005 22:37:13 -0000       1.212
+++ replace.el  21 Jun 2005 01:48:51 -0000
@@ -1002,5 +1002,6 @@
                (setq next-error-last-buffer occur-buf))
            (kill-buffer occur-buf)))
-       (run-hooks 'occur-hook))
+        (save-current-buffer
+          (run-hooks 'occur-hook)))
       (setq buffer-read-only t)
       (set-buffer-modified-p nil))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]