Subject: bug#13887: 24.3; doc-view will render blurry images when image-magick is available

From: Eli Zaretskii <[email-masked]>
Date: Mon, 11 Mar 2013 18:57:28 +0200

> From: Tassilo Horn <[email-masked]>
> Date: Mon, 11 Mar 2013 10:11:28 +0100
> Cc: [email-masked]
> 
> Aha, now I know how to reproduce that (also with the emacs with my
> customizations and the centering patch).  Somehow,
> `doc-view-new-window-function' is run way too often (I've commented in
> the (message ...) in its first line to see).  When opening some
> document, it's run twice.  When the document is shown, M-x <TAB> will
> also run it again.  Ditto for M-: (i<TAB.  Ditto for C-x C-f.

doc-view-new-window-function seems to be run from a
window-configuration-change-hook, right?  If so, why do you expect it
to be run only once, or not run when you type "M-x TAB"?  E.g., the
latter pops up the completion buffer and/or splits the window, which
constitutes a change in window configuration:

 -- Variable: window-configuration-change-hook
     A normal hook that is run every time you change the window
     configuration of an existing frame.  This includes splitting or
     deleting windows, changing the sizes of windows, or displaying a
     different buffer in a window.                    ^^^^^^^^^^^^^^^
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I think a function written to run off that hook should be defensive
and not assume anything about when it will or won't be called, or how
many times.  Just grep the C sources for
run_window_configuration_change_hook, and you will see why.