emacs-devel
[Top][All Lists]
Advanced

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

Re: occur-hook changing the current buffer


From: Juanma Barranquero
Subject: Re: occur-hook changing the current buffer
Date: Wed, 22 Jun 2005 13:10:31 +0200

> Emacs can't, and shouldn't try to, protect against random crap in hooks,

Excuse me if I find this quite funny.

  emacs -Q

  C-x b test RET
  aaaa RET
  bbbb RET
  bbbb RET
  cccc RET
 C-x 2
 C-x o
  M-x ielm RET
  ;; define hook in ielm
 (add-hook 'occur-hook
                 '(lambda ()
                    (let ((w (get-buffer-window "*Occur*")))
                      (message "Before: B(%S), W(%S)" (current-buffer) 
(selected-window))
                      (fit-window-to-buffer w)
                      (message "After : B(%S), W(%S)" (current-buffer) 
(selected-window)))))
C-x o
M-x occur RET
bbbb RET

 => Buffer test is read-only
 => *Messages* has:
Before: B(#<buffer *Occur*>), W(#<window 3 on test>)
After : B(#<buffer test>), W(#<window 3 on test>)

What's exactly "crappy" about the hook function? I don't see anything
in `fit-window-to-buffer 'docs that suggest it should produce this
effect...

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




reply via email to

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