Subject: bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated

From: "Drew Adams" <[email-masked]>
Date: Tue, 14 Jun 2011 13:36:45 -0700

> here, Emacs pops up a new frame and the message tells me the 
> window and that that window is strongly dedicated to its buffer.
> If it does so on your system,

It does here too.

> please try to step through `special-display-popup-frame'
> once with your old, working Emacs and once with the latest 
> version.  The
> differences in arguments and behaviors should tell us what went wrong.

Keep in mind that using the debugger can be problematic because buffer
*Backtrace* itself is a special-display buffer.  But I was able to do so to get
some more info.

(BTW, these debugging problems are worse in the latest build - `q' does not even
exit the debugger; and when you get back to the top level buffer *Backtrace*
still contains a backtrace from execute-extended-command up through
special-display-popup-frame; etc.)

The difference is that, unlike in last week's build, in this week's build
`special-display-popup-frame' does not call the special-display function
`1on1-display-*Completions*-frame'.

Here is the call in last week's build:

* 1on1-display-*Completions*-frame(
#<buffer *Completions*> 
((background-color . "LavenderBlush2") 
 (mouse-color . "VioletRed")
 (cursor-color . "VioletRed")
 (menu-bar-lines . 0)
 (tool-bar-lines . 0)
 (width . 100)))

* apply(1on1-display-*Completions*-frame #<buffer *Completions*>
 ((background-color ...)))

* (if (and args (symbolp (car args)))
      (apply (car args) buffer (cdr args))
  (let ((window (get-buffer-window buffer 0)))
   (or (when window (let ((frame (window-frame window)))
                      (make-frame-visible frame)
                      (raise-frame frame)
                      window))
       (when (cdr (assq (quote same-window) args))
         (condition-case nil
           (progn (switch-to-buffer buffer) (selected-window))
          (error nil)))
       (when (or (cdr (assq (quote same-frame) args))
                 (cdr (assq (quote same-window) args)))
         (let* ((pop-up-windows t)
                pop-up-frames special-display-buffer-names
special-display-regexps)
           (display-buffer buffer)))
  (let ((frame (with-current-buffer buffer (make-frame ...))))
   (set-window-buffer (frame-selected-window frame) buffer)
   (set-window-dedicated-p (frame-selected-window frame) t)
   (frame-selected-window frame)))))

  special-display-popup-frame(
  #<buffer *Completions*>
  (1on1-display-*Completions*-frame
   ((background-color ...)))))

* display-buffer(#<buffer *Completions*> nil nil)

And here is the call in this week's build:

Debugger entered--returning value: (background-color . "LavenderBlush2")
  car(((background-color . "LavenderBlush2")
       (mouse-color . "VioletRed")
       (cursor-color . "VioletRed")
       (menu-bar-lines . 0)
       (tool-bar-lines . 0)
       (width . 100)))
* (symbolp (car args))
* (and args (symbolp (car args)))
* (if (and args (symbolp (car args)))
      (apply (car args) buffer (cdr args))
   (let ...

IOW, what seems to be happening is that the first arg is not a symbol, so the
`if' branch that applies the special-display function (the symbol that is the
car) to its args (the cdr) is not taken at all.

The args to `special-display-popup-frame' are different in the two builds.  For
last week's build, they are:

  special-display-popup-frame(
#<buffer *Completions*>
(1on1-display-*Completions*-frame
  ((background-color . "LavenderBlush2")
   (mouse-color . "VioletRed")
   (cursor-color . "VioletRed")
   (menu-bar-lines . 0)
   (tool-bar-lines . 0)
   (width . 100))))

For this week's build they are:

  special-display-popup-frame(
#<buffer *Completions*>
((background-color . "LavenderBlush2")
 (mouse-color . "VioletRed")
 (cursor-color . "VioletRed")
 (menu-bar-lines . 0)
 (tool-bar-lines . 0)
 (width . 100)))

However, the *Completions* frame does seem to have the correct alist (background
color etc.).  That apparently happens in the other `if' branch, here:

* (append args special-display-frame-alist)
* (make-frame (append args special-display-frame-alist))

IOW, the special-display function, `1on1-display-*Completions*-frame' is not
called by `special-display-popup-frame' in the new build.

However, as I said before, `1on1-display-*Completions*-frame' is called, but
only by `display-buffer'.  Here is a backtrace from debugging only entry to
`1on1-display-*Completions*-frame' (not entry to `special-display-popup-frame'):

  1on1-display-*Completions*-frame(
#<buffer *Completions*>
((background-color . "LavenderBlush2")
 (mouse-color . "VioletRed")
 (cursor-color . "VioletRed")
 (menu-bar-lines . 0)
 (tool-bar-lines . 0)
 (width . 100)))
* apply(
1on1-display-*Completions*-frame
#<buffer *Completions*>
((background-color . "LavenderBlush2")
 (mouse-color . "VioletRed")
 (cursor-color . "VioletRed")
 (menu-bar-lines . 0)
 (tool-bar-lines . 0)
 (width . 100)))

  display-buffer(#<buffer *Completions*> nil nil)
  internal-temp-output-buffer-show(#<buffer *Completions*>)
  minibuffer-completion-help()
  completion--do-completion()
  minibuffer-complete()

That call to `1on1-display-*Completions*-frame' does do (set-window-dedicated-p
#<window 48 on *Completions*> t).  And in the debugger evaluating
(window-dedicated-p (get-buffer-window "*Completions*" 0)) returns t.  And also
this gets evaluated (to nil), with *Completions* as the selected frame:

* (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame)

So I don't really understand what the problem is.  In any case, it's clear that
the first branch of the `if' in `special-display-popup-frame' is not being
taken, and that `1on1-display-*Completions*-frame' is getting called by
`display-buffer' before it even calls `special-display-popup-frame'.

It took me a long time to get this far.  I hope you can take it from here.

In any case, I gave you a complete recipe.  You can do exactly what you asked me
to do just now.  See for yourself what the problems are.  You need only download
the two files I mentioned, oneonone.el and hexrgb.el.