unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
@ 2011-06-13 16:08 Drew Adams
  2011-06-13 18:00 ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-13 16:08 UTC (permalink / raw)
  To: 8851

This regression was introduced between this build (from today,
6/13/2011) and the Windows build of LAST week, which was this:
 
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-06-06 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/build/include'
 
I don't have a recipe starting from emacs -Q.  But these are the
symptoms:
 
I have non-nil `pop-up-frames'.  I use a special-display frame for
buffers such as `*Buffer List*' and `*info*'.  
My value of `special-display-regexps' is this:
("[ ]?[*][^*]+[*]")
 
My special-display frames hav a different background color from my
regular frames.  I visit a file foo.el, then use `C-x 5 0' to remove
its frame. I hit C-x C-b and get the buffer menu in a new,
special-display frame.  I click mouse-2 on the foo.el line to
visit that file.
 
Prior to this week's build, this opens foo.el in a new frame, in a
regular frame.  With this week's build it visits foo.el in the same
frame that showed `*Buffer List*'.  IOW, `pop-up-frames' is not being
respected (in the case where there is not already a frame showing
foo.el).
 
What is happening is that `Buffer-menu-mouse-select' is incorrectly
invoking `switch-to-buffer' instead of `switch-to-buffer-other-window'.
This is happening because the window of the special-display buffer is
not dedicated, as it should be.
 
This returns nil:
(window-dedicated-p #<window 14 on *Buffer List*>)
 
Similarly, M-: (window-dedicated-p (selected-window)) in any
special-display buffer window returns nil.  It should return non-nil.
 
In my setup the windows of buffers such as `*Buffer List*' and `*info*'
should definitely be dedicated.  They are special-display buffers (and
their special-display-frame backgrounds confirm this).
 
As the manual says, and as has always been the behavior in previous
Emacs versions, "By default, special display means to give the buffer a
dedicated frame."

The frames showing special-display buffers should be dedicated frames.
Clicking mouse-2 on a buffer name in `*Buffer List*' should not visit
that buffer in the same window/frame.
 
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-06-13 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/build/include'
 






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-13 16:08 bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated Drew Adams
@ 2011-06-13 18:00 ` martin rudalics
  2011-06-13 18:41   ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-13 18:00 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8851

> Similarly, M-: (window-dedicated-p (selected-window)) in any
> special-display buffer window returns nil.  It should return non-nil.

Does the patch below fix it?

martin

=== modified file 'lisp/window.el'
*** lisp/window.el	2011-06-13 08:21:09 +0000
--- lisp/window.el	2011-06-13 17:53:54 +0000
***************
*** 4372,4378 ****
   	 (dedicated (cdr (assq 'dedicated specifiers)))
   	 (no-other-window (cdr (assq 'no-other-window specifiers))))
       ;; Show BUFFER in WINDOW.
-     (set-window-dedicated-p window nil)
       (set-window-buffer window buffer)
       (when dedicated
         (set-window-dedicated-p window dedicated))
--- 4372,4377 ----
***************
*** 4482,4487 ****
--- 4481,4488 ----
   		 (window-point best-window) buffer
   		 (window-total-size best-window) (selected-window)))))

+       ;; Reset dedicated status of best-window here.
+       (set-window-dedicated-p best-window nil)
         (display-buffer-in-window buffer best-window specifiers))))

   (defconst display-buffer-split-specifiers '(largest lru selected root left top right bottom)







^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-13 18:00 ` martin rudalics
@ 2011-06-13 18:41   ` Drew Adams
  2011-06-14  9:15     ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-13 18:41 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8851

> Does the patch below fix it?

Thanks for your quick reply, Martin.  No, I'm afraid it doesn't change anything
wrt this bug.

I didn't download the latest source files to apply your patch, but the build I'm
using is supposedly from today.  I applied your patch manually to its source
code, which means that I eval'ed these two updated definitions (below).  That
didn't help.

(defun display-buffer-in-window (buffer window specifiers)
  "Display BUFFER in WINDOW and raise its frame if needed.
WINDOW must be a live window and defaults to the selected one.
Return WINDOW.

SPECIFIERS must be a list of buffer display specifiers, see the
documentation of `display-buffer-alist' for a description."
  (setq buffer (normalize-live-buffer buffer))
  (setq window (normalize-live-window window))
  (let* ((old-frame (selected-frame))
	 (new-frame (window-frame window))
	 (dedicated (cdr (assq 'dedicated specifiers)))
	 (no-other-window (cdr (assq 'no-other-window specifiers))))
    ;; Show BUFFER in WINDOW.
    ;;---- (set-window-dedicated-p window nil)
    (set-window-buffer window buffer)
    (when dedicated
      (set-window-dedicated-p window dedicated))
    (when no-other-window
      (set-window-parameter window 'no-other-window t))
    (unless (eq old-frame new-frame)
      (display-buffer-select-window window))
    ;; Return window.
    window))

(defun display-buffer-reuse-window (buffer method &optional specifiers)
  "Display BUFFER in an existing window.
METHOD must be a list in the form of the cdr of a `reuse-window'
buffer display specifier, see `display-buffer-alist' for an
explanation.  The first element must specifiy the window to use,
and can be either nil, `same', `other', or a live window.  The
second element must specify the window's buffer and can be either
nil, `same', `other', or a live buffer.  The third element is the
frame to use - either nil, 0, `visible', `other', t, or a live
frame.

Optional argument SPECIFIERS must be a list of valid display
specifiers.  Return the window chosen to display BUFFER, nil if
none was found."
  (let* ((method-window (nth 0 method))
	 (method-buffer (nth 1 method))
	 (method-frame (nth 2 method))
	 (reuse-dedicated (assq 'reuse-window-dedicated specifiers))
	 windows other-frame dedicated time best-window best-time)
    (when (eq method-frame 'other)
      ;; `other' is not handled by `window-list-1'.
      (setq other-frame t)
      (setq method-frame t))
    (dolist (window (window-list-1 nil 'nomini method-frame))
      (let ((window-buffer (window-buffer window)))
	(when (and (not (window-minibuffer-p window))
		   ;; Don't reuse a side window.
		   (or (not (eq (window-parameter window 'window-side) 'side))
		       (eq window-buffer buffer))
		   (or (not method-window)
		       (and (eq method-window 'same)
			    (eq window (selected-window)))
		       (and (eq method-window 'other)
			    (not (eq window (selected-window))))
		       ;; Special case for applications that specifiy
		       ;; the window explicitly.
		       (eq method-window window))
		   (or (not method-buffer)
		       (and (eq method-buffer 'same)
			    (eq window-buffer buffer))
		       (and (eq method-buffer 'other)
			    (not (eq window-buffer buffer)))
		       ;; Special case for applications that specifiy
		       ;; the window's buffer explicitly.
		       (eq method-buffer window-buffer))
		   (or (not other-frame)
		       (not (eq (window-frame window) (selected-frame))))
		   ;; Handle dedicatedness.
		   (or (eq window-buffer buffer)
		       ;; The window does not show the same buffer.
		       (not (setq dedicated (window-dedicated-p window)))
		       ;; If the window is weakly dedicated to its
		       ;; buffer, reuse-dedicated must be non-nil.
		       (and (not (eq dedicated t)) reuse-dedicated)
		       ;; If the window is strongly dedicated to its
		       ;; buffer, reuse-dedicated must be t.
		       (eq reuse-dedicated t)))
	  (setq windows (cons window windows)))))

    (if (eq method-buffer 'same)
	;; When reusing a window on the same buffer use the lru one.
	(dolist (window windows)
	  (setq time (window-use-time window))
	  (when (or (not best-window) (< time best-time))
	    (setq best-window window)
	    (setq best-time time)))
      ;; Otherwise, sort windows according to their use-time.
      (setq windows
	    (sort windows
		  #'(lambda (window-1 window-2)
		      (<= (window-use-time window-1)
			  (window-use-time window-2)))))
      (setq best-window
	    ;; Try to get a full-width window (this is silly and can
	    ;; get us to another frame but let's ignore these issues
	    ;; for the moment).
	    (catch 'found
	      (dolist (window windows)
		(when (window-full-width-p window)
		  (throw 'found window)))
	      ;; If there's no full-width window return the lru window.
	      (car windows))))

    (when best-window
      (display-buffer-even-window-sizes best-window specifiers)
      ;; Never change the quit-restore parameter of a window here.
      (if (eq (window-buffer best-window) buffer)
	  (setq display-buffer-window
		(cons best-window 'reuse-buffer-window))
	(setq display-buffer-window
	      (cons best-window 'reuse-other-window))
	(unless (window-parameter best-window 'quit-restore)
	  ;; Don't overwrite an existing quit-restore entry.
	  (set-window-parameter
	   best-window 'quit-restore
	   (list (window-buffer best-window) (window-start best-window)
		 (window-point best-window) buffer
		 (window-total-size best-window) (selected-window)))))
      ;; Reset dedicated status of best-window here.
      (set-window-dedicated-p best-window nil)
      (display-buffer-in-window buffer best-window specifiers))))






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-13 18:41   ` Drew Adams
@ 2011-06-14  9:15     ` martin rudalics
  2011-06-14 20:36       ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-14  9:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8851

 > I didn't download the latest source files to apply your patch, but the build I'm
 > using is supposedly from today.  I applied your patch manually to its source
 > code, which means that I eval'ed these two updated definitions (below).  That
 > didn't help.

The first thing I would have to know is if `special-display-popup-frame'
gets called with your setup.  If, with emacs -Q, I evaluate

(let* ((special-display-regexps '("[ ]?[*][^*]+[*]"))
        (window (display-buffer (get-buffer-create "*foo*"))))
   (message "%s" (cons window (window-dedicated-p window))))

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, 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.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-14  9:15     ` martin rudalics
@ 2011-06-14 20:36       ` Drew Adams
       [not found]         ` <4DFB6BBF.3080504@gmx.at>
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-14 20:36 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8851

> 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.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
       [not found]         ` <4DFB6BBF.3080504@gmx.at>
@ 2011-06-17 15:51           ` Drew Adams
  2011-06-17 16:22             ` bug#8856: " martin rudalics
  2011-06-17 17:48             ` bug#8856: " Drew Adams
  0 siblings, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-17 15:51 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8851, 8856

> From: martin rudalics (private mail)
> I've checked in a fix that should address this issue.  I 
> attached a copy of the latest window.el.  Please report on the
> list whether it works.

Thanks for working on this.  But I'm sorry to say that no, it not only does not
help, it makes things worse.

Now, when I hit `C-x C-b' I get `*Buffer List*' in the same (regular) frame - it
just replaces the current buffer in its window. 

What should happen is that `*Buffer List*' gets popped up in its own,
special-display frame (separate frame, different frame properties from regular
frames).

Here is a recipe (you just need to download the same 2 files as for the recipe
for bug #8856).  In fact, my reply to you with the debugger info, in this #8851
thread, involves this same startup recipe.

Let me repeat the startup recipe, which holds for both of these bugs (different
symptoms), #8851 and #8856:

runemacs.exe -Q --debug-init -l "hexrgb.el" -l "oneonone.el" -f "1on1-emacs"
 
Download the two files mentioned from here:
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24

For the rest of the bug #8851 recipe, see the initial bug report.

----

Wrt bug #8856 also, the same symptoms reported initially are still there (frame
selection/focus problem).

Plus, now the special-display frame that I define for `*Completions*' is not
even used.  Instead, buffer/window `*Completions*' is shown in a regular frame.

Please try the recipe for #8856, starting with the same Emacs startup recipe
shown above, and I think you will see the same things I see.  IOW, you should be
able to reproduce both problems from runemacs -Q.

Here again is that recipe (after startup as shown above):

> M-x f TAB ; to display *Completions* frame.
> C-]       ; to return to top level.
>  
> M-x f TAB o
> 
> Or just hit TAB twice in a row: M-x f TAB TAB.
> 
> IOW, try to type more input in minibuffer.  This raises the error
> "Buffer is read-only #<buffer *Completions*>"

----

If you cannot reproduce these two problems then maybe there is an
MS-Windows-specific issue somewhere.  But I'm guessing that you will be able to
reproduce them from the runemacs -Q startup shown here.  Let me know if
something is not clear.
 






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-17 15:51           ` Drew Adams
@ 2011-06-17 16:22             ` martin rudalics
  2011-06-17 17:48               ` Drew Adams
  2011-06-17 17:48             ` bug#8856: " Drew Adams
  1 sibling, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-17 16:22 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8851, 8856

 > Now, when I hit `C-x C-b' I get `*Buffer List*' in the same (regular) frame - it
 > just replaces the current buffer in its window.
 >
 > What should happen is that `*Buffer List*' gets popped up in its own,
 > special-display frame (separate frame, different frame properties from regular
 > frames).

So you somewhere have settings for this buffer in
`special-display-buffer-names' or `special-display-regexps'.  Why can't
you send me them?

 > Here is a recipe (you just need to download the same 2 files as for the recipe
 > for bug #8856).  In fact, my reply to you with the debugger info, in this #8851
 > thread, involves this same startup recipe.

I need a simple recipe from emacs -Q.  If you use an outside function in
any of these please use a dummy function I can run on both Emacs 23 and
Emacs 24 to see the differences.  If it's already difficult for you to
go through the debugger with your functions why do you think I can do
any better?  What I need are your settings wrt special-display-... and
the buffer in question.  Why can't you post these?

 > Wrt bug #8856 also, the same symptoms reported initially are still there (frame
 > selection/focus problem).
 >
 > Plus, now the special-display frame that I define for `*Completions*' is not
 > even used.  Instead, buffer/window `*Completions*' is shown in a regular frame.

Probably because `pop-up-frames' is t on your system so
`pop-up-frame-alist' prevails.  Again, what are the
special-display-... related values for *Completions*?

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-17 15:51           ` Drew Adams
  2011-06-17 16:22             ` bug#8856: " martin rudalics
@ 2011-06-17 17:48             ` Drew Adams
  2011-06-19 13:26               ` martin rudalics
       [not found]               ` <4DFE09A7.10500@gmx.at>
  1 sibling, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-17 17:48 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

>  > Wrt bug #8856 also, the same symptoms reported initially 
>  > are still there (frame selection/focus problem).
>  >
>  > Plus, now the special-display frame that I define for 
>  > `*Completions*' is not even used.  Instead, buffer/window
>  > `*Completions*' i shown in a regular frame.
> 
> Probably because `pop-up-frames' is t on your system so
> `pop-up-frame-alist' prevails.  Again, what are the
> special-display-... related values for *Completions*?

`pop-up-frames' is t, from oneonone.el.
I do not define `pop-up-frame-alist'.

I gave you the value of `special-display-regexps'.  Here it is again: ("[
]?[*][^*]+[*]"))

>  > Here again is that recipe (after startup as shown above):
>  > > M-x f TAB ; to display *Completions* frame.
>  > > C-]       ; to return to top level.
>  > > M-x f TAB o
>  > > Or just hit TAB twice in a row: M-x f TAB TAB.
>  > > IOW, try to type more input in minibuffer.  This raises the error
>  > > "Buffer is read-only #<buffer *Completions*>"

The recipe, one more time:

runemacs.exe -Q --debug-init -l "hexrgb.el" -l "oneonone.el" -f "1on1-emacs"
 
Download the two files mentioned from here:
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24

1. Load your new window.el that you just sent me (but see below).

2. (setq special-display-regexps '("[ ]?[*][^*]+[*]"))

So far, the recipe is the same for bug #8851 and #8856.  Now it changes.

3. Do this:
 
M-x f TAB ; to display *Completions* frame.
C-]       ; to return to top level.

M-x f TAB o

Or just hit TAB twice in a row: M-x f TAB TAB.  IOW, try to type more
input in minibuffer.

The bug reported for #8856 is that this then raises the error
"Buffer is read-only #<buffer *Completions*>"

However, as I said, with the window.el version you just sent me there is now an
additional bug - presumably the same additional bug mentioned in #8851 (wrt
buffer `*Buffer List*'): `*Completions*' is no longer shown in a special-display
frame at all.  It is now shown in the same window of the original buffer
(`*scratch*' presumably, by default from emacs -Q).

Can you reproduce the problems?  Try first without step #1, to see the bug I
reported.  Try with step #1 to see that your fix just adds another problem.

The first step is to reproduce the problem.  Then we can try to debug it.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-17 16:22             ` bug#8856: " martin rudalics
@ 2011-06-17 17:48               ` Drew Adams
  2011-06-19 17:29                 ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-17 17:48 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8851

> So you somewhere have settings for this buffer in
> `special-display-buffer-names' or `special-display-regexps'.  
> Why can't you send me them?

I gave you this info in the initial bug report.  Here it is again:

> I have non-nil `pop-up-frames'.  I use a special-display frame for
> buffers such as `*Buffer List*' and `*info*'.  
> My value of `special-display-regexps' is this:
> ("[ ]?[*][^*]+[*]")
>
>  > Here is a recipe (you just need to download the same 2 
>  > files as for the recipe for bug #8856).
>
> I need a simple recipe from emacs -Q.

I gave you one.  Here it is again:

runemacs.exe -Q --debug-init -l "hexrgb.el" -l "oneonone.el" -f "1on1-emacs"
 
Download the two files mentioned from here:
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24

1. Load your new window.el that you just sent me (but see below).

2. (setq special-display-regexps '("[ ]?[*][^*]+[*]"))

So far, the recipe is the same for bug #8851 and #8856.  Now it changes.

3.
> visit a file foo.el, then use `C-x 5 0' to remove its frame.

It doesn't matter what file you use here, as long as its buffer name doesn't
match `special-display-regexps'.

4.
> hit C-x C-b and get the buffer menu in a new, special-display frame.

This part is now broken also, using the window.el you sent me: the frame is not
a special-display frame anymore.

(See oneonone.el for the definition of `special-display-frame-alist' etc.)

5.
> click mouse-2 on the foo.el line to visit that file.

foo.el is displayed in the same frame and window as *Buffer List* was displayed.
That's the bug.  But now the behavior is mixed up with the new bug of not even
showing *Buffer List* in a special-display frame.

> What I need are your settings wrt special-display-... and
> the buffer in question.  Why can't you post these?

There is no particular buffer in question (do you mean foo.el?), and you have
the `special-display-regexps' setting.  Please just follow the recipe.

Can you reproduce the problems?  Try first without step #1, to see the bug I
reported.  Try with step #1 to see that your fix just adds another problem.

The first step is to reproduce the problem.  Then we can try to debug it.







^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-17 17:48             ` bug#8856: " Drew Adams
@ 2011-06-19 13:26               ` martin rudalics
  2011-06-19 14:31                 ` bug#8856: 24.0.50;regression: `special-display-frame' broken Drew Adams
       [not found]               ` <4DFE09A7.10500@gmx.at>
  1 sibling, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-19 13:26 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > The recipe, one more time:
 >
 > runemacs.exe -Q --debug-init -l "hexrgb.el" -l "oneonone.el" -f "1on1-emacs"
 >
 > Download the two files mentioned from here:
 > http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
 > 3F%24

I'm not going to do that.  If you can provide me a self-contained test
that doesn't require to download any files I shall follow your advices.

But I have done the check below.

When I add the name of a buffer *text* to `special-display-buffer-names'
I have three choices - a plain string, an alist of parameter value
pairs, or a function with arguments.  These give the three cases below
when evaluating (display-buffer (get-buffer-create "*text*")):

(1) special-display-buffer-names --> ("*text*")

     calls `special-display-popup-frame' with the argument

     nil

(2) special-display-buffer-names --> (("*text*" (x . 3) (y . 4)))

     calls `special-display-popup-frame' with the argument

     ((x . 3) (y . 4))

(3) special-display-buffer-names -->  (("*text*" ignore (3 4)))

     calls `special-display-popup-frame' with the argument

     (ignore (3 4))

All three cases give the same results here for `display-buffer' before
and after my changes.  If you see the same values, the handling of
special buffers is not affected by the changes.  If you see a different
behavior, please tell me what you see.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50;regression: `special-display-frame' broken
  2011-06-19 13:26               ` martin rudalics
@ 2011-06-19 14:31                 ` Drew Adams
  2011-06-19 18:50                   ` Chong Yidong
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-19 14:31 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 2837 bytes --]

>  > The recipe, one more time:
>  >
>  > runemacs.exe -Q --debug-init -l "hexrgb.el" -l 
>  > "oneonone.el" -f "1on1-emacs"
>  >
>  > Download the two files mentioned from here:
>  > 
>  >
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24
> 
> I'm not going to do that.  If you can provide me a self-contained test
> that doesn't require to download any files I shall follow 
> your advices.

I see.  You introduce a regression but won't click a link.

OK, in that case see attached.  These are the same two files for the recipes of
the other regressions reported.  They are not large, and they are all you need -
the recipe is a self-contained test.

> But I have done the check below.
> 
> When I add the name of a buffer *text*
> to `special-display-buffer-names'

Please follow the recipe.  As you know, buffer *Completions* is not just any
buffer - it is not *text*.  It is closely connected with the minibuffer.  And in
this case the minibuffer is in a standalone frame.  And frame focus for the
*Completions* frame is redirected to the minibuffer frame.

I have explained all of that, and it is all in the recipe code that you can
test.
  
> I have three choices - a plain string, an alist of parameter value
> pairs, or a function with arguments.  These give the three cases below
> when evaluating (display-buffer (get-buffer-create "*text*")):

Why invent?  I gave you exactly which of the three choices is used.  If you
simply look at the code or load it and use `C-h v special-display-buffer-names'
you'll see it:

Value: (("*Completions*" 1on1-display-*Completions*-frame
  ((background-color . "LavenderBlush2")
   (mouse-color . "VioletRed")
   (cursor-color . "VioletRed")
   (menu-bar-lines . 0)
   (tool-bar-lines . 0)
   (width . 100)))
 ("*Help*" 1on1-display-*Help*-frame
  ((background-color . "Thistle")
   (mouse-color . "Blue Violet")
   (cursor-color . "Blue Violet")
   (height . 40))))

> (3) special-display-buffer-names -->  (("*text*" ignore (3 4)))
>      calls `special-display-popup-frame' with the argument
> 
>      (ignore (3 4))
> 
> All three cases give the same results here for `display-buffer' before
> and after my changes.  If you see the same values, the handling of
> special buffers is not affected by the changes.  If you see a 
> different behavior, please tell me what you see.

See above.  *Completions* is not *text*.  *Completions* is tied to the
minibuffer.  The minibuffer is in a standalone frame.  The *Completions* frame
focus is redirected to the minibuffer frame.

Please try the simple (3-4 lines) recipe, using the attached code.  That's the
first step: reproduce the problem.

Then we can try to dig down to its kernel and find a solution.  You haven't even
taken the 1-2 minutes needed to see if you can reproduce it on your system.



[-- Attachment #2: hexrgb.el --]
[-- Type: application/octet-stream, Size: 34475 bytes --]

;;; hexrgb.el --- Functions to manipulate colors, including RGB hex strings.
;;
;; Filename: hexrgb.el
;; Description: Functions to manipulate colors, including RGB hex strings.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 2004-2011, Drew Adams, all rights reserved.
;; Created: Mon Sep 20 22:58:45 2004
;; Version: 21.0
;; Last-Updated: Sun May 22 13:36:17 2011 (-0700)
;;           By: dradams
;;     Update #: 784
;; URL: http://www.emacswiki.org/cgi-bin/wiki/hexrgb.el
;; Keywords: number, hex, rgb, color, background, frames, display
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
;;
;; Features that might be required by this library:
;;
;;   None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;;  Functions to manipulate colors, including RGB hex strings.
;;
;;  This library provides functions for converting between RGB (red,
;;  green, blue) color components and HSV (hue, saturation, value)
;;  color components.  It helps you convert among Emacs color
;;  components (whole numbers from 0 through 65535), RGB and HSV
;;  floating-point components (0.0 through 1.0), Emacs color-name
;;  strings (such as "blue"), and hex RGB color strings (such as
;;  "#FC43A7912").
;;
;;  An RGB hex string, such as used as a frame `background-color'
;;  property, is a string of 1 + (3 * n) characters, the first of
;;  which is "#".  The other characters are hexadecimal digits, in
;;  three groups representing (from the left): red, green, and blue
;;  hex codes.
;;
;;  Constants defined here:
;;
;;    `hexrgb-defined-colors', `hexrgb-defined-colors-alist',
;;    `hexrgb-defined-colors-no-dups',
;;    `hexrgb-defined-colors-no-dups-alist'.
;;
;;  Options defined here:
;;
;;    `hexrgb-canonicalize-defined-colors-flag'.
;;
;;  Commands defined here:
;;
;;    `hexrgb-blue', `hexrgb-complement', `hexrgb-green',
;;    `hexrgb-hue', `hexrgb-read-color', `hexrgb-red',
;;    `hexrgb-saturation', `hexrgb-value'.
;;
;;  Non-interactive functions defined here:
;;
;;    `hexrgb-approx-equal', `hexrgb-canonicalize-defined-colors',
;;    `hexrgb-color-name-to-hex', `hexrgb-color-values-to-hex',
;;    `hexrgb-color-value-to-float', `hexrgb-defined-colors',
;;    `hexrgb-defined-colors-alist',
;;    `hexrgb-delete-whitespace-from-string',
;;    `hexrgb-float-to-color-value', `hexrgb-hex-char-to-integer',
;;    `hexrgb-hex-to-color-values', `hexrgb-hex-to-hsv',
;;    `hexrgb-hex-to-rgb', `hexrgb-hsv-to-hex', `hexrgb-hex-to-int',
;;    `hexrgb-hsv-to-rgb', `hexrgb-increment-blue',
;;    `hexrgb-increment-equal-rgb', `hexrgb-increment-green',
;;    `hexrgb-increment-hex', `hexrgb-increment-red',
;;    `hexrgb-int-to-hex', `hexrgb-rgb-hex-string-p',
;;    `hexrgb-rgb-to-hex', `hexrgb-rgb-to-hsv'.
;;
;;
;;  Add this to your initialization file (~/.emacs or ~/_emacs):
;;
;;    (require 'hexrgb)
;;
;;  Do not try to use this library without a window manager.
;;  That is, do not use this with `emacs -nw'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;; 2011/02/16 dadams
;;     hexrgb-increment-hex: INCOMPATIBLE CHANGE:
;;                           Swapped order of args NB-DIGITS, INCREMENT, to fit other functions.
;;     hexrgb-increment-*: Took the change to hexrgb-increment-hex into account.
;;     Improved various doc strings.
;; 2011/01/08 dadams
;;     Restored autoload cookie for eval-and-compile hexrgb-canonicalize-defined-colors.
;; 2011/01/03 dadams
;;     Removed autoload cookies from non-interactive functions.
;; 2010/12/18 dadams
;;     hexrgb-canonicalize-defined-colors: Added autoload cookie.  Thx to Richard Kim.
;; 2010/12/06 dadams
;;     hexrgb-hex-to-color-values: Correct start offset for blue.  Thx to "Linda" on Emacs Wiki.
;; 2009/11/14 dadams
;;    hexrgb-rgb-to-hsv: Corrected hue when > 1.0.  Use strict inequality for hue limit tests.
;;    hexrgb-approx-equal: Convert RFUZZ and AFUZZ to their absolute values.
;; 2009/11/03 dadams
;;    Added: hexrgb-delete-whitespace-from-string, hexrgb-canonicalize-defined-colors,
;;           hexrgb-defined-colors(-no-dups)(-alist), hexrgb-canonicalize-defined-colors-flag.
;;    hexrgb-read-color: Use function hexrgb-defined-colors-alist, not the constant.
;; 2008/12/25 dadams
;;    hexrgb-rgb-to-hsv:
;;      Replace (not (equal 0.0e+NaN saturation)) by standard test (= saturation saturation).
;;      Thx to  Michael Heerdegen for the bug report.
;; 2008-10-17 dadams
;;    hexrgb-defined-colors(-alist): Prevent load-time error if user tries to use emacs -nw.
;; 2007/12/30 dadams
;;    Added: hexrgb-hex-to-color-values.
;; 2007/10/20 dadams
;;    hexrgb-read-color: Treat pseudo colors too (e.g. *point foreground*).
;; 2007/01/21 dadams
;;    hexrgb-read-color: Error if empty string (and not allow-empty-name-p).
;; 2006/06/06 dadams
;;    Added: hexrgb-defined-colors(-alist).  Use instead of (x-defined-colors).
;;    hexrgb-(red|green|blue): Added interactive specs.
;; 2006/06/04 dadams
;;    hexrgb-read-color: Added optional arg allow-empty-name-p.
;; 2006/06/02 dadams
;;    Added: hexrgb-rgb-hex-string-p.  Used it.
;; 2006/05/30 dadams
;;    Added: hexrgb-hex-to-(hsv|rgb), hexrgb-hsv-to-hex, hexrgb-color-name-to-hex,
;;           hexrgb-complement, hexrgb-read-color, hexrgb-hue, hexrgb-saturation,
;;           hexrgb-value, hexrgb-red, hexrgb-blue, hexrgb-green.
;;    approx-equal: Add optional fuzz factor arguments.  Changed the algorithm.
;;    Renamed: approx-equal to hexrgb-approx-equal.
;;    hexrgb-rgb-to-hsv: Changed test from < to <=: (when (<= hue 0.0)...).
;;    hexrgb-hsv-to-rgb: Treat hue = 0.0 (int 0) the same as hue = 1.0 (int 6).
;;    hexrgb-rgb-to-hex, hexrgb-increment-hex: Corrected doc strings.
;; 2006/05/22 dadams
;;    Added: hexrgb-hsv-to-hex, hexrgb-rgb-to-hex.  Require cl.el when byte-compile.
;; 2005/08/09 dadams
;;    hexrgb-rgb-to-hsv: Side-stepped Emacs-20 bug in comparing NaN.
;;    hexrgb-increment-*: Added optional arg wrap-p.
;;    hexrgb-increment-hex: Prevent wrap if not wrap-p.
;; 2005/08/02 dadams
;;    hexrgb-rgb-to-hes: Bug fix: If delta is zero, then so are hue and saturation.
;; 2005/06/24 dadams
;;    hexrgb-rgb-to-hsv: Bug fix: test for NaN (e.g. on divide by zero).
;; 2005/02/08 dadams
;;    hexrgb-hsv-to-rgb: Bug fix (typo: p, q -> pp, qq; added ww).
;; 2005/01/09 dadams
;;    hexrgb-int-to-hex: Fixed bug in hexrgb-int-to-hex: nb-digits not respected.
;;    Added: hexrgb-hsv-to-rgb, hexrgb-rgb-to-hsv, approx-equal.
;;    Renamed old hexrgb-increment-value to hexrgb-increment-equal-rgb.
;; 2005/01/05 dadams
;;    hexrgb-int-to-hex: Used a suggestion from Juri Linkov.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(eval-when-compile (require 'cl)) ;; case

;; Unless you first load `hexrgb.el', then either `palette.el' or `eyedropper.el', you will get
;; warnings about variables and functions with prefix `eyedrop-' when you byte-compile
;; `hexrgb.el'.  You can ignore these warnings.

(defvar eyedrop-picked-foreground)
(defvar eyedrop-picked-background)

;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;###autoload
(eval-and-compile
 (defun hexrgb-canonicalize-defined-colors (list)
   "Copy of LIST with color names canonicalized.
LIST is a list of color names (strings).
Canonical names are lowercase, with no whitespace.
There are no duplicate names."
   (let ((tail  list)
         this new)
     (while tail
       (setq this  (car tail)
             this  (hexrgb-delete-whitespace-from-string (downcase this) 0 (length this)))
       (unless (member this new) (push this new))
       (pop tail))
     (nreverse new)))

 (defun hexrgb-delete-whitespace-from-string (string &optional from to)
   "Remove whitespace from substring of STRING from FROM to TO.
If FROM is nil, then start at the beginning of STRING (FROM = 0).
If TO is nil, then end at the end of STRING (TO = length of STRING).
FROM and TO are zero-based indexes into STRING.
Character FROM is affected (possibly deleted).  Character TO is not."
   (setq from  (or from 0)
         to    (or to (length string)))
   (with-temp-buffer
     (insert string)
     (goto-char (+ from (point-min)))
     (let ((count  from)
           char)
       (while (and (not (eobp))  (< count to))
         (setq char  (char-after))
         (if (memq char '(?\  ?\t ?\n))  (delete-char 1)  (forward-char 1))
         (setq count  (1+ count)))
       (buffer-string)))))

;;;###autoload
(defconst hexrgb-defined-colors (eval-when-compile (and window-system (x-defined-colors)))
  "List of all supported colors.")

;;;###autoload
(defconst hexrgb-defined-colors-no-dups
    (eval-when-compile
     (and window-system (hexrgb-canonicalize-defined-colors (x-defined-colors))))
  "List of all supported color names, with no duplicates.
Names are all lowercase, without any spaces.")

;;;###autoload
(defconst hexrgb-defined-colors-alist
    (eval-when-compile (and window-system (mapcar #'list (x-defined-colors))))
  "Alist of all supported color names, for use in completion.
See also `hexrgb-defined-colors-no-dups-alist', which is the same
thing, but without any duplicates, such as \"light blue\" and
\"LightBlue\".")

;;;###autoload
(defconst hexrgb-defined-colors-no-dups-alist
    (eval-when-compile
     (and window-system
          (mapcar #'list (hexrgb-canonicalize-defined-colors (x-defined-colors)))))
  "Alist of all supported color names, with no duplicates, for completion.
Names are all lowercase, without any spaces.")

;;;###autoload
(defcustom hexrgb-canonicalize-defined-colors-flag t
  "*Non-nil means remove duplicate color names.
Names are considered duplicates if they are the same when abstracting
from whitespace and letter case."
  :type 'boolean
  :group 'Icicles :group 'doremi-frame-commands :group 'faces :group 'convenience)

;; You should use these two functions, not the constants, so users can change
;; the behavior by customizing `hexrgb-canonicalize-defined-colors-flag'.

(defun hexrgb-defined-colors ()
  "List of supported color names.
If `hexrgb-canonicalize-defined-colors-flag' is non-nil, then names
are lowercased, whitespace is removed, and there are no duplicates."
  (if hexrgb-canonicalize-defined-colors-flag
      hexrgb-defined-colors-no-dups
    hexrgb-defined-colors))

(defun hexrgb-defined-colors-alist ()
  "Alist of supported color names.  Usable for completion.
If `hexrgb-canonicalize-defined-colors-flag' is non-nil, then names
are lowercased, whitespace is removed, and there are no duplicates."
  (if hexrgb-canonicalize-defined-colors-flag
      hexrgb-defined-colors-no-dups-alist
    hexrgb-defined-colors-alist))

;; RMS added this function to Emacs (23) as `read-color', with some feature loss.
;;;###autoload
(defun hexrgb-read-color (&optional convert-to-RGB-p allow-empty-name-p prompt)
  "Read a color name or RGB hex value: #RRRRGGGGBBBB.
Completion is available for color names, but not for RGB hex strings.
If you input an RGB hex string, it must have the form #XXXXXXXXXXXX or
XXXXXXXXXXXX, where each X is a hex digit.  The number of Xs must be a
multiple of 3, with the same number of Xs for each of red, green, and
blue.  The order is red, green, blue.

Color names that are normally considered equivalent are canonicalized:
They are lowercased, whitespace is removed, and duplicates are
eliminated.  E.g. \"LightBlue\" and \"light blue\" are both replaced
by \"lightblue\".  If you do not want this behavior, but want to
choose names that might contain whitespace or uppercase letters, then
customize option `hexrgb-canonicalize-defined-colors-flag' to nil.

In addition to standard color names and RGB hex values, the following
are available as color candidates.  In each case, the corresponding
color is used.

* `*copied foreground*'  - last copied foreground, if available
* `*copied background*'  - last copied background, if available
* `*mouse-2 foreground*' - foreground where you click `mouse-2'
* `*mouse-2 background*' - background where you click `mouse-2'
* `*point foreground*'   - foreground under the cursor
* `*point background*'   - background under the cursor

\(You can copy a color using eyedropper commands such as
`eyedrop-pick-foreground-at-mouse'.)

Checks input to be sure it represents a valid color.  If not, raises
an error (but see exception for empty input with non-nil
ALLOW-EMPTY-NAME-P).

Interactively, or with optional arg CONVERT-TO-RGB-P non-nil, converts
an input color name to an RGB hex string.  Returns the RGB hex string.

Optional arg ALLOW-EMPTY-NAME-P controls what happens if you enter an
empty color name (that is, you just hit `RET').  If non-nil, then
`hexrgb-read-color' returns an empty color name, \"\".  If nil, then
it raises an error.  Programs must test for \"\" if ALLOW-EMPTY-NAME-P
is non-nil.  They can then perform an appropriate action in case of
empty input.

Optional arg PROMPT is the prompt.  Nil means use a default prompt."
  (interactive "p")                     ; Always convert to RGB interactively.
  (let* ((completion-ignore-case  t)
         ;; Free variables here: `eyedrop-picked-foreground', `eyedrop-picked-background'.
         ;; They are defined in library `palette.el' or library `eyedropper.el'.
         (colors                  (if (fboundp 'eyedrop-foreground-at-point)
                                      (append (and eyedrop-picked-foreground
                                                   '(("*copied foreground*")))
                                              (and eyedrop-picked-background
                                                   '(("*copied background*")))
                                              '(("*mouse-2 foreground*")
                                                ("*mouse-2 background*")
                                                ("*point foreground*") ("*point background*"))
                                              (hexrgb-defined-colors-alist))
                                    (hexrgb-defined-colors-alist)))
         (color                   (completing-read (or prompt "Color (name or #R+G+B+): ")
                                                   colors))
         hex-string)
    (when (fboundp 'eyedrop-foreground-at-point)
      (cond ((string= "*copied foreground*" color) (setq color  eyedrop-picked-foreground))
            ((string= "*copied background*" color) (setq color  eyedrop-picked-background))
            ((string= "*point foreground*" color)  (setq color  (eyedrop-foreground-at-point)))
            ((string= "*point background*" color)  (setq color  (eyedrop-background-at-point)))
            ((string= "*mouse-2 foreground*" color)
             (setq color  (prog1 (eyedrop-foreground-at-mouse
                                  (read-event "Click `mouse-2' to choose foreground color - "))
                            (read-event)))) ; Discard mouse up event.
            ((string= "*mouse-2 background*" color)
             (setq color  (prog1 (eyedrop-background-at-mouse
                                  (read-event "Click `mouse-2' to choose background color - "))
                            (read-event)))))) ; Discard mouse up event.
    (setq hex-string  (or (string-match "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)
                          (and (string-match "^\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)
                               t)))
    (if (and allow-empty-name-p (string= "" color))
        ""
      (when (and hex-string (not (eq 0 hex-string)))
        (setq color  (concat "#" color))) ; No #; add it.
      (unless hex-string
        (when (or (string= "" color)
                  (not (if (fboundp 'test-completion) ; Not defined in Emacs 20.
                           (test-completion color colors)
                         (try-completion color colors))))
          (error "No such color: %S" color))
        (when convert-to-RGB-p (setq color  (hexrgb-color-name-to-hex color))))
      (when (interactive-p) (message "Color: `%s'" color))
      color)))

(defun hexrgb-rgb-hex-string-p (color &optional laxp)
  "Non-nil if COLOR is an RGB string #XXXXXXXXXXXX.
Each X is a hex digit.  The number of Xs must be a multiple of 3, with
the same number of Xs for each of red, green, and blue.

Non-nil optional arg LAXP means that the initial `#' is optional.  In
that case, for a valid string of hex digits: when # is present 0 is
returned; otherwise, t is returned."
  (or (string-match "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)
      (and laxp (string-match "^\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color) t)))

;;;###autoload
(defun hexrgb-complement (color)
  "Return the color that is the complement of COLOR."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (let ((red    (hexrgb-red color))
        (green  (hexrgb-green color))
        (blue   (hexrgb-blue color)))
    (setq color  (hexrgb-rgb-to-hex (- 1.0 red) (- 1.0 green) (- 1.0 blue))))
  (when (interactive-p) (message "Complement: `%s'" color))
  color)

;;;###autoload
(defun hexrgb-hue (color)
  "Return the hue component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (car (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) (hexrgb-blue color))))

;;;###autoload
(defun hexrgb-saturation (color)
  "Return the saturation component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (cadr (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) (hexrgb-blue color))))

;;;###autoload
(defun hexrgb-value (color)
  "Return the value component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (caddr (hexrgb-rgb-to-hsv (hexrgb-red color) (hexrgb-green color) (hexrgb-blue color))))

;;;###autoload
(defun hexrgb-red (color)
  "Return the red component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (/ (hexrgb-hex-to-int (substring color 1 (1+ (/ (1- (length color)) 3))))
     (expt 16.0 (/ (1- (length color)) 3.0))))

;;;###autoload
(defun hexrgb-green (color)
  "Return the green component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (let* ((len    (/ (1- (length color)) 3))
         (start  (1+ len)))
    (/ (hexrgb-hex-to-int (substring color start (+ start len)))
       (expt 16.0 (/ (1- (length color)) 3.0)))))

;;;###autoload
(defun hexrgb-blue (color)
  "Return the blue component of COLOR, in range 0 to 1 inclusive.
COLOR is a color name or hex RGB string that starts with \"#\"."
  (interactive (list (hexrgb-read-color)))
  (setq color  (hexrgb-color-name-to-hex color))
  (let* ((len    (/ (1- (length color)) 3))
         (start  (+ 1 len len)))
    (/ (hexrgb-hex-to-int (substring color start (+ start len)))
       (expt 16.0 (/ (1- (length color)) 3.0)))))

(defun hexrgb-rgb-to-hsv (red green blue)
  "Convert RED, GREEN, BLUE components to HSV (hue, saturation, value).
Each input component is 0.0 to 1.0, inclusive.
Returns a list of HSV components of value 0.0 to 1.0, inclusive."
  (let* ((min    (min red green blue))
         (max    (max red green blue))
         (value  max)
         (delta  (- max min))
         hue saturation)
    (if (hexrgb-approx-equal 0.0 delta)
        (setq hue         0.0
              saturation  0.0)          ; Gray scale - no color; only value.
      (if (and (condition-case nil
                   (setq saturation  (/ delta max))
                 (arith-error nil))
               ;; Must be a number, not a NaN.  The standard test for a NaN is (not (= N N)),
               ;; but an Emacs 20 bug makes (= N N) return t for a NaN also.
               (or (< emacs-major-version 21) (= saturation saturation)))                
          (if (hexrgb-approx-equal 0.0 saturation)
              (setq hue         0.0
                    saturation  0.0)    ; Again, no color; only value.
            ;; Color
            (setq hue  (if (hexrgb-approx-equal red max)
                           (/ (- green blue) delta) ; Between yellow & magenta.
                         (if (hexrgb-approx-equal green max)
                             (+ 2.0 (/ (- blue red) delta)) ; Between cyan & yellow.
                           (+ 4.0 (/ (- red green) delta)))) ; Between magenta & cyan.
                  hue  (/ hue 6.0))
            ;; (when (<= hue 0.0) (setq hue  (+ hue 1.0)))  ; $$$$$$
            ;; (when (>= hue 1.0) (setq hue  (- hue 1.0)))) ; $$$$$$
            (when (< hue 0.0) (setq hue  (+ hue 1.0)))
            (when (> hue 1.0) (setq hue  (- hue 1.0))))
        (setq hue         0.0           ; Div by zero (max=0): H:=0, S:=0. (Hue undefined.)
              saturation  0.0)))
    (list hue saturation value)))

(defun hexrgb-hsv-to-rgb (hue saturation value)
  "Convert HUE, SATURATION, VALUE components to RGB (red, green, blue).
Each input component is 0.0 to 1.0, inclusive.
Returns a list of RGB components of value 0.0 to 1.0, inclusive."
  (let (red green blue int-hue fract pp qq tt ww)
    (if (hexrgb-approx-equal 0.0 saturation)
        (setq red    value
              green  value
              blue   value)             ; Gray
      (setq hue      (* hue 6.0)        ; Sectors: 0 to 5
            int-hue  (floor hue)
            fract    (- hue int-hue)
            pp       (* value (- 1 saturation))
            qq       (* value (- 1 (* saturation fract)))
            ww       (* value (- 1 (* saturation (- 1 (- hue int-hue))))))
      (case int-hue
        ((0 6) (setq red    value
                     green  ww
                     blue   pp))
        (1 (setq red    qq
                 green  value
                 blue   pp))
        (2 (setq red    pp
                 green  value
                 blue   ww))
        (3 (setq red    pp
                 green  qq
                 blue   value))
        (4 (setq red    ww
                 green  pp
                 blue   value))
        (otherwise (setq red    value
                         green  pp
                         blue   qq))))
    (list red green blue)))

(defun hexrgb-hsv-to-hex (hue saturation value)
  "Return the hex RBG color string for inputs HUE, SATURATION, VALUE.
The inputs are each in the range 0 to 1.
The output string is of the form \"#RRRRGGGGBBBB\"."
  (hexrgb-color-values-to-hex
   (mapcar (lambda (x) (floor (* x 65535.0))) (hexrgb-hsv-to-rgb hue saturation value))))

(defun hexrgb-rgb-to-hex (red green blue)
  "Return the hex RBG color string for inputs RED, GREEN, BLUE.
The inputs are each in the range 0 to 1.
The output string is of the form \"#RRRRGGGGBBBB\"."
  (hexrgb-color-values-to-hex
   (mapcar (lambda (x) (floor (* x 65535.0))) (list red green blue))))

(defun hexrgb-hex-to-hsv (color)
  "Return a list of HSV (hue, saturation, value) color components.
Each component is a value from 0.0 to 1.0, inclusive.
COLOR is a color name or a hex RGB string that starts with \"#\" and
is followed by an equal number of hex digits for red, green, and blue
components."
  (let ((rgb-components  (hexrgb-hex-to-rgb color)))
    (apply #'hexrgb-rgb-to-hsv rgb-components)))

(defun hexrgb-hex-to-rgb (color)
  "Return a list of RGB (red, green, blue) color components.
Each component is a value from 0.0 to 1.0, inclusive.
COLOR is a color name or a hex RGB string that starts with \"#\" and
is followed by an equal number of hex digits for red, green, and blue
components."
  (unless (hexrgb-rgb-hex-string-p color) (setq color  (hexrgb-color-name-to-hex color)))
  (let ((len  (/ (1- (length color)) 3)))
    (list (/ (hexrgb-hex-to-int (substring color 1 (1+ len))) 65535.0)
          (/ (hexrgb-hex-to-int (substring color (1+ len) (+ 1 len len))) 65535.0)
          (/ (hexrgb-hex-to-int (substring color (+ 1 len len))) 65535.0))))

(defun hexrgb-color-name-to-hex (color)
  "Return the RGB hex string for the COLOR name, starting with \"#\".
If COLOR is already a string starting with \"#\", then just return it."
  (let ((components  (x-color-values color)))
    (unless components (error "No such color: %S" color))
    (unless (hexrgb-rgb-hex-string-p color)
      (setq color  (hexrgb-color-values-to-hex components))))
  color)

;; Color "components" would be better in the name than color "value"
;; but this name follows the Emacs tradition (e.g. `x-color-values',
;; 'ps-color-values', `ps-e-x-color-values').
(defun hexrgb-color-values-to-hex (components)
  "Convert list of rgb color COMPONENTS to a hex string, #XXXXXXXXXXXX.
Each X in the string is a hexadecimal digit.
Input COMPONENTS is as for the output of `x-color-values'."
;; Just hard-code 4 as the number of hex digits, since `x-color-values'
;; seems to produce appropriate integer values for `4'.
  (concat "#" (hexrgb-int-to-hex (nth 0 components) 4) ; red
          (hexrgb-int-to-hex (nth 1 components) 4) ; green
          (hexrgb-int-to-hex (nth 2 components) 4))) ; blue

(defun hexrgb-hex-to-color-values (color)
  "Convert hex COLOR to a list of RGB color components.
COLOR is a hex rgb color string, #XXXXXXXXXXXX
Each X in the string is a hexadecimal digit.  There are 3N X's, N > 0.
The output list is as for `x-color-values'."
  (let* ((hex-strgp  (string-match
                      "^\\(#\\)?\\(\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+\\)$"
                      color))
         (ndigits    (/ (if (eq (match-beginning 1) (match-end 1))
                            (length color)
                          (1- (length color)))
                        3))
         red green blue)
    (unless hex-strgp (error "Invalid RGB color string: %s" color))
    (setq color  (substring color (match-beginning 2) (match-end 2))
          red    (hexrgb-hex-to-int (substring color 0 ndigits))
          green  (hexrgb-hex-to-int (substring color ndigits (* 2 ndigits)))
          blue   (hexrgb-hex-to-int (substring color (* 2 ndigits) (* 3 ndigits))))
    (list red green blue)))
    
(defun hexrgb-increment-red (hex nb-digits increment &optional wrap-p)
  "Increment red component of rgb string HEX by INCREMENT.
String HEX starts with \"#\".  Each color is NB-DIGITS hex digits long.
If optional arg WRAP-P is non-nil then the result wraps around zero.
  For example, with NB-DIGITS 3, incrementing \"#fffffffff\" by 1
  causes it to wrap around to \"#000ffffff\"."
  (concat "#"
          (hexrgb-increment-hex (substring hex 1 (1+ nb-digits)) nb-digits increment wrap-p)
          (substring hex (1+ nb-digits) (1+ (* nb-digits 2)))
          (substring hex (1+ (* nb-digits 2)))))

(defun hexrgb-increment-green (hex nb-digits increment &optional wrap-p)
  "Increment green component of rgb string HEX by INCREMENT.
String HEX starts with \"#\".  Each color is NB-DIGITS hex digits long.
If optional arg WRAP-P is non-nil then the result wraps around zero.
  For example, with NB-DIGITS 3, incrementing \"#fffffffff\" by 1
  causes it to wrap around to \"#fff000fff\"."
  (concat
   "#" (substring hex 1 (1+ nb-digits))
   (hexrgb-increment-hex (substring hex (1+ nb-digits) (1+ (* nb-digits 2)))
                         nb-digits
                         increment
                         wrap-p)
   (substring hex (1+ (* nb-digits 2)))))

(defun hexrgb-increment-blue (hex nb-digits increment &optional wrap-p)
  "Increment blue component of rgb string HEX by INCREMENT.
String HEX starts with \"#\".  Each color is NB-DIGITS hex digits long.
If optional arg WRAP-P is non-nil then the result wraps around zero.
  For example, with NB-DIGITS 3, incrementing \"#fffffffff\" by 1
  causes it to wrap around to \"#ffffff000\"."
  (concat "#" (substring hex 1 (1+ (* nb-digits 2)))
          (hexrgb-increment-hex (substring hex (1+ (* nb-digits 2)))
                                nb-digits
                                increment
                                wrap-p)))

(defun hexrgb-increment-equal-rgb (hex nb-digits increment &optional wrap-p)
  "Increment each color component (r,g,b) of rgb string HEX by INCREMENT.
String HEX starts with \"#\".  Each color is NB-DIGITS hex digits long.
If optional arg WRAP-P is non-nil then the result wraps around zero.
  For example, with NB-DIGITS 3, incrementing \"#fffffffff\" by 1
  causes it to wrap around to \"#000000000\"."
  (concat
   "#"
   (hexrgb-increment-hex (substring hex 1 (1+ nb-digits)) nb-digits increment wrap-p)
   (hexrgb-increment-hex (substring hex (1+ nb-digits) (1+ (* nb-digits 2)))
                         nb-digits
                         increment
                         wrap-p)
   (hexrgb-increment-hex (substring hex (1+ (* nb-digits 2))) nb-digits increment wrap-p)))

(defun hexrgb-increment-hex (hex nb-digits increment &optional wrap-p)
  "Increment hexadecimal-digits string HEX by INCREMENT.
Only the first NB-DIGITS of HEX are used.
If optional arg WRAP-P is non-nil then the result wraps around zero.
  For example, with NB-DIGITS 3, incrementing \"fff\" by 1 causes it
  to wrap around to \"000\"."
  (let* ((int      (hexrgb-hex-to-int hex))
         (new-int  (+ increment int)))
    (if (or wrap-p
            (and (>= int 0)             ; Not too large for the machine.
                 (>= new-int 0)         ; For the case where increment < 0.
                 (<= (length (format (concat "%X") new-int)) nb-digits))) ; Not too long.
        (hexrgb-int-to-hex new-int nb-digits) ; Use incremented number.
      hex)))                            ; Don't increment.

(defun hexrgb-hex-to-int (hex)
  "Convert HEX string argument to an integer.
The characters of HEX must be hex characters."
  (let* ((factor  1)
         (len     (length hex))
         (indx    (1- len))
         (int     0))
    (while (>= indx 0)
      (setq int     (+ int (* factor (hexrgb-hex-char-to-integer (aref hex indx))))
            indx    (1- indx)
            factor  (* 16 factor)))
    int))

;; From `hexl.el'.  This is the same as `hexl-hex-char-to-integer' defined there.
(defun hexrgb-hex-char-to-integer (character)
  "Take a CHARACTER and return its value as if it were a hex digit."
  (if (and (>= character ?0) (<= character ?9))
      (- character ?0)
    (let ((ch  (logior character 32)))
      (if (and (>= ch ?a) (<= ch ?f))
          (- ch (- ?a 10))
        (error "Invalid hex digit `%c'" ch)))))

;; Originally, I used the code from `int-to-hex-string' in `float.el'.
;; This version is thanks to Juri Linkov <juri@jurta.org>.
;;
(defun hexrgb-int-to-hex (int &optional nb-digits)
  "Convert integer argument INT to a #XXXXXXXXXXXX format hex string.
Each X in the output string is a hexadecimal digit.
NB-DIGITS is the number of hex digits.  If INT is too large to be
represented with NB-DIGITS, then the result is truncated from the
left.  So, for example, INT=256 and NB-DIGITS=2 returns \"00\", since
the hex equivalent of 256 decimal is 100, which is more than 2 digits."
  (setq nb-digits  (or nb-digits 4))
  (substring (format (concat "%0" (int-to-string nb-digits) "X") int) (- nb-digits)))

;; Inspired by Elisp Info manual, node "Comparison of Numbers".
(defun hexrgb-approx-equal (x y &optional rfuzz afuzz)
  "Return non-nil if numbers X and Y are approximately equal.
RFUZZ is a relative fuzz factor.  AFUZZ is an absolute fuzz factor.
RFUZZ defaults to 1.0e-8.  AFUZZ defaults to (/ RFUZZ 10).
RFUZZ and AFUZZ are converted to their absolute values.
The algorithm is:
 (< (abs (- X Y)) (+ AFUZZ (* RFUZZ (+ (abs X) (abs Y)))))."
  (setq rfuzz  (or rfuzz 1.0e-8)
        rfuzz  (abs rfuzz)
        afuzz  (or afuzz (/ rfuzz 10))
        afuzz  (abs afuzz))
  (< (abs (- x y)) (+ afuzz (* rfuzz (+ (abs x) (abs y))))))

(defun hexrgb-color-value-to-float (n)
  "Return the floating-point equivalent of color-component value N.
N must be an integer between 0 and 65535, or else an error is raised."
  (unless (and (wholenump n) (<= n 65535))
    (error "Not a whole number less than 65536"))
  (/ (float n) 65535.0))

(defun hexrgb-float-to-color-value (x)
  "Return the color-component value equivalent of floating-point number X.
X must be between 0.0 and 1.0, or else an error is raised."
  (unless (and (numberp x) (<= 0.0 x) (<= x 1.0))
    (error "Not a floating-point number between 0.0 and 1.0"))
  (floor (* x 65535.0)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide 'hexrgb)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; hexrgb.el ends here

[-- Attachment #3: oneonone.el --]
[-- Type: application/octet-stream, Size: 77239 bytes --]

;;; oneonone.el --- Frame configuration that uses one frame per window.
;;
;; Filename: oneonone.el
;; Description: Frame configuration that uses one frame per window.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1999-2011, Drew Adams, all rights reserved.
;; Created: Fri Apr  2 12:34:20 1999
;; Version: 21.1
;; Last-Updated: Sat Jun 18 08:18:01 2011 (-0700)
;;           By: dradams
;;     Update #: 2574
;; URL: http://www.emacswiki.org/cgi-bin/wiki/oneonone.el
;; Keywords: local, frames
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
;;
;; Features that might be required by this library:
;;
;;   `avoid', `cl', `frame-cmds', `frame-fns', `hexrgb', `misc-fns',
;;   `oneonone', `strings', `thingatpt', `thingatpt+', `zoom-frm'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;;    Frame configuration that uses one frame per window.
;;
;;  This library is part of One-on-One Emacs, a collection of
;;  libraries that try to make Emacs more frame-oriented and less
;;  window-oriented.
;;
;;  This library sets up Emacs to use multiple frames: individual
;;  frames are used, by default, instead of Emacs windows.  That is,
;;  the default is to use a frame for each Emacs window: one window on
;;  one frame.
;;
;;  You can configure each of the frames defined here.
;;
;;  Default properties are defined here for normal frames and
;;  "special" frames, which show "special-display buffers" (see Emacs
;;  manual for info on such frames).
;;
;;  In addition, these user options control the creation of three
;;  separate, specialized frames:
;;
;;    - `1on1-*Help*-frame-flag' - *Help* buffer frame
;;    - `1on1-*Completions*-frame-flag' - *Completions* buffer frame
;;    - `1on1-minibuffer-frame-flag' - minibuffer frame
;;
;;  Buffers *Help* and *Completions* are always displayed in their own
;;  frames.  In addition, if `1on1-*Help*-frame-flag' or
;;  `1on1-*Completions*-frame-flag' is non-nil, then the *Help* or
;;  *Completions* frame has a special (customizable) appearance.
;;
;;  If `1on1-minibuffer-frame-flag' is non-nil (the default value),
;;  then the minibuffer is shown in its own frame,
;;  `1on1-minibuffer-frame'; this is the only frame to have a
;;  minibuffer.  If you customize `1on1-minibuffer-frame-flag' to nil,
;;  then each frame will have its own minibuffer, as usual, and there
;;  will be no standalone minibuffer frame.
;;  
;;  By default, if you use a standalone minibuffer frame, it is
;;  automatically sized to the full width of your display and placed
;;  at the bottom of the display.
;;
;;  If `1on1-fit-minibuffer-frame-flag' is non-nil,
;;  `1on1-minibuffer-frame-flag' is non-nil, and you also use library
;;  `fit-frame.el', then, whenever the minibuffer is active, the
;;  minibuffer frame height is automatically adjusted to fit its
;;  content after each command or user event (e.g. each key press).
;;  Options `1on1-fit-minibuffer-frame-max-height' and
;;  `1on1-fit-minibuffer-frame-max-height-percent' define the maximum
;;  possible height for this behavior.  In addition, if you bind
;;  `1on1-fit-minibuffer-frame' to a key (I use `C-o'), then you can
;;  use that key repeatedly to increase the height by one line, even
;;  beyond the maximum.
;;
;;  To help you perceive changes to different minibuffer recursion
;;  levels, the background color of the minibuffer frame is changed
;;  slightly with each recursion-depth change.
;;
;;  This library is especially useful if used in combination with
;;  One-on-One Emacs libraries `autofit-frame.el', which automatically
;;  fits frames to their sole window, and `fit-frame.el', which lets
;;  you fit a frame to its selected window manually.  Library
;;  `autofit-frame.el' uses library `fit-frame.el'.
;;
;;  Because Emacs is not really designed to be frame-oriented, there
;;  are many built-in and standard functions that produce
;;  less-than-optimal results when frames, instead of windows, are the
;;  default.  In other One-on-One Emacs libraries, I have fixed most
;;  of these built-in functions to play well with frames.
;;
;;  For more information on One-on-One Emacs see
;;  http://www.emacswiki.org/cgi-bin/wiki/OneOnOneEmacs.
;;
;;  To use this library, put the following at the *END* of your init
;;  file, `.emacs' (or `_emacs').  In particular, if your init file
;;  contains a `custom-set-variables' expression, then the following
;;  must appear *AFTER* that expression, in order for this to take
;;  into account your customizations of any `1on1-' user options.
;;
;;    (require 'oneonone)
;;    (1on1-emacs)
;;
;;  Initial frame: By default, the initial Emacs frame is like all
;;  other normal (non-special-display) frames; that is,
;;  `initial-frame-alist' effectively uses the frame properties
;;  defined in `default-frame-alist'.  If you would like the initial
;;  frame to be different, set `default-frame-alist' to nil after
;;  requiring `oneonone.el' but before executing `1on1-emacs':
;;
;;    (require 'oneonone)
;;    (setq default-frame-alist nil)
;;    (setq initial-frame-alist '((background-color . "White"))); e.g.
;;    (1on1-emacs)
;;
;;  If you want the text cursor to change to a box when Emacs is idle,
;;  then add this line also to your init file:
;;
;;    (toggle-box-cursor-when-idle 1) ; Turn on box cursor when idle.
;;
;;  Info and Customize frames: I recommend that you put the following
;;  code in your init file, so that Info and Customize buffers will
;;  display in their own frames.  Which code to use depends on your
;;  version of GNU Emacs.
;;
;;    (cond ((< emacs-major-version 21)
;;           (remove-hook 'same-window-buffer-names "*info*"))
;;          ((= emacs-version 21)
;;           (remove-hook 'same-window-buffer-names "*info*")
;;           (remove-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'"))
;;          (t
;;           (remove-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
;;           (remove-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'")))
;;
;;  Recommended key bindings (requires library `fit-frame.el'):
;;
;;    (define-key minibuffer-local-map "\C-o"
;;                '1on1-fit-minibuffer-frame)
;;    (define-key minibuffer-local-must-match-map "\C-o"
;;                '1on1-fit-minibuffer-frame)
;;    (define-key minibuffer-local-completion-map "\C-o"
;;                '1on1-fit-minibuffer-frame)
;;
;;
;;  Notes on user options defined here:
;;  ---------------------------------
;;
;;  Some user options are used here only as conveniences to define
;;  frame-parameter alists.  They are defined using `defvar', not
;;  `defcustom', because you cannot use Customize to define them
;;  independently of the alist user options they help to define.  The
;;  alists themselves are the variables to customize.  If you want to
;;  change the `defvar' variables individually and then use them to
;;  set the alist variables, then use `setq', not Customize, to change
;;  them, and restart Emacs for their changes to take effect.
;;
;;  Changes to any user options defined here with `defcustom' will
;;  take effect as soon as `1on1-emacs' is executed, so you can do
;;  `M-x 1on1-emacs' to see their changes (no need to restart
;;  Emacs).
;;
;;  User options `1on1-color-minibuffer-frame-on-setup-increment' and
;;  `1on1-color-minibuffer-frame-on-exit-increment' determine how much
;;  to change the color of the minibuffer frame when the minibuffer is
;;  entered and exitted.  They are hue increments, and should be
;;  opposite in sign.  They should cancel each other out, so that the
;;  color returns to what it was initially at any given
;;  recursive-minibuffer depth.  However, because of the way HSV and
;;  RGB color-component conversion works, the best cancellation does
;;  not occur when these have the same absolute value.  And, how much
;;  their absolute values should differ depends on that magnitude.
;;  It's best to just set one of these to an increment you like, and
;;  then fiddle with the other until they more or less cancel.
;;
;;
;;  New functions and macros defined here (each has prefix `1on1-'):
;;
;;    `box-cursor-when-idle', `change-cursor-on-input-method',
;;    `change-cursor-on-overwrite/read-only',
;;    `color-minibuffer-frame-on-exit',
;;    `color-minibuffer-frame-on-setup',
;;    `color-isearch-minibuffer-frame', `display-*Completions*-frame',
;;    `display-*Help*-frame', `emacs', `fit-minibuffer-frame',
;;    `flash-ding-minibuffer-frame', `increment-color-hue',
;;    `minibuffer-prompt-end', `reset-minibuffer-frame',
;;    `set-box-cursor-when-idle-interval', `set-cursor-type',
;;    `set-minibuffer-frame-top/bottom', `set-minibuffer-frame-width',
;;    `setup-minibuffer-frame-coloring',
;;    `setup-mode-line'. `toggle-box-cursor-when-idle'.
;;
;;  Customizable user options defined here (each has prefix `1on1-'):
;;
;;    `*Completions*-frame-flag', `*Completions*-frame-at-right-flag',
;;    `*Help*-frame-flag', `active-minibuffer-frame-background',
;;    `active-mode-line-background',
;;    `change-cursor-on-overwrite/read-only-flag',
;;    `color-minibuffer-frame-on-exit-increment',
;;    `color-minibuffer-frame-on-setup-increment',
;;    `color-mode-line-flag', `completions-frame-background',
;;    `completions-frame-mouse+cursor-color',
;;    `completions-frame-width',
;;    `completions-frame-zoom-font-difference',
;;    `default-frame-cursor-color',
;;    `default-frame-cursor-color-input-method',
;;    `default-frame-cursor-type',
;;    `default-frame-cursor-type-overwrite/read-only',
;;    `default-frame-alist', `help-frame-background',
;;    `help-frame-mouse+cursor-color',
;;    `inactive-minibuffer-frame-background',
;;    `inactive-mode-line-background',
;;    `isearch-minibuffer-frame-background', `minibuffer-frame-alist',
;;    `minibuffer-frame-flag', `minibuffer-frame-left',
;;    `minibuffer-frame-top/bottom', `minibuffer-frame-width',
;;    `minibuffer-frame-width-percent', `special-display-frame-alist'.
;;
;;  Non-customizable user options defined here (prefix `1on1-'):
;;
;;    `default-frame-background', `default-frame-font',
;;    `default-frame-foreground', `default-frame-menu-bar-lines',
;;    `default-frame-mouse-color', `default-frame-size',
;;    `default-frame-upper-left-corner',
;;    `default-special-frame-background',
;;    `default-special-frame-cursor-color',
;;    `default-special-frame-font',
;;    `default-special-frame-foreground',
;;    `default-special-frame-menu-bar-lines',
;;    `default-special-frame-mouse-color',
;;    `default-special-frame-size',
;;    `default-special-frame-upper-left-corner',
;;    `minibuffer-frame-background', `minibuffer-frame-cursor-color',
;;    `minibuffer-frame-font', `minibuffer-frame-foreground',
;;    `minibuffer-frame-height', `minibuffer-frame-mouse-color'.
;;
;;  Other new variables defined here (each has prefix `1on1-'):
;;
;;    `box-cursor-when-idle-p', `box-cursor-when-idle-interval',
;;    `box-cursor-when-idle-timer', `last-cursor-type',
;;    `minibuffer-frame'.
;;
;;
;;  ***** NOTE: These EMACS PRIMITIVES have been REDEFINED HERE:
;;
;;  `abort-recursive-edit', `top-level' -
;;               Reset color of minibuffer frame to "inactive" color.
;;
;;  `y-or-n-p' - Temporarily color minibuffer frame to "active" color.
;;
;;
;;  Acknowledgements:
;;
;;  The cursor-changing on input method and read-only was inspired by
;;  Juri Linkov <juri@jurta.org>.  Joe Casadonte <joc@netaxs.com>
;;  wrote a similar hook (`joc-cursor-type-set-hook'), which he got
;;  from Steve Kemp...
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change Log:
;;
;; 2011/06/15 dadams
;;     Removed soft require of files+.el (switch-to-buffer-other-frame no longer used).
;; 2011/01/04 dadams
;;     Added autoload cookies for defgroup, defcustom, and commands.
;; 2010/11/30 dadams
;;     1on1-minibuffer-frame-alist: Change fallback value from nil to 0 (Emacs bug #1077).
;; 2010/10/27 dadams
;;     1on1-default-frame-alist:
;;       Put back setting of tool-bar-lines for Emacs 24.  Emacs 24 bug was fixed.
;; 2010/07/09 dadams
;;     1on1-emacs: Soft-require fit-frame.el.
;; 2010/07/04 dadams
;;     1on1-default-frame-alist:
;;       Temp workaround: do not set tool-bar-lines for Emacs 24 (Emacs bug).
;; 2009/06/19 dadams
;;     1on1-completions-frame-zoom-font-difference: Supplied missing :type and :group.
;; 2009/05/15 dadams
;;     Added: 1on1-fit-minibuffer-frame-(flag|max-height(-percent)).
;;     1on1-emacs: Add/remove 1on1-fit-minibuffer-frame for post-command-hook (if *-flag).
;;     1on1-set-minibuffer-frame-top/bottom: Redisplay.
;;     1on1-fit-minibuffer-frame:
;;       Do nothing unless 1on1-fit-minibuffer-frame-flag.
;;       Test last-command vs 1on1-fit-minibuffer-frame, not vs this-command.
;;       Pass current frame width to fit-frame.
;;       Bind to the 1on1 minibuffer values for the call to fit-frame:
;;         fit-frame-max-height(-percent),(fit-frame|window)-min-height,fit-frame-empty-*.
;;       Don't bind: frame-width, fit-frame-(min|max)-width, window-min-width.
;;       Don't provide any extra height for Emacs 22+.
;; 2009/05/03 dadams
;;     Corrected commentary: some customizable vars were listed as non-customizable.
;; 2009/04/18 dadams
;;     1on1-emacs: Raise error if run without a graphics display.
;; 2009/04/10 dadams
;;     1on1-emacs: No menu bar or tool bar for *Completions* frame.
;; 2009/02/11 dadams
;;     1on1-display-*(Help|Completions)*-frame:
;;       Protect x-pointer-shape with boundp (Emacs 23 bug #2296 workaround).
;; 2009/01/13 dadams
;;     Added: 1on1-completions-frame-zoom-font-difference.
;;            Use in 1on1-display-*Completions*-frame.
;; 2009/01/01 dadams
;;     1on1-emacs: Removed assignment to pop-up-frame-alist.
;; 2008/09/08 dadams
;;     y-or-n-p: 1on1-color-minibuffer-frame-on-setup only if at top-level.
;; 2007/12/05 dadams
;;     1on1-minibuffer-frame-left: Added :type.
;;     1on1-color-mode-line-flag, 1on1-minibuffer-frame-flag: defvar -> defcustom.
;;     1on1-(minibuffer|(special-)default)-frame-*: Removed * doc-string prefix.
;; 2007/11/22 dadams
;;     Added: 1on1-reset-minibuffer-frame, 1on1-fit-minibuffer-frame,
;;            1on1-minibuffer-prompt-end.  Recommend C-o key binding.
;;     Use 1on1-reset-minibuffer-frame on minibuffer-exit-hook.
;; 2007/08/14 dadams
;;     1on1-emacs:
;;       Add *Completions* to special-display-buffer-names even if
;;         1on1-*Completions*-frame-flag is nil, so minibuffer gets focus.
;;       Set w(in)32-grab-focus-on-raise to nil.
;;     1on1-display-*Completions*-frame:
;;       Don't change mouse pointer unless 1on1-*Completions*-frame-flag.
;;     1on1-minibuffer-frame-background: Use std minibuffer-frame-alist bg, if defined.
;; 2007/05/28 dadams
;;     1on1-display-*Completions*-frame:
;;       Wrap zoom-frm-out in condition-case (hack for Emacs 23 problem changing size).
;; 2007/03/10 dadams
;;     Added: 1on1-completions-frame-width.  Use it in 1on1-emacs.
;; 2007/02/08 dadams
;;     Removed: ^L-appearance-vector.
;;     1on1-emacs: No longer change ^L appearance - use my library pp-c-l.el to do that.
;; 2007/02/04 dadams
;;     1on1-emacs:
;;       Initialize standard-display-table if nil (default is nil!).  Thx to FidelSalas.
;; 2006/12/27 dadams
;;     1on1-change-cursor-on-input-method: Respect 1on1-change-cursor-on-input-method-flag
;; 2006/12/12 dadams
;;     Added: 1on1-^L-appearance-vector.
;;     1on1-emacs: Use 1on1-^L-appearance-vector to set ^L appearance.
;; 2006/12/11 dadams
;;     1on1-set-minibuffer-frame-top/bottom: 2 chars up, not 1, to fit Emacs 22 better.
;; 2006/10/28 dadams
;;     1on1-(in)active-minibuffer-frame-background,
;;     1on1-isearch-minibuffer-frame-background, 1on1-(in)active-mode-line-background,
;;     1on1-(help|completions)-frame-background,
;;     1on1-(help|completions)-frame-mouse+cursor-color,
;;     1on1-default-frame-cursor-color(-input-method):
;;         Changed :type to 'color for Emacs 21+.
;; 2006/09/14 dadams
;;     Removed mode-line position enhancements - use new library modeline-posn.el.
;;       Removed: 1on1-color-mode-line-column-flag, 1on1-mode-line-column-limit.
;; 2006/09/04 dadams
;;     1on1-box-cursor-when-idle-timer: Cancel beforehand, and cancel after defining.
;;     1on1-toggle-box-cursor-when-idle:
;;       Use 1on1-box-cursor-when-idle-off on pre-command-hook.
;;       Don't read an event; just turn it on.
;;     Added: 1on1-box-cursor-when-idle-off.
;; 2006/09/02 dadams
;;      1on1-toggle-box-cursor-when-idle: Corrected.
;; 2006/08/27 dadams
;;      Added: 1on1-box-cursor-when-idle(-p|-interval|-timer), 1on1-last-cursor-type,
;;             (1on1-)toggle-box-cursor-when-idle, 1on1-set-box-cursor-when-idle-interval.
;; 2006/08/13 dadams
;;      defalias set-cursor-type to 1on1-set-cursor-type.
;; 2006/07/25 dadams
;;      Added: 1on1-minibuffer-frame-left.  Use in 1on1-minibuffer-frame-alist.
;; 2006/03/31 dadams
;;      1on1-default-frame-alist:
;;        Changed (left|right)-fringe code, to reflect Emacs 22 change.
;; 2006/03/17 dadams
;;      Renamed:
;;        1on1-color-active-minibuffer-frame to 1on1-color-minibuffer-frame-on-setup,
;;        1on1-color-inactive-minibuffer-frame to 1on1-color-minibuffer-frame-on-exit.
;;      1on1-color-minibuffer-frame-on-setup:
;;        Redefined so hue depends on minibuffer-depth.
;; 2006/03/14 dadams
;;      1on1-color-(in)active-minibuffer-frame: Change hue for each minibuffer recursion.
;;      Added: 1on1-increment-color-hue.
;;      Require hexrgb.el
;; 2006/03/13 dadams
;;      1on1-color-inactive-minibuffer-frame:
;;        Change color only when not in recursive minibuffer.
;;      abort-recursive-edit: Change minibuffer color after, not before, abort.
;; 2006/01/07 dadams
;;      Added :link
;; 2005/12/14 dadams
;;     Added: 1on1-*Completions*-frame-at-right-flag.
;;            Use in 1on1-display-*Completions*-frame.
;; 2005/11/28 dadams
;;     Added: 1on1-change-cursor-on-overwrite-flag,
;;            1on1-change-cursor-on-input-method-flag, 1on1-default-frame-cursor-type,
;;            1on1-default-frame-cursor-type-overwrite, 1on1-default-frame-cursor-color,
;;            1on1-default-frame-cursor-color-input-mode, 1on1-change-cursor-on-overwrite,
;;            1on1-change-cursor-on-insert-mode, 1on1-set-cursor-type (thanks to
;;            Juri Linkov for the last three).
;;     1on1-emacs: Use 1on1-change-cursor-* in post-command-hook.
;;     1on1-mode-line-column-limit: Corrected custom group.
;; 2005/11/22 dadams
;;     Added: 1on1-setup-mode-line, 1on1-mode-line-column-limit,
;;            1on1-color-mode-line(-column)-flag, 1on1-(in)active-mode-line-background.
;; 2005/10/28 dadams
;;     1on1-display-*Completions*-frame: Zoom to smaller font.
;; 2005/07/31 dadams
;;     1on1-emacs: Do not set initial-frame-alist to default-frame-alist (D. Reitter).
;; 2005/07/25 dadams
;;     Added :prefix to defgroup.
;; 2005/07/17 dadams
;;     Switched default colors for 1on1-(in)active-minibuffer-frame-background,
;;       so active is the brighter color.  Change inactive to LightBlue.
;; 2005/06/01 dadams
;;     Corrected typo that gave minibuffer frame a vertical scroll bar.
;; 2005/05/29 dadams
;;     *-alist: Use values from standard alist variables, if available (that is,
;;       don't override user settings.)
;; 2005/05/28 dadams
;;     Renamed: 1on1-separate-minibuffer-frame-flag -> 1on1-minibuffer-frame-flag,
;;       1on1-separate-*Help*-frame-flag -> 1on1-*Help*-frame-flag,
;;       1on1-separate-*Completions*-frame-flag -> 1on1-*Completions*-frame-flag.
;;     Added: setup-minibuffer-frame-coloring.
;;     Added info in doc strings about use of each variable (restart/1on1-emacs).
;;     Corrected 1on1-minibuffer-frame-alist and 1on1-special-display-frame-alist
;;       for menu-bar-lines (nil).
;;     1on1-set-minibuffer-frame-top/bottom: Rewrote with modify-frame-parameters.
;;     1on1-emacs:
;;       Make sensitive to any changes to 1on1-*[Help|Completions]*-frame-flag.
;;       Move defcustom's, defvar's, and defun's outside 1on1-emacs.
;;       If 1on1-minibuffer-frame already exists, just modify it.
;;       Don't step on other parameters in standard alists; just append new values.
;; 2005/05/23 dadams
;;     Changed some individual frame-parameter variables from defcustom to defvar.
;;       Left them as user options, however, so you can change them with
;;       set-variable before loading oneonone.el.
;;     Renamed:
;;       1on1-upper-left-frame-corner-default ->
;;          1on1-default-frame-upper-left-corner
;;       1on1-default-special-display-frame-size ->
;;          1on1-default-special-frame-size
;;       1on1-upper-left-special-display-frame-corner-default ->
;;          1on1-default-special-frame-upper-left-corner
;;     Split 1on1-menu-bar-lines into: 1on1-default-special-frame-menu-bar-lines,
;;          1on1-default-frame-menu-bar-lines
;; 2005/05/18 dadams
;;     Fixed typo: "oneoneone" -> "oneonone".
;; 2005/05/17 dadams
;;     Updated to work with Emacs 22.x.
;; 2005/05/09 dadams
;;     Major reorganization/rewrite.  Created, from previous version setup-frames.el.
;;       Added prefix "1on1-".
;;       Encapsulated stuff in new command 1on1-emacs.
;; 2005/01/29 dadams
;;     1on1-default-frame-font: Fixed bug - misplaced parens, so no good if not Windows.
;; 2005/01/19 dadams
;;     Use defcustom now.
;;     Removed (put ... 'variable-interactive...).
;;     1on1-minibuffer-frame-top/bottom: Must be an integer (for set-frame-position).
;; 2004/12/18 dadams
;;     Bind after-make-frame-functions to nil when create 1on1-minibuffer-frame.
;; 2004/11/26 dadams
;;     Removed ;;;###autoload's.
;; 2004/11/20 dadams
;;     Refined to deal with Emacs 21 < 21.3.50 (soon to be 22.x)
;; 2004/10/01 dadams
;;     Ensure loaded before compile.
;;     No fringe.
;;     Remove *info* and *Customiz.* buffers from `same-window-regexps'
;; 2004/09/21 dadams
;;     Updated to work with Emacs 21 (and Emacs 20).
;; 2004/03/19 dadams
;;     1on1-minibuffer-frame-width -> 1on1-set-minibuffer-frame-width.
;;     added 1on1-set-minibuffer-frame-top/bottom.
;; 2001/01/05 dadams
;;     1. 1on1-minibuffer-frame-width: Use 1on1-minibuffer-frame arg for frame-char-width.
;;     2. Don't define width when initially set 1on1-minibuffer-frame-alist.  Instead,
;;        use set-frame-width afterward, so 1on1-minibuffer-frame-width uses correct
;;        character size.
;; 2001/01/05 dadams
;;     1. These vars no longer user options (interactively changeable):
;;        1on1-completions-frame-background, 1on1-completions-frame-mouse+cursor-color,
;;        1on1-help-frame-background, 1on1-help-frame-mouse+cursor-color,
;;        1on1-minibuffer-frame-cursor-color, 1on1-minibuffer-frame-font,
;;        1on1-minibuffer-frame-foreground, 1on1-minibuffer-frame-height,
;;        1on1-minibuffer-frame-mouse-color, 1on1-minibuffer-frame-top/bottom,
;;        1on1-minibuffer-frame-width.
;;     2. Added: 1on1-minibuffer-frame-width (function),
;;               1on1-minibuffer-frame-width-percent (var).
;;     3. Changed var 1on1-minibuffer-frame-width to nil default (now use *-percent).
;; 2000/09/27 dadams
;;     1. Added: 1on1-display-*Completions*-frame, 1on1-display-*Help*-frame.
;;     2. *Help* & *Completions* frames not created here.  Instead, use
;;        special-display-buffer-names & display-*-frame fns to define them.
;;     3. Added: top-level, abort-recursive-edit.
;; 1999/08/24 dadams
;;     1. Windows: win32-grab-focus-on-raise = nil.
;;     2. 1on1-default-frame-font different if Windows.
;;     3. Added: 1on1-separate-minibuffer-frame-flag, 1on1-menu-bar-lines,
;;        1on1-upper-left-frame-corner-default, 1on1-default-frame-size,
;;        1on1-upper-left-special-display-frame-corner-default,
;;        1on1-default-special-display-frame-size, 1on1-default-special-frame-foreground,
;;        1on1-default-special-frame-background, 1on1-default-special-frame-font,
;;        1on1-default-special-frame-mouse-color, 1on1-default-special-frame-cursor-color.
;;     4. Use new vars to define default-frame-alist, special-display-frame-alist.
;;     5. Only create built-in frames if 1on1-separate-minibuffer-frame-flag.
;;     6. Protected refs to x-* vars.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(eval-and-compile (require 'cl)) ;; remove-if (plus, for Emacs < 20, when, unless)

(require 'frame-cmds nil t) ;; (no error if not found): rename-frame
(require 'zoom-frm nil t) ;; (no error if not found):
                          ;; frame-zoom-font-difference, zoom-frm-out
(require 'hexrgb) ;; hexrgb-color-values-to-hex, hexrgb-hsv-to-rgb, hexrgb-rgb-to-hsv


;; Ensure that this is loaded before compiling it.
(provide 'oneonone)
(require 'oneonone)


;; To quiet the byte compiler
(unless (> emacs-major-version 21)
  (defvar x-pointer-box-spiral)
  (defvar x-pointer-xterm))

;;;;;;;;;;;;;;;;;;;;;;;;


;;;###autoload
(defgroup One-On-One nil
  "Options to define initial frame configuration."
  :prefix "1on1-" :group 'frames
  :link `(url-link :tag "Send Bug Report"
          ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
oneonone.el bug: \
&body=Describe bug here, starting with `emacs -q'.  \
Don't forget to mention your Emacs and library versions."))
  :link '(url-link :tag "Other Libraries by Drew"
          "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries")
  :link '(url-link :tag "Download" "http://www.emacswiki.org/cgi-bin/wiki/oneonone.el")
  :link '(url-link :tag "Description"
          "http://www.emacswiki.org/cgi-bin/wiki/OneOnOneEmacs")
  :link '(emacs-commentary-link :tag "Commentary" "oneonone")
  )
\f


;;; Minibuffer frame: ********************************
;;;
(defvar 1on1-minibuffer-frame nil
  "Minibuffer-only frame used by One-on-One Emacs.
Note: This is not used if `1on1-minibuffer-frame-flag' is nil.")

;;;###autoload
(defcustom 1on1-minibuffer-frame-flag t
  "*Non-nil means use a separate, specialized frame for the minibuffer.
Note that a non-nil value for this option also causes option
`pop-up-frames' to be set to `t'.  That is, it causes `display-buffer'
to generally use a separate frame.

If you change this variable, you will need to restart Emacs for it to
take effect."
  :type 'boolean :group 'One-On-One)

(defvar 1on1-minibuffer-frame-foreground "Red"
  "Default foreground color for the minibuffer frame.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-minibuffer-frame-background
  (or (cdr (assq 'background-color minibuffer-frame-alist)) "LightBlue")
  "Initial color of the `1on1-minibuffer-frame' background.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

;;;###autoload
(defcustom 1on1-active-minibuffer-frame-background "PaleGoldenrod"
  "*The color of the `1on1-minibuffer-frame' when it is active.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-inactive-minibuffer-frame-background 1on1-minibuffer-frame-background
  "*The color of the `1on1-minibuffer-frame' when it is inactive.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-isearch-minibuffer-frame-background "bisque"
  "*Color of the `1on1-minibuffer-frame' when `isearch' is active.
See `1on1-color-isearch-minibuffer-frame'.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-color-mode-line-flag t
  "*Non-nil means use `1on1-(in)active-mode-line-background'.
If you change this variable, you will need to restart Emacs for it to
take effect."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-color-minibuffer-frame-on-exit-increment 5
  "*Increment to change minibuffer-frame hue when minibuffer is exited.
This should be opposite in sign to
`1on1-color-minibuffer-frame-on-setup-increment.'"
  :type 'integer :group 'One-On-One)

;;;###autoload
(defcustom 1on1-color-minibuffer-frame-on-setup-increment -10
  "*Increment to change minibuffer-frame hue when minibuffer is entered.
This should be opposite in sign to
`1on1-color-minibuffer-frame-on-exit-increment.'"
  :type 'integer :group 'One-On-One)

;;;###autoload
(defcustom 1on1-active-mode-line-background 1on1-active-minibuffer-frame-background
  "*The color of the mode-line when it is active.
Note: This is not used if `1on1-color-mode-line-flag' is nil."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-inactive-mode-line-background "LightGray"
  "*The color of the mode-line when it is inactive.
Note: This is not used if `1on1-color-mode-line-flag' is nil."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

(defvar 1on1-minibuffer-frame-font
  (if (eq system-type 'windows-nt)
      "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"
      ;;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"
    "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")
  "Default font for the minibuffer frame.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-minibuffer-frame-mouse-color "Black"
  "Default mouse color for the minibuffer frame.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-minibuffer-frame-cursor-color "Black"
  "Default text cursor color for the minibuffer frame.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-minibuffer-frame-height 2
  "Height of minibuffer frame, in characters.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

This is used only to define the standard value of
`1on1-minibuffer-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

;;;###autoload
(defcustom 1on1-minibuffer-frame-left 0
  "*Position of left edge of minibuffer frame, in pixels.
An integer.  If negative, then the position is that of the frame
bottom relative to the screen right (not left) edge.

See `default-frame-alist' for an explanation of frame parameters.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'integer :group 'One-On-One)

;;;###autoload
(defcustom 1on1-minibuffer-frame-top/bottom nil
  "*Position of top (or bottom) of minibuffer frame, in pixels.
If nil, function `1on1-set-minibuffer-frame-top/bottom' will position
minibuffer at bottom of display.

An integer.  If negative, then the position is that of the frame
bottom relative to the screen bottom.

See `default-frame-alist' for an explanation of frame parameters.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type '(choice (const :tag "Use function `1on1-set-minibuffer-frame-top/bottom'" nil)
                 (integer :tag "Pixels from top (>= 0) or bottom (< 0)" :value 0))
  :group 'One-On-One)

;;;###autoload
(defcustom 1on1-minibuffer-frame-width nil
  "*Width, in characters, for minibuffer frame.
If nil, then function `1on1-set-minibuffer-frame-width' is used instead.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type '(choice (const :tag "Use function `1on1-set-minibuffer-frame-width'" nil)
                 (integer :tag "Width, in characters, for minibuffer frame" :value 0))
  :group 'One-On-One)

;;;###autoload
(defcustom 1on1-minibuffer-frame-width-percent 100
  "*Max percent of the total display width to give to minibuffer frame.
See function `1on1-set-minibuffer-frame-width'.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'integer :group 'One-On-One)

;; Use values from the standard list, when available.  However, we have no way of
;; distinguishing values predefined in vanilla Emacs from user settings.
;;;###autoload
(defcustom 1on1-minibuffer-frame-alist
  (list
   (or (assq 'foreground-color minibuffer-frame-alist)
       (cons 'foreground-color 1on1-minibuffer-frame-foreground))
   (or (assq 'background-color minibuffer-frame-alist)
       (cons 'background-color 1on1-minibuffer-frame-background))
   (or (assq 'font minibuffer-frame-alist)
       (cons 'font 1on1-minibuffer-frame-font))
   (or (assq 'mouse-color minibuffer-frame-alist)
       (cons 'mouse-color 1on1-minibuffer-frame-mouse-color))
   (or (assq 'cursor-color minibuffer-frame-alist)
       (cons 'cursor-color 1on1-minibuffer-frame-cursor-color))
   (or (assq 'menu-bar-lines minibuffer-frame-alist)
       (cons 'menu-bar-lines 0))
   (or (assq 'left minibuffer-frame-alist)
       (cons 'left 1on1-minibuffer-frame-left))
   (or (assq 'height minibuffer-frame-alist)
       (cons 'height 1on1-minibuffer-frame-height))
   (or (assq 'icon-type minibuffer-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'minibuffer minibuffer-frame-alist)
       (cons 'minibuffer 'only))
   (or (assq 'user-position minibuffer-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars minibuffer-frame-alist) ;  No scroll bar.
       (cons 'vertical-scroll-bars nil))
   (or (assq 'name minibuffer-frame-alist)
       (cons 'name "Emacs Minibuffer")))
  "*Frame-parameter alist for the standalone minibuffer frame
`1on1-minibuffer-frame'.

Note: This is not used if `1on1-minibuffer-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'One-On-One)

;;;###autoload
(defcustom 1on1-fit-minibuffer-frame-flag t
  "*Non-nil means adjust `1on1-minibuffer-frame' height to fit content.
This is done after each command or user event (e.g. each key press)
when the minibuffer is active.
This option has no effect if `1on1-minibuffer-frame-flag' is nil."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-fit-minibuffer-frame-max-height nil
  "*Maximum height, in lines, that `fit-frame' gives to `1on1-minibuffer-frame'.
If nil, then function `fit-frame-max-height' is used instead,
respecting `1on1-fit-minibuffer-frame-max-height-percent'.
This has no effect if you do not use library `fit-frame.el'."
  :type '(choice
          (const :tag "Use `1on1-fit-minibuffer-frame-max-height-percent'" nil)
          integer)
  :group 'One-On-One)

;;;###autoload
(defcustom 1on1-fit-minibuffer-frame-max-height-percent 10
  "*Max percent that `fit-frame' gives to `1on1-minibuffer-frame'.
This is a percentage of the display height.
Not used unless `1on1-fit-minibuffer-frame-max-height' is nil.
This has no effect if you do not use library `fit-frame.el'."
  :type 'integer :group 'One-On-One)
\f


;;; *Help* frame: ********************************
;;;   Display of *Help* buffer in custom frame.
;;;   Background, height, cursor and pointer colors.
;;;
;;;###autoload
(defcustom 1on1-*Help*-frame-flag t
  "*Non-nil means use a special appearance for the *Help* frame.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-help-frame-background "Thistle"
  "*Default background color for the *Help* buffer's frame.

Note: This is not used if `1on1-*Help*-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-help-frame-mouse+cursor-color "Blue Violet"
  "*Default color for cursor & pointer of *Help* frame.

Note: This is not used if `1on1-*Help*-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)
\f


;;; *Completions* frame: ********************************
;;;   Display of *Completion* buffer in custom frame.
;;;   Background, height, cursor and pointer colors.
;;;
;;;###autoload
(defcustom 1on1-*Completions*-frame-flag t
  "*Non-nil means use a special appearance for the *Completions* frame.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-*Completions*-frame-at-right-flag nil
  "*Non-nil means place *Completions* frame at right edge of display.
This can be useful to make *Completions* more visible.
This has no effect if `1on1-*Completions*-frame-flag' is nil."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-completions-frame-background "LavenderBlush2"
  "*Default background color for the *Completions* buffer's frame.

Note: This is not used if `1on1-*Completions*-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-completions-frame-mouse+cursor-color "VioletRed"
  "*Default color for cursor & pointer of *Completions* frame.

Note: This is not used if `1on1-*Completions*-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-completions-frame-width 100
  "*Width, in characters, for *Completions* frame.
If this is nil, then the pertinent default frame width is used.

Note: This is not used if `1on1-*Completions*-frame-flag' is nil.

If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'integer :group 'One-On-One)

;;;###autoload
(defcustom 1on1-completions-frame-zoom-font-difference
  (or (and (require 'zoom-frm 'nil t) (* 2 frame-zoom-font-difference))
      2)
  "*Number of points to reduce the *Completions* frame font size.
This must be less than the current default font size, since the new
font size cannot be less than 1 point.
A value of zero or nil means the *Completions* frame is not zoomed."
  :type '(restricted-sexp :match-alternatives (integerp null)) :group 'One-On-One)
\f


;;; Default for normal frames: `1on1-default-frame-alist' **************************
;;;
(defvar 1on1-default-frame-foreground "Black"
  "Default foreground color for non-special frames.
This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-default-frame-background "LightBlue"
  "Default background color for non-special frames.
This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-default-frame-font
  (if (eq system-type 'windows-nt)
      "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"
      ;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"
    "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")
  "Default font for non-special frames.
This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-default-frame-mouse-color "Red"
  "Default mouse-pointer color for non-special frames.
This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

;;;###autoload
(defcustom 1on1-change-cursor-on-input-method-flag t
  "*Non-nil means to use a different cursor when using an input method.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-default-frame-cursor-color "Red"
  "*Default text cursor color for non-special frames.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect.  Furthermore, if
`1on1-change-cursor-on-input-method-flag' is nil when you rerun
`1on1-emacs', you will need to toggle that variable to non-nil (and
back to nil, if that's the value you want).  Otherwise, the new value
will take effect only after you restart Emacs."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-default-frame-cursor-color-input-method "Orange"
  "*Default cursor color for non-special frames if using an input method.
This has no effect if `1on1-change-cursor-on-input-method-flag' is nil.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type (if (>= emacs-major-version 21) 'color 'string) :group 'One-On-One)

;;;###autoload
(defcustom 1on1-change-cursor-on-overwrite/read-only-flag t
  "*Non-nil means use a different cursor when overwrite mode or read-only.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  :type 'boolean :group 'One-On-One)

;;;###autoload
(defcustom 1on1-default-frame-cursor-type 'bar
  "*Default text cursor type for non-special frames.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect.  Furthermore, if
`1on1-change-cursor-on-overwrite/read-only-flag' is nil when you rerun
`1on1-emacs', you will need to toggle that variable to non-nil (and
back to nil, if that's the value you want).  Otherwise, the new value
will take effect only after you restart Emacs."
  :type 'symbol :group 'One-On-One)

(defvar 1on1-last-cursor-type 1on1-default-frame-cursor-type "Saved last cursor type.")

;;;###autoload
(defcustom 1on1-default-frame-cursor-type-overwrite/read-only 'box
  "*Default text cursor type for overwrite mode or read-only buffer.
This applies only to non-special frames.  This has no effect if
`1on1-change-cursor-on-overwrite/read-only-flag' is nil.  If you
customize this variable, you will need to rerun `1on1-emacs' for the
new value to take effect."
  :type 'symbol :group 'One-On-One)

(defvar 1on1-box-cursor-when-idle-p t
  "Non-nil means to use a box cursor whenever Emacs is idle.
Do NOT change this yourself; instead, use `\\[toggle-box-cursor-when-idle]'.")

(defvar 1on1-box-cursor-when-idle-interval 2
  "Number of seconds to wait before changing cursor type to box.
Do NOT change this yourself to change the wait period; instead, use
`\\[1on1-set-box-cursor-when-idle-interval]'.")

(defvar 1on1-box-cursor-when-idle-timer
  (progn                                ; Cancel to prevent duplication.
    (when (boundp '1on1-box-cursor-when-idle-timer)
      (cancel-timer 1on1-box-cursor-when-idle-timer))
    (run-with-idle-timer 1on1-box-cursor-when-idle-interval t '1on1-box-cursor-when-idle))
  "Timer used to change the cursor to a box cursor when Emacs is idle.")

;; Turn it off, by default.  You must use `toggle-box-cursor-when-idle' to turn it on.
(cancel-timer 1on1-box-cursor-when-idle-timer)

(defvar 1on1-default-frame-menu-bar-lines 1
  "Number of lines used for the menu bar in non-special frames.
This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-default-frame-upper-left-corner '(0 . 0)
  "Position of upper left frame corner.
A cons whose car is the distance from the top in pixels
and whose cdr is the distance from the left in pixels.

This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

(defvar 1on1-default-frame-size '(80 . 35)
  "Default frame size.
A cons whose car is the frame width in pixels
and whose cdr is the frame height in pixels.

This is used only to define the standard value of
`1on1-default-frame-alist'.  Customize that variable, not this one.
If you change this variable, you will need to restart Emacs for it to
take effect.")

;; Use values from the standard list, when available.  However, we have no way of
;; distinguishing values predefined in vanilla Emacs from user settings.
;;;###autoload
(defcustom 1on1-default-frame-alist
  (list
   (or (assq 'foreground-color default-frame-alist)
       (cons 'foreground-color 1on1-default-frame-foreground))
   (or (assq 'background-color default-frame-alist)
       (cons 'background-color 1on1-default-frame-background))
   (or (assq 'font default-frame-alist)
       (cons 'font 1on1-default-frame-font))
   (or (assq 'mouse-color default-frame-alist)
       (cons 'mouse-color 1on1-default-frame-mouse-color))
   (or (assq 'cursor-color default-frame-alist)
       (cons 'cursor-color 1on1-default-frame-cursor-color))
   (or (assq 'cursor-type default-frame-alist)
       (cons 'cursor-type 1on1-default-frame-cursor-type))
   (or (assq 'menu-bar-lines default-frame-alist)
       (cons 'menu-bar-lines 1on1-default-frame-menu-bar-lines))
   (or (assq 'top default-frame-alist)
       (cons 'top (car 1on1-default-frame-upper-left-corner)))
   (or (assq 'left default-frame-alist)
       (cons 'left (cdr 1on1-default-frame-upper-left-corner)))
   (or (assq 'width default-frame-alist)
       (cons 'width (car 1on1-default-frame-size)))
   (or (assq 'height default-frame-alist)
       (cons 'height (cdr 1on1-default-frame-size)))
   (or (assq 'minibuffer default-frame-alist)
       (cons 'minibuffer (not 1on1-minibuffer-frame-flag)))
   (or (assq 'user-position default-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars default-frame-alist)
       (cons 'vertical-scroll-bars 'right))
   (or (assq 'icon-type default-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'tool-bar-lines default-frame-alist)
       (cons 'tool-bar-lines 1))        ; Emacs 21+
   (if (cdr (assq 'left-fringe default-frame-alist))
       (assq 'left-fringe default-frame-alist)
     (cons 'left-fringe 0))             ; Emacs 21+
   (if (cdr (assq 'right-fringe default-frame-alist))
       (assq 'right-fringe default-frame-alist)
     (cons 'right-fringe 0))            ; Emacs 21+
   (or (assq 'fringe default-frame-alist)
       (cons 'fringe 0)))               ; Emacs 21, but not 21.3.50 - REMOVE after 22.x
  "*Properties to be used for One-on-One Emacs `default-frame-alist'.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'One-On-One)
\f


;;; Special-display frames: `1on1-special-display-frame-alist' ************************
;;;
(defvar 1on1-default-special-frame-foreground "Black"
  "Default foreground color for special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-background "LightSteelBlue"
  "Default background color for special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-font
  (if (eq system-type 'windows-nt)
      "-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1"
      ;;;;;;;;"-*-Lucida Console-normal-r-*-*-15-*-*-*-c-*-*-ansi-"
    "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")
  "Default font for special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-mouse-color "Yellow"
  "Default mouse color for special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-cursor-color "Yellow"
  "Default text cursor color for special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-menu-bar-lines 1
  "Number of lines used for the menu bar of special display frames.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-upper-left-corner '(0 . 0)
  "Position of upper left corner of special display frames.
A cons whose car is the distance from the top in pixels
and whose cdr is the distance from the left in pixels.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

(defvar 1on1-default-special-frame-size '(80 . 20)
  "Default size of special display frames.
A cons whose car is the frame width in pixels
and whose cdr is the frame height in pixels.

This is used only to define the standard value of
`1on1-special-display-frame-alist'.  Customize that variable, not this
one.  If you change this variable, you will need to restart Emacs for
it to take effect.")

;; Use values from the standard list, when available.  However, we have no way of
;; distinguishing values predefined in vanilla Emacs from user settings.
;;;###autoload
(defcustom 1on1-special-display-frame-alist
  (list
   (or (assq 'font special-display-frame-alist)
       (cons 'font 1on1-default-special-frame-font))
   (or (assq 'width special-display-frame-alist)
       (cons 'width (car 1on1-default-special-frame-size)))
   (or (assq 'height special-display-frame-alist)
       (cons 'height (cdr 1on1-default-special-frame-size)))
   (or (assq 'mouse-color special-display-frame-alist)
       (cons 'mouse-color 1on1-default-special-frame-mouse-color))
   (or (assq 'cursor-color special-display-frame-alist)
       (cons 'cursor-color 1on1-default-special-frame-cursor-color))
   (or (assq 'menu-bar-lines special-display-frame-alist)
       (cons 'menu-bar-lines 1on1-default-special-frame-menu-bar-lines))
   (or (assq 'foreground-color special-display-frame-alist)
       (cons 'foreground-color 1on1-default-special-frame-foreground))
   (or (assq 'background-color special-display-frame-alist)
       (cons 'background-color 1on1-default-special-frame-background))
   (or (assq 'top special-display-frame-alist)
       (cons 'top (car 1on1-default-special-frame-upper-left-corner)))
   (or (assq 'left special-display-frame-alist)
       (cons 'left (cdr 1on1-default-special-frame-upper-left-corner)))
   (or (assq 'unsplittable special-display-frame-alist)
       (cons 'unsplittable t))
   (or (assq 'user-position special-display-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars special-display-frame-alist)
       (cons 'vertical-scroll-bars 'right)))
  "Properties to be used for One-on-One `special-display-frame-alist'.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'One-On-One)
\f


;;; Main command ***************************************
;;;
;;;###autoload
(defun 1on1-emacs ()
  "One-on-One Emacs setup.
Use `1on1-default-frame-alist' and `1on1-special-display-frame-alist'.

If `1on1-minibuffer-frame-flag' is non-nil, then create
   minibuffer-only frame, `1on1-minibuffer-frame', using
   `1on1-minibuffer-frame-alist'.

If `1on1-separate-minibuffer-*Help*-flag' is non-nil, then use
   special frame for *Help* buffer.

If `1on1-separate-minibuffer-*Completions*-flag' is non-nil, then
   use special frame for *Completions* buffer."
  (interactive)
  (unless (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
    (error "Use `1on1-emacs' only with a graphics display, not with a text terminal"))
  (setq default-frame-alist (append 1on1-default-frame-alist default-frame-alist)
        special-display-frame-alist (append 1on1-special-display-frame-alist
                                            special-display-frame-alist))

  ;; *Help* frame
  (if 1on1-*Help*-frame-flag
      (add-to-list
       'special-display-buffer-names
       (list "*Help*" '1on1-display-*Help*-frame
             (list (cons 'background-color 1on1-help-frame-background)
                   (cons 'mouse-color 1on1-help-frame-mouse+cursor-color)
                   (cons 'cursor-color 1on1-help-frame-mouse+cursor-color)
                   '(height . 40))))
    (setq special-display-buffer-names
          (remove-if (lambda (elt) (equal "*Help*" (car elt)))
                     special-display-buffer-names)))

  ;; *Completions* frame
  ;; If `1on1-minibuffer-frame-flag' is non-nil, then *Completions* frame must be treated
  ;; specially, so that it gets focus from the minibuffer frame.  This is so, even if
  ;; `1on1-*Completions*-frame-flag' is nil.
  (if  1on1-minibuffer-frame-flag
       (if 1on1-*Completions*-frame-flag
           (add-to-list
            'special-display-buffer-names
            `("*Completions*" 1on1-display-*Completions*-frame
              ((background-color ,@1on1-completions-frame-background)
               (mouse-color      ,@1on1-completions-frame-mouse+cursor-color)
               (cursor-color     ,@1on1-completions-frame-mouse+cursor-color)
               (menu-bar-lines . 0) (tool-bar-lines . 0)    ; No menu bar or tool bar.
               ,@(and 1on1-completions-frame-width
                      `((width   ,@1on1-completions-frame-width))))))
         (add-to-list 'special-display-buffer-names
                      `("*Completions*" 1on1-display-*Completions*-frame)))
    (setq special-display-buffer-names
          (remove-if (lambda (elt) (equal "*Completions*" (car elt)))
                     special-display-buffer-names)))

  ;; Minibuffer frame
  (when 1on1-minibuffer-frame-flag
    ;; `display-buffer' (& `*-other-window' fns) will use separate frames.
    (setq pop-up-frames  t)

    ;; Set up `1on1-minibuffer-frame'.
    (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist
                                         minibuffer-frame-alist))
    (if 1on1-minibuffer-frame
        (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
      (setq 1on1-minibuffer-frame
            (let ((after-make-frame-functions nil)) ; E.g. inhibit `fit-frame'.
              (make-frame 1on1-minibuffer-frame-alist))))

    ;; Resize and reposition it.  If variable `1on1-minibuffer-frame-width'
    ;; or `1on1-minibuffer-frame-top/bottom' is nil, calculate automatically.
    (1on1-set-minibuffer-frame-width)
    (1on1-set-minibuffer-frame-top/bottom)

    ;; Rename minibuffer frame. (`rename-frame' is defined in `frame-cmds.el'.)
    (when (fboundp 'rename-frame)
      (rename-frame 1on1-minibuffer-frame "Emacs minibuffer                         \
show/hide: hold CTRL + click in window"))
    (setq minibuffer-auto-raise t)
    ;; Background colors of minibuffer frame: 3 states
    (add-hook 'isearch-mode-hook '1on1-color-isearch-minibuffer-frame)
    (add-hook 'isearch-mode-end-hook '1on1-color-minibuffer-frame-on-exit)
    (add-hook 'minibuffer-setup-hook '1on1-color-minibuffer-frame-on-setup)
    (add-hook 'minibuffer-exit-hook '1on1-color-minibuffer-frame-on-exit)
    ;; Redefine built-in fns so they color minibuffer frame.
    (1on1-setup-minibuffer-frame-coloring))

  ;; Hooks.
  (if (and 1on1-fit-minibuffer-frame-flag (require 'fit-frame nil t))
      (add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
    (remove-hook 'post-command-hook '1on1-fit-minibuffer-frame))
  (if 1on1-change-cursor-on-overwrite/read-only-flag
      (add-hook 'post-command-hook '1on1-change-cursor-on-overwrite/read-only)
    (1on1-set-cursor-type 1on1-default-frame-cursor-type)
    (remove-hook 'post-command-hook '1on1-change-cursor-on-overwrite/read-only))
  (if 1on1-change-cursor-on-input-method-flag
      (add-hook 'post-command-hook '1on1-change-cursor-on-input-method)
    (setq current-input-method nil)
    (1on1-change-cursor-on-input-method)
    (remove-hook 'post-command-hook '1on1-change-cursor-on-input-method))
  (add-hook 'minibuffer-exit-hook '1on1-reset-minibuffer-frame)

  (setq w32-grab-focus-on-raise    nil
        win32-grab-focus-on-raise  nil) ; older name
  (1on1-setup-mode-line))

;; This is inspired by code from Juri Linkov <juri@jurta.org>.
(defun 1on1-change-cursor-on-input-method ()
  "Set cursor type depending on whether an input method is used or not."
  (when 1on1-change-cursor-on-input-method-flag
    (set-cursor-color
     (if current-input-method
         1on1-default-frame-cursor-color-input-method
       (let ((bufname (buffer-name (current-buffer))))
         (cond
           ((string= "*Help*" bufname) 1on1-help-frame-mouse+cursor-color)
           ((string= "*Completions*" bufname) 1on1-completions-frame-mouse+cursor-color)
           ((eq 1on1-minibuffer-frame (selected-frame))
            1on1-minibuffer-frame-cursor-color)
           ((special-display-p bufname) 1on1-default-special-frame-cursor-color)
           (t 1on1-default-frame-cursor-color)))))))

;; This is from Juri Linkov <juri@jurta.org>, with read-only added.
(defun 1on1-change-cursor-on-overwrite/read-only ()
  "Set cursor type differently for overwrite mode and read-only buffer.
That is, use one cursor type for overwrite mode and read-only buffers,
and another cursor type otherwise."
  (1on1-set-cursor-type (if (or buffer-read-only overwrite-mode)
                            1on1-default-frame-cursor-type-overwrite/read-only
                          1on1-default-frame-cursor-type)))

(unless (fboundp 'set-cursor-type) (defalias 'set-cursor-type '1on1-set-cursor-type))
;; This is essentially from Juri Linkov <juri@jurta.org>.
;;;###autoload
(defun 1on1-set-cursor-type (cursor-type)
  "Set the cursor type of the selected frame to CURSOR-TYPE.
When called interactively, prompt for the type to use.
To get the frame's current cursor type, use `frame-parameters'."
  (interactive
   (list (intern (completing-read "Cursor type: "
                                  (mapcar 'list '("box" "hollow" "bar" "hbar" nil))))))
  (modify-frame-parameters (selected-frame) (list (cons 'cursor-type cursor-type))))

(defun 1on1-box-cursor-when-idle ()
  "Change the cursor to a box cursor when Emacs is idle."
  (let ((type (cdr (assoc 'cursor-type (frame-parameters)))))
    (unless (eq type 'box)
      (setq 1on1-last-cursor-type type)
      (1on1-set-cursor-type 'box))))     

(defun 1on1-box-cursor-when-idle-off ()
  "Turn off changing the cursor to a box cursor when Emacs is idle."
  (when 1on1-last-cursor-type (1on1-set-cursor-type 1on1-last-cursor-type)))

;;;###autoload
(defalias 'toggle-box-cursor-when-idle '1on1-toggle-box-cursor-when-idle)
;;;###autoload
(defun 1on1-toggle-box-cursor-when-idle (&optional arg)
  "Turn on or off automatically changing to a box cursor when idle.
When on, the cursor is changed to a box whenever Emacs is idle.
With prefix argument, turn on if ARG > 0; else turn off."
  (interactive "P")
  (setq 1on1-box-cursor-when-idle-p
        (if arg (> (prefix-numeric-value arg) 0) (not 1on1-box-cursor-when-idle-p)))
  (cond (1on1-box-cursor-when-idle-p
         (timer-activate-when-idle 1on1-box-cursor-when-idle-timer)
         (add-hook 'pre-command-hook '1on1-box-cursor-when-idle-off)
         (message "Turned ON making cursor a box when Emacs is idle."))
        (t
         (cancel-timer 1on1-box-cursor-when-idle-timer)
         (remove-hook 'pre-command-hook '1on1-box-cursor-when-idle-off)
         (message "Turned OFF making cursor a box when Emacs is idle."))))

;;;###autoload
(defun 1on1-set-box-cursor-when-idle-interval (secs)
  "Set wait until automatically change to a box cursor when Emacs is idle.
Whenever Emacs is idle for this many seconds it will change the cursor
to a box.

To turn on or off automatically changing to a box cursor when idle,
use `\\[toggle-box-cursor-when-idle]."
  (interactive
   "nSeconds to idle, before changing to a box cursor: ")
  (timer-set-idle-time 1on1-box-cursor-when-idle-timer
                       (setq 1on1-box-cursor-when-idle-interval secs)
                       t))

(defun 1on1-display-*Help*-frame (buf &optional args)
  "Display *Help* buffer in its own frame.
`special-display-function' is used to do the actual displaying.
BUF and ARGS are the arguments to `special-display-function'."
  (let ((old-ptr-shape (and (boundp 'x-pointer-shape) x-pointer-shape))
        return-window)
    (when (boundp 'x-pointer-xterm) (setq x-pointer-shape x-pointer-xterm))
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    (setq x-pointer-shape old-ptr-shape)
    return-window))

(defun 1on1-display-*Completions*-frame (buf &optional args)
  "Display *Completions* buffer in its own frame.
`special-display-function' is used to do the actual displaying.
Completion input events are redirected to `1on1-minibuffer-frame'.
BUF and ARGS are the arguments to `special-display-function'."
  (let ((old-ptr-shape (and (boundp 'x-pointer-shape) x-pointer-shape))
        return-window)
    (when (and 1on1-*Completions*-frame-flag (boundp 'x-pointer-box-spiral))
      (setq x-pointer-shape x-pointer-box-spiral))
    (setq return-window (select-window (funcall special-display-function buf args)))
    (when (and (fboundp 'zoom-frm-out) 1on1-completions-frame-zoom-font-difference)
      (condition-case nil
          (let ((frame-zoom-font-difference  1on1-completions-frame-zoom-font-difference))
            (zoom-frm-out))             ; In `zoom-frm.el'.
        (error nil)))
    
    ;; We reposition frame this way, instead of binding `special-display-frame-alist'
    ;; with this value, because `after-make-frame-functions' might resize frame.
    (when 1on1-*Completions*-frame-at-right-flag
      (modify-frame-parameters
       (selected-frame)                 ; Hard-code 7 here - what does it depend on?
       `((left . ,(- (x-display-pixel-width) (+ (frame-pixel-width) 7))))))
    (raise-frame)
    (when (boundp '1on1-minibuffer-frame)
      (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame))
    (when (and 1on1-*Completions*-frame-flag (boundp 'x-pointer-box-spiral))
      (setq x-pointer-shape old-ptr-shape))
    return-window))

(defun 1on1-set-minibuffer-frame-top/bottom ()
  "Set position of minibuffer frame.
Use `1on1-minibuffer-frame-top/bottom' if non-nil.
Else, place minibuffer at bottom of display."
  (when (boundp '1on1-minibuffer-frame)
    (condition-case nil
        (if (fboundp 'redisplay) (redisplay t) (force-mode-line-update t))
      (error nil))                      ; Ignore errors from, e.g., killed buffers.
    (modify-frame-parameters
     1on1-minibuffer-frame
     `((top ,@ (or 1on1-minibuffer-frame-top/bottom
                (- (* 2 (frame-char-height 1on1-minibuffer-frame)))))))))

(defun 1on1-set-minibuffer-frame-width ()
  "Set width of minibuffer frame, in characters.
Use `1on1-minibuffer-frame-width' if not nil.
Else, set width relative to character size of `1on1-minibuffer-frame'
and display size, and depending on
`1on1-minibuffer-frame-width-percent':

  (/ (* 1on1-minibuffer-frame-width-percent (x-display-pixel-width))
     (* 100 (frame-char-width 1on1-minibuffer-frame)))"
  (when (boundp '1on1-minibuffer-frame)
    (set-frame-width
     1on1-minibuffer-frame
     (or 1on1-minibuffer-frame-width
         (/ (* 1on1-minibuffer-frame-width-percent (x-display-pixel-width))
            (* 100 (frame-char-width 1on1-minibuffer-frame)))))))

(defun 1on1-color-minibuffer-frame-on-setup ()
  "Change background of minibuffer frame to reflect the minibuffer depth.
Use this when increasing the minibuffer recursion depth."
  (when (boundp '1on1-minibuffer-frame)
    (save-window-excursion
      (select-frame 1on1-minibuffer-frame)
      (set-background-color 1on1-active-minibuffer-frame-background)
      (let ((count (minibuffer-depth)))
        (while (> count 1)
          (set-background-color (1on1-increment-color-hue ; Change bg hue slightly.
                                 (frame-parameter nil 'background-color)
                                 1on1-color-minibuffer-frame-on-setup-increment))
          (setq count (1- count)))))))

(defun 1on1-color-minibuffer-frame-on-exit ()
  "Change background of minibuffer frame to reflect the minibuffer depth.
Use this when reducing the minibuffer recursion depth."
  (when (boundp '1on1-minibuffer-frame)
    (save-window-excursion
      (select-frame 1on1-minibuffer-frame)
      (if (< (minibuffer-depth) 2)
          (set-background-color 1on1-inactive-minibuffer-frame-background)
        (set-background-color (1on1-increment-color-hue ; Change bg hue slightly.
                               (frame-parameter nil 'background-color)
                               1on1-color-minibuffer-frame-on-exit-increment))))))

;; This is essentially a version of `doremi-increment-color-component' for hue only.
(defun 1on1-increment-color-hue (color increment)
  "Increase hue component of COLOR by INCREMENT."
  (unless (string-match "#" color)      ; Convert color name to #hhh...
    (setq color (hexrgb-color-values-to-hex (x-color-values color))))
  ;; Convert RGB to HSV
  (let* ((rgb (x-color-values color))
         (red   (/ (float (nth 0 rgb)) 65535.0)) ; Convert from 0-65535 to 0.0-1.0
         (green (/ (float (nth 1 rgb)) 65535.0))
         (blue  (/ (float (nth 2 rgb)) 65535.0))
         (hsv (hexrgb-rgb-to-hsv red green blue))
         (hue        (nth 0 hsv))
         (saturation (nth 1 hsv))
         (value      (nth 2 hsv)))
    (setq hue (+ hue (/ increment 100.0)))
    (when (> hue 1.0) (setq hue (1- hue)))
    (hexrgb-color-values-to-hex (mapcar (lambda (x) (floor (* x 65535.0)))
                                        (hexrgb-hsv-to-rgb hue saturation value)))))

(defun 1on1-color-isearch-minibuffer-frame ()
  "Use `1on1-isearch-minibuffer-frame-background' for minibuffer."
  (and (boundp '1on1-minibuffer-frame)
       (save-window-excursion
         (select-frame 1on1-minibuffer-frame)
         (set-background-color
          ;; Can also try `x-defined-colors', defined in `x-win.el'.
          ;; It contains all colors currently supported by X windows.
          (if (x-color-defined-p 1on1-isearch-minibuffer-frame-background)
              1on1-isearch-minibuffer-frame-background
            "white")))))

(defun 1on1-flash-ding-minibuffer-frame (&optional do-not-terminate)
  "Ring bell (`ding'), after flashing minibuffer frame, if relevant.
Terminates any keyboard macro executing, unless arg DO-NOT-TERMINATE non-nil."
  (flash-ding do-not-terminate (and (boundp '1on1-minibuffer-frame)
                                    1on1-minibuffer-frame)))

(defun 1on1-setup-minibuffer-frame-coloring ()
  "Redefine some built-in functions so they color the minibuffer frame.
Functions redefined: `y-or-n-p', `top-level', `abort-recursive-exit'."

  (or (fboundp 'old-y-or-n-p)
      (fset 'old-y-or-n-p (symbol-function 'y-or-n-p)))

  ;; REPLACES ORIGINAL (built-in function):
  ;; Temporarily colors minibuffer frame to "active" color if at top-level.
  ;;
  (defun y-or-n-p (prompt)
    "Ask user a \"y or n\" question.  Return t if answer is \"y\".
Takes one argument, which is the string to display to ask the question.
It should end in a space; `y-or-n-p' adds `(y or n) ' to it.
No confirmation of answer is requested; a single character is enough.
Also accepts SPC to mean yes, or DEL to mean no."
    (if (> (minibuffer-depth) 0)
        (old-y-or-n-p prompt)           ; Don't do anything special if in minibuffer.
      (1on1-color-minibuffer-frame-on-setup)
      (prog1 (old-y-or-n-p prompt)
        (1on1-color-minibuffer-frame-on-exit))))


  (or (fboundp 'old-top-level)
      (fset 'old-top-level (symbol-function 'top-level)))

  ;; REPLACES ORIGINAL (built-in function):
  ;; Resets color of minibuffer frame to "inactive" color.
  ;;
  (defun top-level ()
    "Exit all recursive editing levels."
    (interactive)
    (1on1-color-minibuffer-frame-on-exit)
    (old-top-level))


  (or (fboundp 'old-abort-recursive-edit)
      (fset 'old-abort-recursive-edit (symbol-function 'abort-recursive-edit)))

  ;; REPLACES ORIGINAL (built-in function):
  ;; Resets color of minibuffer frame to "inactive" color.
  ;;
  (defun abort-recursive-edit ()
    "Abort command that requested this recursive edit or minibuffer input."
    (interactive)
    (1on1-color-minibuffer-frame-on-exit)
    (old-abort-recursive-edit)))

(defun 1on1-setup-mode-line ()
  "Set up mode-line faces."
  (when 1on1-color-mode-line-flag
    (set-face-background 'modeline 1on1-active-mode-line-background)
    (when (facep 'mode-line-inactive)   ; Emacs 22
      (set-face-background 'mode-line-inactive 1on1-inactive-mode-line-background))))

(defun 1on1-reset-minibuffer-frame ()
  (when 1on1-minibuffer-frame
    (set-frame-size 1on1-minibuffer-frame
                    (frame-width 1on1-minibuffer-frame)
                    1on1-minibuffer-frame-height)
    (1on1-set-minibuffer-frame-top/bottom)))

;;;###autoload
(defun 1on1-fit-minibuffer-frame ()
  "Fit the standalone minibuffer frame height to its contents.
Repeat to increase the height by 1.
Bind this in minibuffer keymaps to a key such as `C-o' that you can
use during minibuffer input.
This has no effect if you do not also use library `fit-frame.el'."
  (interactive)
  (unless (require 'fit-frame nil t)
    (error "You need to load library `fit-frame.el' to use this command"))
  ;; We could assume the minibuffer frame is `1on1-minibuffer-frame', but we don't.
  (when (and 1on1-fit-minibuffer-frame-flag
             (active-minibuffer-window)
             (save-selected-window
               (select-window (minibuffer-window))
               ;; We should be able to use just (one-window-p),
               ;; but an Emacs bug means we need this:
               (one-window-p nil 'selected-frame)))
    (let* ((frame         (save-selected-window
                            (select-window (minibuffer-window)) (selected-frame)))
           (frame-height  (frame-height frame)))
      (cond
        ((eq last-command '1on1-fit-minibuffer-frame)
         (set-frame-height frame (1+ (frame-height frame)))
         (1on1-set-minibuffer-frame-top/bottom)
         (condition-case nil (scroll-down (frame-height frame)) (error nil)))
        (t
         (let* ((beg                                     (1on1-minibuffer-prompt-end))
                (fit-frame-max-height
                 1on1-fit-minibuffer-frame-max-height)
                (fit-frame-max-height-percent
                 1on1-fit-minibuffer-frame-max-height-percent)
                (fit-frame-min-height                    1on1-minibuffer-frame-height)
                (window-min-height                       1on1-minibuffer-frame-height)
                (fit-frame-empty-height                  1on1-minibuffer-frame-height)
                (fit-frame-empty-special-display-height  1on1-minibuffer-frame-height))
           (fit-frame frame (frame-width frame))
;; $$$$       (when (>= emacs-major-version 21)
;;              (set-frame-height frame (1+ (frame-height frame)))) ; A little extra.
           (1on1-set-minibuffer-frame-top/bottom)
           (condition-case nil (scroll-down (frame-height frame)) (error nil))))))))

(defun 1on1-minibuffer-prompt-end ()
  "Version of `minibuffer-prompt-end' that works for Emacs 20 and later."
  (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) (point-min)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; oneonone.el ends here

^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
       [not found]               ` <4DFE09A7.10500@gmx.at>
@ 2011-06-19 14:43                 ` Drew Adams
  2011-06-19 17:26                   ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-19 14:43 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> There was a bug that caused `pop-up-frames' be processed before
> `special-display-p'.  I attach the latest version of window.el.
> 
> Please try again.

Will do.

And I will try to pare down the two files a bit for reproducing this.  But
please at least try the simple recipe using those two files (likewise the recipe
for bug #8851, using the same two files), to see if you can at least reproduce
the problem on your platform.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-19 14:43                 ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated Drew Adams
@ 2011-06-19 17:26                   ` Drew Adams
  2011-06-19 18:40                     ` martin rudalics
  2011-06-20  9:46                     ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated martin rudalics
  0 siblings, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-19 17:26 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 347 bytes --]


I've pared down the code to load.  Just load the attached and then follow the
recipe:

M-x f TAB ; to display *Completions* frame.
C-]       ; to return to top level.

M-x f TAB o

Or just hit TAB twice in a row: M-x f TAB TAB.  IOW, try to type more
input in minibuffer.

This then raises the error
"Buffer is read-only #<buffer *Completions*>"

[-- Attachment #2: throw-one.el --]
[-- Type: application/octet-stream, Size: 7544 bytes --]

(defvar 1on1-minibuffer-frame nil "Minibuffer-only frame")

(defcustom 1on1-minibuffer-frame-alist
  (list
   (assq 'foreground-color minibuffer-frame-alist)
   (assq 'background-color minibuffer-frame-alist)
   (assq 'font minibuffer-frame-alist)
   (assq 'mouse-color minibuffer-frame-alist)
   (assq 'cursor-color minibuffer-frame-alist)
   (assq 'menu-bar-lines minibuffer-frame-alist)
   (or (assq 'left minibuffer-frame-alist) (cons 'left 0))
   (or (assq 'height minibuffer-frame-alist) (cons 'height 2))
   (or (assq 'minibuffer minibuffer-frame-alist) (cons 'minibuffer 'only))
   (or (assq 'user-position minibuffer-frame-alist) (cons 'user-position t))
   (or (assq 'vertical-scroll-bars minibuffer-frame-alist)
       (cons 'vertical-scroll-bars nil))
   (or (assq 'name minibuffer-frame-alist) (cons 'name "Emacs Minibuffer")))
  "*Frame-parameter alist for the standalone minibuffer frame
`1on1-minibuffer-frame'.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'frames)

(defcustom 1on1-default-frame-alist
  (list
   (assq 'foreground-color default-frame-alist)
   (or (assq 'background-color default-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font default-frame-alist)
   (assq 'mouse-color default-frame-alist)
   (assq 'cursor-color default-frame-alist)
   (assq 'cursor-type default-frame-alist)
   (assq 'menu-bar-lines default-frame-alist)
   (or (assq 'top default-frame-alist) (cons 'top 0))
   (or (assq 'left default-frame-alist) (cons 'left 0))
   (or (assq 'width default-frame-alist) (cons 'width 80))
   (or (assq 'height default-frame-alist) (cons 'height 35))
   (or (assq 'minibuffer default-frame-alist) (cons 'minibuffer nil))
   (or (assq 'user-position default-frame-alist) (cons 'user-position t))
   (or (assq 'vertical-scroll-bars default-frame-alist)
       (cons 'vertical-scroll-bars 'right))
   (or (assq 'icon-type default-frame-alist) (cons 'icon-type nil))
   (or (assq 'tool-bar-lines default-frame-alist) (cons 'tool-bar-lines 1))
   (if (cdr (assq 'left-fringe default-frame-alist))
       (assq 'left-fringe default-frame-alist)
     (cons 'left-fringe 0))
   (if (cdr (assq 'right-fringe default-frame-alist))
       (assq 'right-fringe default-frame-alist)
     (cons 'right-fringe 0)))
  "Properties to be used for One-on-One Emacs `default-frame-alist'.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'frames)

(defcustom 1on1-special-display-frame-alist
  (list
   (assq 'font special-display-frame-alist)
   (or (assq 'width special-display-frame-alist) (cons 'width 80))
   (or (assq 'height special-display-frame-alist) (cons 'height 20))
   (assq 'mouse-color special-display-frame-alist)
   (assq 'cursor-color special-display-frame-alist)
   (assq 'menu-bar-lines special-display-frame-alist)
   (assq 'foreground-color special-display-frame-alist)
   (or (assq 'background-color special-display-frame-alist)
       (cons 'background-color "LightSteelBlue"))
   (or (assq 'top special-display-frame-alist) (cons 'top 0))
   (or (assq 'left special-display-frame-alist) (cons 'left 0))
   (or (assq 'unsplittable special-display-frame-alist)
       (cons 'unsplittable t))
   (or (assq 'user-position special-display-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars special-display-frame-alist)
       (cons 'vertical-scroll-bars 'right)))
  "Properties to be used for One-on-One `special-display-frame-alist'.
If you customize this variable, you will need to rerun `1on1-emacs'
for the new value to take effect."
  ;; If we didn't need Emacs 20 compatibility, this could be:
  ;; :type '(alist :key-type symbol :value-type sexp)
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'frames)

(defun 1on1-emacs ()
  "One-on-One Emacs setup.
Use `1on1-default-frame-alist' and `1on1-special-display-frame-alist'.
Create minibuffer-only frame, `1on1-minibuffer-frame', using
`1on1-minibuffer-frame-alist'.
Use special frame for *Completions* buffer."
  (interactive)
  (unless (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
    (error "Use `1on1-emacs' only with a graphics display"))
  (setq default-frame-alist (append 1on1-default-frame-alist default-frame-alist)
        special-display-frame-alist (append 1on1-special-display-frame-alist
                                            special-display-frame-alist))
  ;; Treat *Completions* frame, so it gets focus from minibuffer frame.
  (add-to-list
   'special-display-buffer-names
   '("*Completions*" 1on1-display-*Completions*-frame
     ((background-color . "LavenderBlush2")
      (menu-bar-lines . 0) (tool-bar-lines . 0)
      (width . 100))))
  (setq pop-up-frames  t)
  (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist
                                       minibuffer-frame-alist))
  (if 1on1-minibuffer-frame
      (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
    (setq 1on1-minibuffer-frame
          (let ((after-make-frame-functions nil)) ; E.g. inhibit `fit-frame'.
            (make-frame 1on1-minibuffer-frame-alist))))
  (1on1-set-minibuffer-frame-width)
  (1on1-set-minibuffer-frame-top/bottom)
  (setq minibuffer-auto-raise t)
  (setq w32-grab-focus-on-raise    nil
        win32-grab-focus-on-raise  nil)) ; older name

(defun 1on1-display-*Completions*-frame (buf &optional args)
  "Display *Completions* buffer in its own frame.
`special-display-function' is used to do the actual displaying.
Completion input events are redirected to `1on1-minibuffer-frame'.
BUF and ARGS are the arguments to `special-display-function'."
  (let (return-window)
    (setq return-window (select-window
                         (funcall special-display-function buf args)))
    (raise-frame)
    (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame)
    return-window))

(defun 1on1-set-minibuffer-frame-top/bottom ()
  "Set position of minibuffer frame.
Use `1on1-minibuffer-frame-top/bottom' if non-nil.
Else, place minibuffer at bottom of display."
  (condition-case nil
      (redisplay t)
    (error nil))                        ; Ignore e.g., killed buffers.
  (modify-frame-parameters
   1on1-minibuffer-frame
   `((top ,@ (- (* 2 (frame-char-height 1on1-minibuffer-frame)))))))

(defun 1on1-set-minibuffer-frame-width ()
  "Set width of minibuffer frame, in chars.
Set relative to `1on1-minibuffer-frame' char size and display size."
  (set-frame-width
   1on1-minibuffer-frame
   (/ (* 100 (x-display-pixel-width))
      (* 100 (frame-char-width 1on1-minibuffer-frame)))))

;; Last part of recipe for bug #8856:
(load-file "c:/drews-lisp-20/window-2011-06-19a-MARTIN.el")
(setq special-display-regexps '("[ ]?[*][^*]+[*]"))



^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-17 17:48               ` Drew Adams
@ 2011-06-19 17:29                 ` Drew Adams
  2011-06-20  3:04                   ` Stefan Monnier
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-19 17:29 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8851

With the second new `window.el' version that you sent today, this bug appears to
be fixed.  (Bug #8856 is not yet fixed, however.)  Thx.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-19 17:26                   ` Drew Adams
@ 2011-06-19 18:40                     ` martin rudalics
  2011-06-19 19:34                       ` bug#8856: 24.0.50; regression: `special-display-popup-frame' broken Drew Adams
  2011-06-20  9:46                     ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated martin rudalics
  1 sibling, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-19 18:40 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > I've pared down the code to load.  Just load the attached and then follow the
 > recipe:
 >
 > M-x f TAB ; to display *Completions* frame.
 > C-]       ; to return to top level.
 >
 > M-x f TAB o
 >
 > Or just hit TAB twice in a row: M-x f TAB TAB.  IOW, try to type more
 > input in minibuffer.
 >
 > This then raises the error
 > "Buffer is read-only #<buffer *Completions*>"

It does.  But it does the same on an old verion of trunk here too.  Are
you sure that the version of throw-one.el you sent me works with your
old Emacs?

BTW, in both versions I get the error when I hit c-] already.

Anyway, let's see what happens.  `display-buffer' should execute this
part

       (while (and specifiers (not (window-live-p window)))
	...
	(setq window
                ... 	
	       ((eq method 'fun-with-args)
		(apply (cadr specifier) buffer (cddr specifier))))))

calling

(defun 1on1-display-*Completions*-frame (buf &optional args)
   "..."
   (let (return-window)
     (setq return-window (select-window
                          (funcall special-display-function buf args)))
     (raise-frame)
     (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame)
     return-window))

returning return-window.  After that `display-buffer' leaves the loop
because return-window is hopefully live and

       (or (and (window-live-p window) window)

returns window (that is your return-window).  So I can't imagine that
`display-buffer' got anything to do with this.

However, I noticed that I have changed `pop-to-buffer'.  Does it help if
you use the version below?  It doesn't help here as I explained above.

martin


(defun pop-to-buffer (&optional buffer-or-name specifiers norecord label)
   "..."
   (interactive "BPop to buffer:\nP")
   (let ((buffer (normalize-buffer-to-display buffer-or-name))
	(old-window (selected-window))
	(old-frame (selected-frame))
	new-window new-frame)
     (set-buffer buffer)
     (setq new-window (display-buffer buffer specifiers label))
     (unless (eq new-window old-window)
       ;; `display-buffer' has chosen another window, select it.
       (select-window new-window norecord)
       (setq new-frame (window-frame new-window))
       (unless (eq new-frame old-frame)
	;; `display-buffer' has chosen another frame, make sure it gets
	;; input focus and is risen.
	(select-frame-set-input-focus new-frame)))
     buffer))





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50;regression: `special-display-frame' broken
  2011-06-19 14:31                 ` bug#8856: 24.0.50;regression: `special-display-frame' broken Drew Adams
@ 2011-06-19 18:50                   ` Chong Yidong
  2011-06-19 18:54                     ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: Chong Yidong @ 2011-06-19 18:50 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

"Drew Adams" <drew.adams@oracle.com> writes:

> I see.  You introduce a regression but won't click a link.
>
> OK, in that case see attached.  These are the same two files for the recipes of
> the other regressions reported.  They are not large, and they are all you need -
> the recipe is a self-contained test.

A test case consisting of 1600+ lines of complicated Elisp code is not a
good basis for debugging.  Since you are the one who wrote the code, you
are in the best position to try to isolate parts relevant to the recent
changes.







^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50;regression: `special-display-frame' broken
  2011-06-19 18:50                   ` Chong Yidong
@ 2011-06-19 18:54                     ` Drew Adams
  0 siblings, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-19 18:54 UTC (permalink / raw)
  To: 'Chong Yidong'; +Cc: 8856

> A test case consisting of 1600+ lines of complicated Elisp 
> code is not a good basis for debugging.  Since you are the
> one who wrote the code, you are in the best position to try
> to isolate parts relevant to the recent changes.

I did pare down the code thereafter, which took some time.

I was asking that the code be tried first as is, as the recipe is trivial and
quick.  That would at least determine whether you can reproduce it on your
(non-Windows) platform.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: `special-display-popup-frame' broken
  2011-06-19 18:40                     ` martin rudalics
@ 2011-06-19 19:34                       ` Drew Adams
  2011-06-19 19:52                         ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-19 19:34 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

>  > This then raises the error
>  > "Buffer is read-only #<buffer *Completions*>"
> 
> It does.  But it does the same on an old verion of trunk here 
> too.  Are you sure that the version of throw-one.el you sent
> me works with your old Emacs?

Yes, I'm sure.  I just re-tested using throw-one.el with both Emacs 23.3 and
with a build from the week before your code was added, 2011-06-03.

However, I had to remove the line I had added to throw-one.el to load your
window.el, since otherwise I got an error saying that function `window-list-1'
is void.

IOW, I cannot test an older build with your new window.el, because of that
error, but I can test an older build without any of your additions. Things work
fine with the older builds, starting from emacs -Q, with throw-one.el (minus the
line loading your new window.el).

When I test using any such old builds, the minibuffer frame keeps the focus
properly, so there is no error saying that *Completions* is read-only.  IOW, the
focus redirection from the *Completions* frame to the minibuffer frame works (in
the versions prior to your addition).

> BTW, in both versions I get the error when I hit c-] already.

I do not get any error when I hit `C-]'.  Instead I get the normal behavior for
`C-]', with the message `Quit' in the echo area.  What you're seeing sounds like
another bug (even in older releases apparently), on your platform but not on
mine (Windows).  `C-]' (`abort-recursive-edit') should just exit to the top
level and print `Quit' in this case.

Maybe, if you cannot reproduce the bug I reported, it is MS Windows-specific.

> Anyway, let's see what happens.  `display-buffer' should
> execute this part...  So I can't imagine that `display-buffer'
> got anything to do with this.

I don't quite follow you here.  Was there something you wanted me to check about
that?

> However, I noticed that I have changed `pop-to-buffer'.  Does 
> it help if you use the version below?  It doesn't help here as
> I explained above.
>
> (defun pop-to-buffer...

No, that changes nothing, unfortunately.  I see exactly the same behavior (and
different behavior apparently from what you see).

This is one reason I wanted you to just load the original files I sent and see
if you could reproduce the problem, as a start.  It's looking like the bug might
be Windows-specific.

Anyway, we at least now have a pared-down file to test with.

Thx.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: `special-display-popup-frame' broken
  2011-06-19 19:34                       ` bug#8856: 24.0.50; regression: `special-display-popup-frame' broken Drew Adams
@ 2011-06-19 19:52                         ` Drew Adams
  0 siblings, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-19 19:52 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

Does it help if I give you the value of `display-buffer-alist'?

Here is the value in a test that manifests the bug (i.e., using throw-one.el and
your latest window.el), as shown by `C-h v':

Value: ((((regexp . ".*"))
  reuse-window
  (reuse-window nil same visible)
  pop-up-window
  (pop-up-window
   (largest)
   (lru))
  pop-up-frame
  (pop-up-frame)
  reuse-window
  (reuse-window nil other visible)
  (reuse-window-even-sizes . t)))

Original value was 
((((regexp . ".*"))
  reuse-window
  (reuse-window nil same visible)
  pop-up-window
  (pop-up-window
   (largest)
   (lru))
  (pop-up-window-min-height . 40)
  (pop-up-window-min-width . 80)
  reuse-window
  (reuse-window other nil nil)
  (reuse-window-even-sizes . t)))






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-19 17:29                 ` Drew Adams
@ 2011-06-20  3:04                   ` Stefan Monnier
  0 siblings, 0 replies; 42+ messages in thread
From: Stefan Monnier @ 2011-06-20  3:04 UTC (permalink / raw)
  To: 8851-done

> With the second new `window.el' version that you sent today, this bug
> appears to be fixed.  (Bug #8856 is not yet fixed, however.)  Thx.

Good, thanks,


        Stefan





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-19 17:26                   ` Drew Adams
  2011-06-19 18:40                     ` martin rudalics
@ 2011-06-20  9:46                     ` martin rudalics
  2011-06-20 13:01                       ` Drew Adams
  1 sibling, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-20  9:46 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > I've pared down the code to load.  Just load the attached and then follow the
 > recipe:
 >
 > M-x f TAB ; to display *Completions* frame.
 > C-]       ; to return to top level.
 >
 > M-x f TAB o
 >
 > Or just hit TAB twice in a row: M-x f TAB TAB.  IOW, try to type more
 > input in minibuffer.
 >
 > This then raises the error
 > "Buffer is read-only #<buffer *Completions*>"

I suppose that after "loading the attached" I have to call `1on1-emacs'
in order to set up things first.  Only then I should try the M-x f TAB
stuff.

If I do that, I can see different behaviors indeed.  I'll look into
this.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-20  9:46                     ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated martin rudalics
@ 2011-06-20 13:01                       ` Drew Adams
       [not found]                         ` <4E00C54C.5080108@gmx.at>
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-20 13:01 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

>  > I've pared down the code to load.  Just load the attached 
>  > and then follow the recipe:
>  > M-x f TAB ; to display *Completions* frame.
>  > C-]       ; to return to top level.
>  > M-x f TAB o
>  > Or just hit TAB twice in a row: M-x f TAB TAB.  IOW, try 
>  > to type more input in minibuffer.
>  > This then raises the error
>  > "Buffer is read-only #<buffer *Completions*>"
> 
> I suppose that after "loading the attached" I have to call 
> `1on1-emacs' in order to set up things first.  Only then I should
> try the M-x f TAB stuff.
> 
> If I do that, I can see different behaviors indeed.  I'll look into
> this.

Great, thanks.

Actually, I meant that you need to do this, as stated earlier (for the earlier
load files):

runemacs.exe -Q --debug-init -l "throw-one.el" -f "1on1-emacs"

IOW, I believe that you must invoke `1on1-emacs' from the command line this way,
so it is called before any frames are displayed.

Otherwise, you will end up with two minibuffers: the standalone minibuffer frame
will not function for some things; rather, the initial minibuffer (in a normal
frame) will be used.

At least that's what I see on Windows, and I expect that it is the case for you
too.  Please run Emacs this way for testing this, so we're on the same page.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
       [not found]                         ` <4E00C54C.5080108@gmx.at>
@ 2011-06-21 18:10                           ` Drew Adams
  2011-06-22  0:13                             ` Drew Adams
                                               ` (2 more replies)
  0 siblings, 3 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-21 18:10 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

>  > Please run Emacs this way for testing this, so we're on 
>  > the same page.
> 
> I know what the bug is now.  The old code ran some very complicated
> raise-frame mechanism but did _not_ select the window if it already
> existed on another frame.  That's what I changed in the new 
> code to make it uniform with the pop-up-a-new-frame behavior.  
> Apparently that was a bad idea.  I now (hopefully) reverted the
> old behavior.
> 
> Attached find the latest window.el.  It only works with the latest two
> versions uploaded by Sean.  If you get any warnings or bugs 
> when loading or compiling it please tell me.

I'll give it a try and let you knonw.  Thanks for struggling with all of this,
and for trying to improve the handling of windows and frames - a daunting task,
no doubt.

> Also, `display-buffer-alist' will unlikely work with your code
> yet.  So you need to trigger 1on1 using the old options.

I'm not sure what you mean, in particular by the last sentence.  Are you
referring to how command `1on1-emacs' is invoked or to something else?

I assume that I would at least need to replace the assignment, in `1on1-emacs',
of `pop-up-frames' to `t' by something else, presumably something involving
`display-buffer-alist'.

Are you saying that there is not yet any good replacement in this case?  Will
you let me know when you have an idea what I can do, to DTRT, once the "yet" is
dealt with?

> Redirecting frame focus is not very easy to handle :-(

I am sure of that.  And most users have nil `pop-up-frames' (or equivalent), and
they never have to deal with focus redirection.  Likewise most Emacs
maintainers.

I've been trying to get Emacs Dev to think (and test!) more in terms of frames
for years.  Frames are nearly second-class citizens for Emacs.  Development and
maintenance changes have often, I think, been tested only with `pop-up-frames' =
nil.  Certainly they are more tested in that case than in the non-nil case.
Frames are almost an afterthought.

Partly this is no doubt due to frames being handled differently by different
window mgrs.  Partly it may be due to habit (Emacs had windows before frames,
most users do not use non-nil `pop-up-frames', etc.).

--

BTW, as you might have noticed in looking at command `1on1-emacs' and
`oneonone.el' generally, it presents an example of why it is wrong to think that
code should never bind or set user options.  I mention this because (you think
that) you disagree.

Emacs base code should not overrule user settings, of course.  But code that is
invoked by user choice is another story.  A user chooses to invoke a command,
just as s?he chooses option settings and other default values.

It is helpful for the command's doc in this case to mention that it temporarily
binds such-and-such user option to such-and-such value or that it sets the
option (i.e. not just temporarily), etc.

But there is no reason that a voluntarily invoked command should not alter a
user setting.  The moral obligation is to let users know just what the
consequences of invocation are, including option changes.  A user of command
`1on1-emacs' should know that it sets `pop-up-frames' to t, and that that is
precisely part of the command's raison d'etre.  You use `1on1-emacs' only if you
want non-nil `pop-up-frames'.

Emacs has always allowed for and even provided option-altering commands.  See
`customize-set-variable', `customize-set-value', and `set-variable', for
instance.

Personally, although I try to convince users to use Customize rather than just
Lisp code, I also believe it is helpful to go beyond Customize as an interactive
way to modify options and faces.

I've done that with Do Re Mi, for instance: provide commands to easily modify
option values incrementally.  Nothing wrong with that - in fact, we could use
more of it.  Nothing should limit us to the Customize UI as the only way to
interactively change user settings.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-21 18:10                           ` Drew Adams
@ 2011-06-22  0:13                             ` Drew Adams
  2011-06-22  0:14                             ` Drew Adams
  2011-06-22  0:15                             ` Drew Adams
  2 siblings, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-22  0:13 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> I know what the bug is now.
> Attached find the latest window.el.

I tried it, using a new build from Sean (from 6/20).  I tested it with my full
setup (oneonone.el etc., not just the pared-down file I sent you).

I still see the problem reported for this bug: focus of *Completions* is not
being redirected to the minibuffer frame.  I get the same read-only error.

But now I see that problem only when the *Completions* frame is created, not
when the frame is already displayed.  That's the _opposite_ behavior from
before: Previously, if the frame was already displayed then I got the error, but
not when it was first displayed (created).

Also, now I do not get the appearance that I defined for the *Completions*
frame.  The frame background color is that of a normal frame etc.  This is true
in the latest build, whether I load your new window.el or not.

However, buffer *Help* is correctly displayed according to its special-display
function, `1on1-display-*Help*-frame' - it has the proper background color etc.

Also, when I byte-compiled the file (to test that as you requested):

1. The *Compile-Log* buffer was not displayed.  That's probably because it had
only this in it (so probably this is not a problem):
Compiling file .../window-2011-06-21a-MARTIN.el at Tue Jun 21 11:38:26 2011

2. When I click mouse-2 on buffer *Compile-Log* in the buffer list, or I use C-x
4 b to choose it, buffer *Compile-Log* is displayed in an ordinary frame, not in
a special-display frame as it should be.  This, in spite of the fact that M-:
(string-match "[ ]?[*][^*]+[*]" "*Compile-Log*") returns 0; that string is the
only one in my `special-display-buffer-regexps'.

(What's more, my automatic frame-fitting is not invoked now, so the frame is
tiny.  I'll worry about that separately, for now.)

Other buffers that should have special-display frames (e.g. whose names match
`special-display-buffer-regexps') are correctly shown in the default
special-display frames, however.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-21 18:10                           ` Drew Adams
  2011-06-22  0:13                             ` Drew Adams
@ 2011-06-22  0:14                             ` Drew Adams
  2011-06-22  0:15                             ` Drew Adams
  2 siblings, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-22  0:14 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> I tested it with my full setup (oneonone.el etc., not just the 
> pared-down file I sent you).
> I still see the problem reported for this bug: focus of 
> *Completions* is not being redirected to the minibuffer 
> frame.  I get the same read-only error.
> But now I see that problem only when the *Completions* frame 
> is created, not when the frame is already displayed.  That's 
> the _opposite_ behavior from before...
> Also, now I do not get the appearance that I defined for the 
> *Completions* frame.  The frame background color is that of a 
> normal frame etc.  This is true in the latest build, whether 
> I load your new window.el or not.

I also tested using throw-one.el (but with the file loaded at the end being your
latest window.el, not the one from 6/19).  With that test:

1. *Completions* is shown with the proper frame background.
2. But it does not seem to be dedicated, in this sense:

If you do `M-x f TAB o TAB' everything seems fine, but if you then hit `rwa TAB'
(matching all commands that start with `forward-'), buffer *Completions* gets
replaced by buffer *scratch* in its frame.  Hitting TAB again puts *Completions*
back there, but *scratch* should never appear in that dedicated frame/window.
You can see the same thing (*scratch* replacing *Completions*) if you just type
something that has no match: `M-x f TAB qqqqqqqqq'.

However, (window-dedicated-p (get-buffer-window "*Completions*" 0)) returns t,
so officially it is dedicated.  The window, at least.  Maybe the window itself
is being replaced in that frame by another window?  No idea.

3. I do not see the read-only-error problem I reported earlier today from using
my full setup, so this pared-down test is no longer sufficient to get that.  I
also do not see that error if I use the original recipe, with just hexrgb.el and
oneonone.el.  So I'll have to start again from my full setup and pare down to
something smaller.  I cannot do that right away, however.

Thx, HTH.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-21 18:10                           ` Drew Adams
  2011-06-22  0:13                             ` Drew Adams
  2011-06-22  0:14                             ` Drew Adams
@ 2011-06-22  0:15                             ` Drew Adams
  2011-06-23 16:45                               ` Drew Adams
       [not found]                               ` <4E033CBA.1050700@gmx.at>
  2 siblings, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-22  0:15 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

> 3. I do not see the read-only-error problem I reported 
> earlier today from using my full setup, so this pared-down 
> test is no longer sufficient to get that.  I also do not see 
> that error if I use the original recipe, with just hexrgb.el 
> and oneonone.el.  So I'll have to start again from my full 
> setup and pare down to something smaller.  I cannot do that 
> right away, however.

OK, I've now pared down from my full setup again.  Took quite a while.

Use the attached file, starting Emacs, as before, this way, where the first load
file is your latest window.el:

runemacs.exe -Q --debug-init  -l "window-2011-06-21a-MARTIN.el" -l
"throw-three.el" -f "1on1-emacs"

Then, as before (but no need to exit to top level before typing more chars):

M-x f TAB o

When you hit TAB, *Completions* is shown in its frame, as expected. As soon as
you hit the second char (`o'), you get the read-only error.


Note: In the file, both of these two lines are necessary, to cause the error:

(add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
(setq w32-grab-focus-on-raise    nil)

The second is of course Windows-specific.  If I comment that out then the error
is not raised, but instead when I hit `o' the focus just changes to the
minibuffer (no `o' char appears in the minibuffer at this point).

I can tell that the focus changes because the frame border shows that (the
active frame border is a diff color from inactive frame borders - this is a
window mgr thing, not an Emacs thing).

Then, if I hit `o' a second time it (a single `o' is inserted in the minibuffer.

Thx/HTH.

[-- Attachment #2: throw-three.el --]
[-- Type: application/octet-stream, Size: 7610 bytes --]

(setq debug-on-error t)

(load-file "c:/drews-lisp-20/hexrgb.el")
(load-file "c:/drews-lisp-20/fit-frame.el")


;;; Minibuffer frame: ********************************
;;;
(defvar 1on1-minibuffer-frame nil "")

(defcustom 1on1-minibuffer-frame-alist
  (list
   (assq 'foreground-color minibuffer-frame-alist)
   (or (assq 'background-color minibuffer-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font minibuffer-frame-alist)
   (assq 'mouse-color minibuffer-frame-alist)
   (assq 'cursor-color minibuffer-frame-alist)
   (or (assq 'menu-bar-lines minibuffer-frame-alist)
       (cons 'menu-bar-lines 0))
   (or (assq 'left minibuffer-frame-alist)
       (cons 'left 0))
   (or (assq 'height minibuffer-frame-alist)
       (cons 'height 2))
   (or (assq 'icon-type minibuffer-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'minibuffer minibuffer-frame-alist)
       (cons 'minibuffer 'only))
   (or (assq 'user-position minibuffer-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars minibuffer-frame-alist) ;  No scroll bar.
       (cons 'vertical-scroll-bars nil))
   (or (assq 'name minibuffer-frame-alist)
       (cons 'name "Emacs Minibuffer")))
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'One-On-One)

;;; *Completions* frame: ********************************
(defcustom 1on1-default-frame-alist
  (list
   (assq 'foreground-color default-frame-alist)
   (or (assq 'background-color default-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font default-frame-alist)
   (assq 'mouse-color default-frame-alist)
   (assq 'cursor-color default-frame-alist)
   (assq 'cursor-type default-frame-alist)
   (or (assq 'menu-bar-lines default-frame-alist)
       (cons 'menu-bar-lines 1))
   (or (assq 'top default-frame-alist)
       (cons 'top 0))
   (or (assq 'left default-frame-alist)
       (cons 'left 0))
   (or (assq 'width default-frame-alist)
       (cons 'width 80))
   (or (assq 'height default-frame-alist)
       (cons 'height 35))
   (or (assq 'minibuffer default-frame-alist)
       (cons 'minibuffer nil))
   (or (assq 'user-position default-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars default-frame-alist)
       (cons 'vertical-scroll-bars 'right))
   (or (assq 'icon-type default-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'tool-bar-lines default-frame-alist)
       (cons 'tool-bar-lines 1))        ; Emacs 21+
   (if (cdr (assq 'left-fringe default-frame-alist))
       (assq 'left-fringe default-frame-alist)
     (cons 'left-fringe 0))             ; Emacs 21+
   (if (cdr (assq 'right-fringe default-frame-alist))
       (assq 'right-fringe default-frame-alist)
     (cons 'right-fringe 0))            ; Emacs 21+
   (or (assq 'fringe default-frame-alist)
       (cons 'fringe 0)))               ; Emacs 21, but not 21.3.50 - REMOVE after 22.x
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'frames)

;;; Special-display frames
(defcustom 1on1-special-display-frame-alist
  (list
   (assq 'font special-display-frame-alist)
   (or (assq 'width special-display-frame-alist)
       (cons 'width 80))
   (or (assq 'height special-display-frame-alist)
       (cons 'height 20))
   (assq 'mouse-color special-display-frame-alist)
   (assq 'cursor-color special-display-frame-alist)
   (or (assq 'menu-bar-lines special-display-frame-alist)
       (cons 'menu-bar-lines 1))
   (assq 'foreground-color special-display-frame-alist)
   (or (assq 'background-color special-display-frame-alist)
       (cons 'background-color "LightSteelBlue"))
   (or (assq 'top special-display-frame-alist)
       (cons 'top 0))
   (or (assq 'left special-display-frame-alist)
       (cons 'left 0))
   (or (assq 'unsplittable special-display-frame-alist)
       (cons 'unsplittable t))
   (or (assq 'user-position special-display-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars special-display-frame-alist)
       (cons 'vertical-scroll-bars 'right)))
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'frames)

(defun 1on1-emacs ()
  ""
  (interactive)
  (unless (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
    (error "Use `1on1-emacs' only with a graphics display, not with a text terminal"))
  (setq default-frame-alist (append 1on1-default-frame-alist default-frame-alist)
        special-display-frame-alist (append 1on1-special-display-frame-alist
                                            special-display-frame-alist))
  (add-to-list                          ; *Help* frame
   'special-display-buffer-names
   (list "*Help*" '1on1-display-*Help*-frame
         (list (cons 'background-color "Thistle")
               '(height . 40))))
  (add-to-list                          ; *Completions* frame
   'special-display-buffer-names
   `("*Completions*" 1on1-display-*Completions*-frame
     ((background-color . "LavenderBlush2")
      (menu-bar-lines . 0) (tool-bar-lines . 0)
      (width . 100))))
  (setq pop-up-frames  t)
  ;; Minibuffer frame
  (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist
                                       minibuffer-frame-alist))
  (if 1on1-minibuffer-frame
      (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
    (setq 1on1-minibuffer-frame
          (make-frame 1on1-minibuffer-frame-alist)))
  (set-frame-width 1on1-minibuffer-frame 150)
  (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
  (setq minibuffer-auto-raise t)

  ;; Hooks.
  ;; @@@
  (add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
  (setq w32-grab-focus-on-raise    nil)
  ;; @@@
  )
     
(defun 1on1-display-*Help*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    return-window))

(defun 1on1-display-*Completions*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    (when (boundp '1on1-minibuffer-frame)
      (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame))
    return-window))

;; @@@
(defun 1on1-fit-minibuffer-frame ()
  ""
  (interactive)
  (when (and (active-minibuffer-window)
             (save-selected-window
               (select-window (minibuffer-window))
               (one-window-p nil 'selected-frame)))
    (let* ((frame         (save-selected-window
                            (select-window (minibuffer-window)) (selected-frame)))
           (frame-height  (frame-height frame)))
      (cond
        ((eq last-command '1on1-fit-minibuffer-frame)
         (set-frame-height frame (1+ (frame-height frame)))
         (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
         (condition-case nil (scroll-down (frame-height frame)) (error nil)))
        (t
         (let ((window-min-height  2))
           (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
           (condition-case nil (scroll-down (frame-height frame)) (error nil))))))))

;; @@@


\f
(load-file "c:/drews-lisp-20/window-2011-06-21a-MARTIN.el")

^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-22  0:15                             ` Drew Adams
@ 2011-06-23 16:45                               ` Drew Adams
       [not found]                               ` <4E033CBA.1050700@gmx.at>
  1 sibling, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-23 16:45 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 4298 bytes --]

> I comment out the two lines
> ;; (load-file "c:/drews-lisp-20/hexrgb.el")
> ;; (load-file "c:/drews-lisp-20/fit-frame.el")
> at the beginning of the file.  I hope they are not needed.

Yes, that was an oversight.  They are not needed at all.

>  > Note: In the file, both of these two lines are necessary, 
>  > to cause the error:
>  > (add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
>  > (setq w32-grab-focus-on-raise    nil)
> 
> Both are in here.

Yes, they are needed.

> With the `post-command-hook' active, focus remains always within the
> Minibuffer frame at the bottom of my screen, whatever silly I 
> type.  The Completions frame is never selected.  So lets hope
> this got fixed.
> 
> I attach a copy of window.el as usual.  If you think that 
> hexrgb and/or fit-frame are needed for showing the bug,
> please tell me so.

(No, those files are not needed.  You can remove those two lines.)

Testing with the latest window.el you just sent, here are the results:


THE GOOD NEWS:

With the last setup we both tried, no bug!  That is: 
runemacs.exe -Q --debug-init -l "window-2011-06-23a-MARTIN.el" -l
"throw-three.el" -f "1on1-emacs"


THE BAD NEWS:

So I pared down again.  The bug happens if you make just this change in the
definition of `1on1-emacs':

Change these lines:

(if 1on1-minibuffer-frame
    (modify-frame-parameters
      1on1-minibuffer-frame
      1on1-minibuffer-frame-alist)
 (setq 1on1-minibuffer-frame
       (make-frame 1on1-minibuffer-frame-alist)))

To these, which is really what I use:

(if 1on1-minibuffer-frame
    (modify-frame-parameters
      1on1-minibuffer-frame
      1on1-minibuffer-frame-alist)
  (setq 1on1-minibuffer-frame
        (let ((after-make-frame-functions  nil))
          (make-frame 1on1-minibuffer-frame-alist))))

IOW, the difference is that `after-make-frame-functions' is bound to nil when
`make-frame' is called.  I do that to inhibit my `fit-frame' from doing
anything.  I have `fit-frame' on `after-make-frame-functions'.

I attached the file - just do as before, using this instead of throw-three.el.

I can try removing just `fit-frame' from that hook and then restoring it.  But I
think I shouldn't have to.  I think that correct behavior should not depend on
`after-make-frame-functions'.  Don't you agree?

Can you please take a look and see why and whether it is necessary that a user
_not_ bind `after-make-frame-functions' to nil here?

Why should `after-make-frame-functions' have any effect on whether keyboard
input for *Completions* gets properly redirected to the minibuffer frame?  You
don't use `after-make-frame-functions' in your code, do you?

If so, that I think is probably a bad idea.  Such hooks should be only for
additional, user etc. things, not for necessary code for vanilla Emacs to work
normally.

Anyway, please let me know what you think.  Give it a try with that `let'
binding (just use the attached file), to confirm that you at least see the same
problem as I.  We can then worry about what to do to fix or work around the
problem.

Again, the problem happens only when the *Completions* is first created.  What
happens on MS Windows is that whenever a frame is created it gets selected (by
the OS/window mgr - there is no way around this).

And for some reason, I guess because of emptying `after-make-frame-functions',
that Windows-frame-selection-on-creation is now also selecting the
window/buffer, and in such a way that keyboard input is not being correctly
redirected to the minibuffer frame.

And as before (since you made some changes a few days ago), things do work
correctly once the *Completions* frame has been created.  If that frame is
already showing and I repeat the recipe (M-x etc.) there is no problem.

And that is true regardless of which frame is selected when I start with M-x:
the *scratch* frame, the minibuffer frame, or even the *Completions* frame.
When I hit M-x, the input is always correctly redirected to the minibuffer
frame, so there is no error saying that *Completions* is read-only.  (Again,
this is when *Completions* was already showing.)

I think (and hope) we are almost there.  Something seems to be preventing the
input-focus redirection just after the *Completions* frame is created, when
`after-make-frame-functions' is nil.

Thx - Drew

[-- Attachment #2: throw-fit-1.el --]
[-- Type: application/octet-stream, Size: 7813 bytes --]

(setq debug-on-error t)

;;; Minibuffer frame: ********************************
;;;
(defvar 1on1-minibuffer-frame nil "")

(defcustom 1on1-minibuffer-frame-alist
  (list
   (assq 'foreground-color minibuffer-frame-alist)
   (or (assq 'background-color minibuffer-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font minibuffer-frame-alist)
   (assq 'mouse-color minibuffer-frame-alist)
   (assq 'cursor-color minibuffer-frame-alist)
   (or (assq 'menu-bar-lines minibuffer-frame-alist)
       (cons 'menu-bar-lines 0))
   (or (assq 'left minibuffer-frame-alist)
       (cons 'left 0))
   (or (assq 'height minibuffer-frame-alist)
       (cons 'height 2))
   (or (assq 'icon-type minibuffer-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'minibuffer minibuffer-frame-alist)
       (cons 'minibuffer 'only))
   (or (assq 'user-position minibuffer-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars minibuffer-frame-alist) ;  No scroll bar.
       (cons 'vertical-scroll-bars nil))
   (or (assq 'name minibuffer-frame-alist)
       (cons 'name "Emacs Minibuffer")))
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'One-On-One)

;;; *Completions* frame: ********************************
(defcustom 1on1-default-frame-alist
  (list
   (assq 'foreground-color default-frame-alist)
   (or (assq 'background-color default-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font default-frame-alist)
   (assq 'mouse-color default-frame-alist)
   (assq 'cursor-color default-frame-alist)
   (assq 'cursor-type default-frame-alist)
   (or (assq 'menu-bar-lines default-frame-alist)
       (cons 'menu-bar-lines 1))
   (or (assq 'top default-frame-alist)
       (cons 'top 0))
   (or (assq 'left default-frame-alist)
       (cons 'left 0))
   (or (assq 'width default-frame-alist)
       (cons 'width 80))
   (or (assq 'height default-frame-alist)
       (cons 'height 35))
   (or (assq 'minibuffer default-frame-alist)
       (cons 'minibuffer nil))
   (or (assq 'user-position default-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars default-frame-alist)
       (cons 'vertical-scroll-bars 'right))
   (or (assq 'icon-type default-frame-alist)
       (cons 'icon-type (< emacs-major-version 21))) ; `t' for Emacs 21 too?
   (or (assq 'tool-bar-lines default-frame-alist)
       (cons 'tool-bar-lines 1))        ; Emacs 21+
   (if (cdr (assq 'left-fringe default-frame-alist))
       (assq 'left-fringe default-frame-alist)
     (cons 'left-fringe 0))             ; Emacs 21+
   (if (cdr (assq 'right-fringe default-frame-alist))
       (assq 'right-fringe default-frame-alist)
     (cons 'right-fringe 0))            ; Emacs 21+
   (or (assq 'fringe default-frame-alist)
       (cons 'fringe 0)))               ; Emacs 21, but not 21.3.50 - REMOVE after 22.x
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'frames)

;;; Special-display frames
(defcustom 1on1-special-display-frame-alist
  (list
   (assq 'font special-display-frame-alist)
   (or (assq 'width special-display-frame-alist)
       (cons 'width 80))
   (or (assq 'height special-display-frame-alist)
       (cons 'height 20))
   (assq 'mouse-color special-display-frame-alist)
   (assq 'cursor-color special-display-frame-alist)
   (or (assq 'menu-bar-lines special-display-frame-alist)
       (cons 'menu-bar-lines 1))
   (assq 'foreground-color special-display-frame-alist)
   (or (assq 'background-color special-display-frame-alist)
       (cons 'background-color "LightSteelBlue"))
   (or (assq 'top special-display-frame-alist)
       (cons 'top 0))
   (or (assq 'left special-display-frame-alist)
       (cons 'left 0))
   (or (assq 'unsplittable special-display-frame-alist)
       (cons 'unsplittable t))
   (or (assq 'user-position special-display-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars special-display-frame-alist)
       (cons 'vertical-scroll-bars 'right)))
  ""
  :type '(repeat (cons :format "%v" (symbol :tag "Frame Parameter") (sexp :tag "Value")))
  :group 'frames)

(defun 1on1-emacs ()
  ""
  (interactive)
  (unless (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
    (error "Use `1on1-emacs' only with a graphics display, not with a text terminal"))
  (setq default-frame-alist (append 1on1-default-frame-alist default-frame-alist)
        special-display-frame-alist (append 1on1-special-display-frame-alist
                                            special-display-frame-alist))
  (add-to-list                          ; *Help* frame
   'special-display-buffer-names
   (list "*Help*" '1on1-display-*Help*-frame
         (list (cons 'background-color "Thistle")
               '(height . 40))))
  (add-to-list                          ; *Completions* frame
   'special-display-buffer-names
   `("*Completions*" 1on1-display-*Completions*-frame
     ((background-color . "LavenderBlush2")
      (menu-bar-lines . 0) (tool-bar-lines . 0)
      (width . 100))))
  (setq pop-up-frames  t)
  ;; Minibuffer frame
  (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist
                                       minibuffer-frame-alist))

  (if 1on1-minibuffer-frame
      (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
    (setq 1on1-minibuffer-frame
          (let ((after-make-frame-functions  nil)) ; E.g. inhibit `fit-frame'.
            (make-frame 1on1-minibuffer-frame-alist))))
;;   (if 1on1-minibuffer-frame
;;       (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
;;     (setq 1on1-minibuffer-frame
;;           (make-frame 1on1-minibuffer-frame-alist)))
  (set-frame-width 1on1-minibuffer-frame 150)
  (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
  (setq minibuffer-auto-raise t)

  ;; Hooks.
  ;; @@@
  (add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
  (setq w32-grab-focus-on-raise    nil)
  ;; @@@
  )
     
(defun 1on1-display-*Help*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    return-window))

(defun 1on1-display-*Completions*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    (when (boundp '1on1-minibuffer-frame)
      (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame))
    return-window))

;; @@@
(defun 1on1-fit-minibuffer-frame ()
  ""
  (interactive)
  (when (and (active-minibuffer-window)
             (save-selected-window
               (select-window (minibuffer-window))
               (one-window-p nil 'selected-frame)))
    (let* ((frame         (save-selected-window
                            (select-window (minibuffer-window)) (selected-frame)))
           (frame-height  (frame-height frame)))
      (cond
        ((eq last-command '1on1-fit-minibuffer-frame)
         (set-frame-height frame (1+ (frame-height frame)))
         (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
         (condition-case nil (scroll-down (frame-height frame)) (error nil)))
        (t
         (let ((window-min-height  2))
           (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
           (condition-case nil (scroll-down (frame-height frame)) (error nil))))))))

;; @@@

\f
(load-file "c:/drews-lisp-20/window-2011-06-23a-MARTIN.el")

^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
       [not found]                                   ` <4E037708.2000205@gmx.at>
@ 2011-06-23 22:06                                     ` Drew Adams
  2011-06-24  8:53                                       ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-23 22:06 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

Martin,

Please disregard my previous message from today completely.  Dunno what I was
seeing or thought I was seeing.  Sorry for wasting your time (and mine) with
that.

I checked again, and the same test as before, with throw-three.el, does NOT
work, i.e., the bug is still manifested.  I tested again with both the window.el
you sent yesterday and with the latest window.el you sent.  Both have the same
problem.

runemacs.exe -Q --debug-init -l "window-2011-06-21a-MARTIN.el" -l
"throw-three.el" -f "1on1-emacs"

runemacs.exe -Q --debug-init -l "window-2011-06-23a-MARTIN.el" -l
"throw-three.el" -f "1on1-emacs"

Same recipe: M-x f TAB o

When I hit the second char (`o') I get the read-only error for *Completions*.

--

(FWIW, I also checked `after-make-frame-functions' and it was anyway nil in the
tests I mentioned earlier, even without the `let' binding.  All of that was just
a wild goose chase.)






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-23 22:06                                     ` Drew Adams
@ 2011-06-24  8:53                                       ` martin rudalics
  2011-06-24 21:21                                         ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-24  8:53 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > I checked again, and the same test as before, with throw-three.el, does NOT
 > work, i.e., the bug is still manifested.  I tested again with both the window.el
 > you sent yesterday and with the latest window.el you sent.  Both have the same
 > problem.
 >
 > runemacs.exe -Q --debug-init -l "window-2011-06-21a-MARTIN.el" -l
 > "throw-three.el" -f "1on1-emacs"
 >
 > runemacs.exe -Q --debug-init -l "window-2011-06-23a-MARTIN.el" -l
 > "throw-three.el" -f "1on1-emacs"
 >
 > Same recipe: M-x f TAB o
 >
 > When I hit the second char (`o') I get the read-only error for *Completions*.

Note that apart from the

(load-file "c:/drews-lisp-20/hexrgb.el")
(load-file "c:/drews-lisp-20/fit-frame.el")

the throw-three.el you sent me contains

(load-file "c:/drews-lisp-20/window-2011-06-21a-MARTIN.el")

which contains the old definitions which don't work in your case.  I
removed all three lines in my version.


Apart from that I can see the following:

If I do -f "1on1-emacs" from the command line I see the "bad" behavior.
But I see the same behavior if I do -f "1on1-emacs" with an old Emacs
that does NOT contain my changes.  In both cases the *Completions* frame
is selected.  So please verify that this invocation DTRT with an old
Emacs of yours.

If I omit -f "1on1-emacs" from the command line and evaluate the
expression (1on1-emacs) after my initial frame appeared I don't see the
bad behavior.

Please clarify these issues.

Thanks, martin.





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-24  8:53                                       ` martin rudalics
@ 2011-06-24 21:21                                         ` Drew Adams
  2011-06-25 14:15                                           ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-24 21:21 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 2914 bytes --]

Martin,

OK, I believe I've located the problem.  Sorry for all of the confusion.

However, this is not necessarily simple, and you will need to load more in order
to see it.  I spent a lot of time on this today, but I cannot easily simplify
things more.  I think you will need to look at it first, and then we'll see what
we can do together to focus in more on the problem.

But I suspect that just by looking at the problematic part of the code you will
be able to offer a suggestion that will fix things.  Hope so.  I call
`display-buffer' with the old calling sequence, and that, I imagine, is the
problem.  With a little luck you will be able to let me know what the correction
should be, and that will take care of things.

You might be able to do that without bothering to test at all - see the end of
this message.  But I suspect it might help you to see what happens, even so.

I have tested this with Emacs 23.3 and with your latest window.el (Emacs 24
build from 6/20).  Here is the startup.  File throw-10.el is attached.  It loads
Icicles.

runemacs.exe -Q --debug-init  -l "window-2011-06-23a-MARTIN.el" -l "throw-10.el"
-f "1on1-emacs"

(For Emacs 23, the startup is the same, but without the -l of your window.el
file.)

Once Emacs is started, you can test as before: `M-x f TAB o'.

But to see the problem you need to be in Icicle mode, so do this first: `M-x
icy-mode' (toggles the mode).  You can thus test with and without Icicle mode to
see the difference.  With Emacs 23, both in and out of Icicle mode work.  With
your code it works only when not in Icicle mode.

--

You will need to download all of the Icicles source files for the test.  The
attached file, throw-10.el, loads them all, but it also then simplifies the part
of the code that I think is leading to the problem.  So the code you actually
need to look at is, I think, quite focused.

These are the Icicles files, and the place to get them:
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24

icicles-mac.el
icicles-face.el
icicles-opt.el
icicles-var.el
icicles-fn.el
icicles-mcmd.el
icicles-cmd1.el
icicles-cmd2.el
icicles-mode.el
icicles.el

The code to focus on is, I believe, in test-10.el, function
`icicle-display-candidates-in-Completions'.  (This function is called a lot, in
many Icicles contexts.)

This is the part of the code that I think is problematic - marked with a
`@@@@@@@' comment:

(let ((comp-buf  (get-buffer-create "*Completions*")))
  (unless (get-buffer-window comp-buf 'visible)
    (save-selected-window
      (display-buffer comp-buf t 0) ; <== the problem, no doubt
      (deactivate-mark))))

This calls `display-buffer', but it uses the old calling sequence, which I'm
guessing is the problem.  The point of this code is just to visit display the
buffer and deactivate the mark there.

Again, sorry for the amount of work.  Hoping this will help.

Thx - Drew


[-- Attachment #2: throw-10.el --]
[-- Type: application/octet-stream, Size: 10580 bytes --]

(setq debug-on-error t)

(load-file "c:/drews-lisp-20/icicles-mac.el")
(load-file "c:/drews-lisp-20/icicles-face.el")
(load-file "c:/drews-lisp-20/icicles-opt.el")
(load-file "c:/drews-lisp-20/icicles-var.el")
(load-file "c:/drews-lisp-20/icicles-fn.el")
(load-file "c:/drews-lisp-20/icicles-mcmd.el")
(load-file "c:/drews-lisp-20/icicles-cmd1.el")
(load-file "c:/drews-lisp-20/icicles-cmd2.el")
(load-file "c:/drews-lisp-20/icicles-mode.el")
(load-file "c:/drews-lisp-20/icicles.el")

;; (when (fboundp 'icicle-mode) (icicle-mode 1))

;; Pared down.
(defun icicle-display-candidates-in-Completions (&optional reverse-p no-display-p)
  ""
  (setq icicle-incremental-completion-p  icicle-incremental-completion-flag)
  (when (and (eq t icicle-incremental-completion-p) (get-buffer-window "*Completions*" 0))
    (setq icicle-incremental-completion-p  'always))
  (let ((nb-cands             (length icicle-completion-candidates)))
    (cond ((eq no-display-p 'no-msg))   ; No-op.
          (no-display-p)                ; Simplified for test.
          ((null icicle-completion-candidates) ; Simplified for test.
           (save-selected-window (icicle-remove-Completions-window)))
          (t
           ;; @@@ THIS SEEMS TO BE WHERE THE PROBLEM IS @@@@@@@@@@@@@@@@@@@
           (when (consp icicle-completion-candidates)
             (let ((comp-buf  (get-buffer-create "*Completions*")))
               (unless (get-buffer-window comp-buf 'visible)
                 ;; Remove any leftover mouse selection.
                 (save-selected-window
                   (display-buffer comp-buf t 0) ; <== the problem, no doubt
                   (deactivate-mark)))))
           ;; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

           (with-output-to-temp-buffer "*Completions*"
             ;; The `condition-case' shouldn't be needed, but it prevents an
             ;; "End of buffer" message from `display-completion-list' on Emacs 22.
             (condition-case nil
                 (display-completion-list
                  (if reverse-p (reverse icicle-completion-candidates)
                    icicle-completion-candidates))
               (error nil)))
           (message nil)))))

;; Make these functions into no-ops, to simplify things a bit.
(defun icicle-activate-mark () "" nil)
(defun icicle-cancel-Help-redirection () "" nil)
(defun icicle-restore-region-face () "" nil)
(defun icicle-unhighlight-lighter () "" nil)
(defun icicle-fit-completions-window (&optional arg) "" nil)

;---------------------------------


;;; Minibuffer frame
(defvar 1on1-minibuffer-frame nil "")

(defcustom 1on1-minibuffer-frame-alist
  (list
   (assq 'foreground-color minibuffer-frame-alist)
   (or (assq 'background-color minibuffer-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font minibuffer-frame-alist)
   (assq 'mouse-color minibuffer-frame-alist)
   (assq 'cursor-color minibuffer-frame-alist)
   (or (assq 'menu-bar-lines minibuffer-frame-alist)
       (cons 'menu-bar-lines 0))
   (or (assq 'left minibuffer-frame-alist)
       (cons 'left 0))
   (or (assq 'height minibuffer-frame-alist)
       (cons 'height 2))
   (or (assq 'icon-type minibuffer-frame-alist)
       (cons 'icon-type (< emacs-major-version 21)))
   (or (assq 'minibuffer minibuffer-frame-alist)
       (cons 'minibuffer 'only))
   (or (assq 'user-position minibuffer-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars minibuffer-frame-alist)
       (cons 'vertical-scroll-bars nil))
   (or (assq 'name minibuffer-frame-alist)
       (cons 'name "Emacs Minibuffer")))
  ""
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'One-On-One)

;;; *Completions* frame
(defcustom 1on1-default-frame-alist
  (list
   (assq 'foreground-color default-frame-alist)
   (or (assq 'background-color default-frame-alist)
       (cons 'background-color "LightBlue"))
   (assq 'font default-frame-alist)
   (assq 'mouse-color default-frame-alist)
   (assq 'cursor-color default-frame-alist)
   (assq 'cursor-type default-frame-alist)
   (or (assq 'menu-bar-lines default-frame-alist)
       (cons 'menu-bar-lines 1))
   (or (assq 'top default-frame-alist)
       (cons 'top 0))
   (or (assq 'left default-frame-alist)
       (cons 'left 0))
   (or (assq 'width default-frame-alist)
       (cons 'width 80))
   (or (assq 'height default-frame-alist)
       (cons 'height 35))
   (or (assq 'minibuffer default-frame-alist)
       (cons 'minibuffer nil))
   (or (assq 'user-position default-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars default-frame-alist)
       (cons 'vertical-scroll-bars 'right))
   (or (assq 'icon-type default-frame-alist)
       (cons 'icon-type (< emacs-major-version 21)))
   (or (assq 'tool-bar-lines default-frame-alist)
       (cons 'tool-bar-lines 1))
   (if (cdr (assq 'left-fringe default-frame-alist))
       (assq 'left-fringe default-frame-alist)
     (cons 'left-fringe 0))
   (if (cdr (assq 'right-fringe default-frame-alist))
       (assq 'right-fringe default-frame-alist)
     (cons 'right-fringe 0))
   (or (assq 'fringe default-frame-alist)
       (cons 'fringe 0)))
  ""
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'frames)

;;; Special-display frames
(defcustom 1on1-special-display-frame-alist
  (list
   (assq 'font special-display-frame-alist)
   (or (assq 'width special-display-frame-alist)
       (cons 'width 80))
   (or (assq 'height special-display-frame-alist)
       (cons 'height 20))
   (assq 'mouse-color special-display-frame-alist)
   (assq 'cursor-color special-display-frame-alist)
   (or (assq 'menu-bar-lines special-display-frame-alist)
       (cons 'menu-bar-lines 1))
   (assq 'foreground-color special-display-frame-alist)
   (or (assq 'background-color special-display-frame-alist)
       (cons 'background-color "LightSteelBlue"))
   (or (assq 'top special-display-frame-alist)
       (cons 'top 0))
   (or (assq 'left special-display-frame-alist)
       (cons 'left 0))
   (or (assq 'unsplittable special-display-frame-alist)
       (cons 'unsplittable t))
   (or (assq 'user-position special-display-frame-alist)
       (cons 'user-position t))
   (or (assq 'vertical-scroll-bars special-display-frame-alist)
       (cons 'vertical-scroll-bars 'right)))
  ""
  :type '(repeat (cons :format "%v"
                  (symbol :tag "Frame Parameter")
                  (sexp :tag "Value")))
  :group 'frames)

;; Pared down.
(defun 1on1-emacs ()
  ""
  (interactive)
  (setq default-frame-alist (append 1on1-default-frame-alist default-frame-alist)
        special-display-frame-alist (append 1on1-special-display-frame-alist
                                            special-display-frame-alist))
  (add-to-list                          ; *Help* frame
   'special-display-buffer-names
   (list "*Help*" '1on1-display-*Help*-frame
         (list (cons 'background-color "Thistle")
               '(height . 40))))
  (add-to-list                          ; *Completions* frame
   'special-display-buffer-names
   `("*Completions*" 1on1-display-*Completions*-frame
     ((background-color . "LavenderBlush2")
      (menu-bar-lines . 0) (tool-bar-lines . 0)
      (width . 100))))
  (setq pop-up-frames  t)
  ;; Minibuffer frame
  (setq minibuffer-frame-alist (append 1on1-minibuffer-frame-alist
                                       minibuffer-frame-alist))
  (if 1on1-minibuffer-frame
      (modify-frame-parameters 1on1-minibuffer-frame 1on1-minibuffer-frame-alist)
    (setq 1on1-minibuffer-frame
          (make-frame 1on1-minibuffer-frame-alist)))
  (set-frame-width 1on1-minibuffer-frame 150)
  (modify-frame-parameters 1on1-minibuffer-frame `((top ,@ -50)))
  (setq minibuffer-auto-raise t)
;;; (if foobar
;;;       (add-hook 'post-command-hook '1on1-fit-minibuffer-frame)
;;;     (remove-hook 'post-command-hook '1on1-fit-minibuffer-frame))
  (setq w32-grab-focus-on-raise  nil))

;; Pared down.
(defun 1on1-display-*Help*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    return-window))

;; Pared down.
(defun 1on1-display-*Completions*-frame (buf &optional args)
  ""
  (let (return-window)
    (setq return-window (select-window (funcall special-display-function buf args)))
    (raise-frame)
    (when (boundp '1on1-minibuffer-frame)
      (redirect-frame-focus (selected-frame) 1on1-minibuffer-frame))
    return-window))

;; Pared down.
(defun 1on1-set-minibuffer-frame-top/bottom ()
  ""
  (when (boundp '1on1-minibuffer-frame)
    (condition-case nil (redisplay t) (error nil))
    (modify-frame-parameters 1on1-minibuffer-frame '((top . -50)))))

;; Pared down.
(defun 1on1-fit-minibuffer-frame ()
  ""
  (interactive)
;;   (unless (require 'fit-frame nil t)
;;     (error "You need to load library `fit-frame.el' to use this command"))
  (when (and (active-minibuffer-window)
             (save-selected-window
               (select-window (minibuffer-window))
               (one-window-p nil 'selected-frame)))
    (let* ((frame         (save-selected-window
                            (select-window (minibuffer-window)) (selected-frame)))
           (frame-height  (frame-height frame)))
      (cond
        ((eq last-command '1on1-fit-minibuffer-frame)
         (set-frame-height frame (1+ (frame-height frame)))
         (1on1-set-minibuffer-frame-top/bottom)
         (condition-case nil (scroll-down (frame-height frame)) (error nil)))
        (t
         (let* ((beg                                     (minibuffer-prompt-end))
                (fit-frame-max-height                    nil)
                (fit-frame-max-height-percent            10)
                (fit-frame-min-height                    2)
                (window-min-height                       2)
                (fit-frame-empty-height                  2)
                (fit-frame-empty-special-display-height  2))
           (fit-frame frame (frame-width frame))
           (1on1-set-minibuffer-frame-top/bottom)
           (condition-case nil (scroll-down (frame-height frame)) (error nil))))))))

^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-24 21:21                                         ` Drew Adams
@ 2011-06-25 14:15                                           ` martin rudalics
  2011-06-25 14:52                                             ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-25 14:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > These are the Icicles files, and the place to get them:
 > http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
 > 3F%24
 >
 > icicles-mac.el
 > icicles-face.el
 > icicles-opt.el
 > icicles-var.el
 > icicles-fn.el
 > icicles-mcmd.el
 > icicles-cmd1.el
 > icicles-cmd2.el
 > icicles-mode.el
 > icicles.el

It's a pain to get ten files from there one by one.  Can't you pack them
and send them in an attachment together with the throw-... file?  I
suppose you have them in one and the same directory and a thing like
7-zip around.  So this should be much easier for you ...

 > (let ((comp-buf  (get-buffer-create "*Completions*")))
 >   (unless (get-buffer-window comp-buf 'visible)
 >     (save-selected-window
 >       (display-buffer comp-buf t 0) ; <== the problem, no doubt
 >       (deactivate-mark))))

Could you explain what you think that happens, happens instead, or does
not happen here?  "0" won't do anything `display-buffer' without that
argument would not have done anyway: Search all visible and iconified
frames for a window showing comp-buf.  Maybe there are reasons why this
argument is needed and I should put back its semantics but I never found
one and don't find one here.

IIUC the code tests whether it finds a visible window showing comp-buf.
If it doesn't, either because the window doesn't exist or is not
visible, it tries to get one on an iconified frame or make a new frame
and deactivate the mark there.  So you probably raise the frame of
com-buf and then want to redirect focus from the comp-buf window to your
minibuffer window which probably was selected here, and finally you
reselect the minibuffer window because of the `save-selected-window'.
But for some reason the comp-buf window remains selected.  Is it that
what you see?

Note: In all examples you sent me before you didn't have a thing like
`save-selected-window' around a `display-buffer' call.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 14:15                                           ` martin rudalics
@ 2011-06-25 14:52                                             ` Drew Adams
       [not found]                                               ` <8A3D5626004B4 945A624B69463A0B849@us.oracle.com>
  2011-06-25 15:04                                               ` Drew Adams
  0 siblings, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-25 14:52 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> It's a pain to get ten files from there one by one.  Can't 
> you pack them and send them in an attachment together with
> the throw-... file?  I suppose you have them in one and the
> same directory and a thing like 7-zip around.  So this
> should be much easier for you ...

There are several bulk download methods for Icicles, if you feel that
right-clicking 10 times is onerous:

http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Libraries#toc5

Try one of the 3 download scripts (see the first two bullets).  If you don't
like any of the bulk download methods then I will send a 7zip archive to you by
mail - let me know.
 
>  > (let ((comp-buf  (get-buffer-create "*Completions*")))
>  >   (unless (get-buffer-window comp-buf 'visible)
>  >     (save-selected-window
>  >       (display-buffer comp-buf t 0) ; <== the problem, no doubt
>  >       (deactivate-mark))))
> 
> Could you explain what you think that happens, happens 
> instead, or does not happen here?  "0" won't do anything
> `display-buffer' without that argument would not have done
> anyway: Search all visible and iconified frames for a window
> showing comp-buf.

(Again, to be sure we're on the same page, this is a call to `display-buffer'
for Emacs prior to your changes.  Perhaps I need to modify it now, for Emacs
24+.)

The code above is Icicles code.  Icicles does not require users to use non-nil
`pop-up-frames' (and most do not probably).  In my own, personal setup I use
non-nil `pop-up-frames', but this code needs to work with any value of that
option.

You are the expert on `display-buffer', but this is my understanding.  From the
`display-buffer' doc string:

Emacs 20:

 If FRAME is 0, search all visible and iconified frames.
 If FRAME is nil, search only the selected frame
  (actually the last nonminibuffer frame),
  unless `pop-up-frames' is non-nil,
  which means search visible and iconified frames.

Emacs 22 says the same, but it adds "or `display-buffer-reuse-frames'" to
`pop-up-frames'.

Emacs 23 and Emacs 24 before your changes say the same as Emacs 22, but they
distinguish the `graphic-only' case of non-nil for pop-up-frames.

The Elisp manual says essentially the same thing.  The Emacs 23.3 manual says
only this about a nil value for FRAME (but it then lists a long page of other
options that also affect the behavior of `display-buffer').

 `nil' means consider windows on the selected frame.
 (Actually, the last non-minibuffer frame.)

IIUC, in the above code, I do not want nil for FRAME, because I do not want only
the selected frame checked for a *Completions* window.

> Maybe there are reasons why this argument is needed and I
> should put back its semantics but I never found one and
> don't find one here.

Do you see one now?  Am I missing something?

> IIUC the code tests whether it finds a visible window showing 
> comp-buf.  If it doesn't, either because the window doesn't
> exist or is not visible, it tries to get one on an iconified
> frame or make a new frame

New window, not new frame - no?

Unless `pop-up-frames is non-nil etc.  Again, please keep in mind that this is
general code for users with all possible values of `pop-up-frames' etc.

> and deactivate the mark there.  So you probably raise the frame of
> com-buf and then want to redirect focus from the comp-buf 
> window to your
> minibuffer window which probably was selected here, and finally you
> reselect the minibuffer window because of the `save-selected-window'.
> But for some reason the comp-buf window remains selected.  Is it that
> what you see?

I guess so.  I don't know about the explanation of why, but yes, as I described
earlier, for some reason the new *Completions* frame is getting the input
(keyboard) focus.  It is supposed to be a frame that always has its keyboard
input redirected to the minibuffer frame.

I suspect it's better to concentrate on the problem of input focus rather than
speaking only in terms of window/frame selection.  The new *Completions* frame
_appears_ selected even prior to your changes (as shown by the window mgr border
color, for instance), but the input focus is always correctly redirected to the
minibuffer frame.

That is the change (problem): the keyboard input focus.  It seems (symptom, not
explanation) as if the frame is no longer being correctly redirected, in terms
of input focus.

> Note: In all examples you sent me before you didn't have a thing like
> `save-selected-window' around a `display-buffer' call.

Not sure what you're saying there.  Is that not a good idea?

Thx - Drew






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 14:52                                             ` Drew Adams
       [not found]                                               ` <8A3D5626004B4 945A624B69463A0B849@us.oracle.com>
@ 2011-06-25 15:04                                               ` Drew Adams
  2011-06-25 15:57                                                 ` martin rudalics
  1 sibling, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-25 15:04 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

To clarify some of what I said last -

> for some reason the new *Completions* frame is getting
> the input (keyboard) focus.  It is supposed to be a
> frame that always has its keyboard input redirected to
> the minibuffer frame.
>
> I suspect it's better to concentrate on the problem of input 
> focus rather than speaking only in terms of window/frame
> selection.

Re-reading that, it sounds a bit misleading ("always").  It is of course also
about which window/frame is selected (and a user can in fact change the input
focus to *Completions*, via a minibuffer keymap key).

I just meant that in this situation *Completions* should have the focus, and it
does not.

> The new *Completions* frame _appears_ selected even prior
> to your changes (as shown by the window mgr border
> color, for instance), but the input focus is always correctly 
> redirected to the minibuffer frame.

That was all I was trying to say above wrt "selection".  What counts here is
that *Completions* is getting the input focus and it should not be getting it.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 15:04                                               ` Drew Adams
@ 2011-06-25 15:57                                                 ` martin rudalics
  2011-06-25 16:15                                                   ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-25 15:57 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > That was all I was trying to say above wrt "selection".  What counts here is
 > that *Completions* is getting the input focus and it should not be getting it.

I downloaded your Icicles tarball and tried with throw-10.  Everything
seems to work as expected including focus redirection and resurrection
of an iconified Completions frame.  So if you don't use any additional
strings the problem seems fixed.

I can't tell why it doesn't work on your machine.  Maybe some .el files
have to be recompiled in order to work with my later fixes so it's
likely best to wait till Sean uploads the new binaries (IIRC this
happens every Monday).  As soon as you tried with the new binaries tell
me what you get.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 15:57                                                 ` martin rudalics
@ 2011-06-25 16:15                                                   ` Drew Adams
  2011-06-25 17:00                                                     ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-25 16:15 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> I downloaded your Icicles tarball and tried with throw-10.  Everything
> seems to work as expected including focus redirection and resurrection
> of an iconified Completions frame.

There should be no iconfied Completions frame in the test I gave you.

The problem arises only when the Completions frame is newly _created_, as I
tried to explain.  If you use `M-x f TAB o' (recipe) after the frame has already
been created then the input focus is not a problem.

If you have the frame already, then please delete it and try `M-x f TAB o'
again.

> So if you don't use any additional strings the problem seems
> fixed.  I can't tell why it doesn't work on your machine.

As I said, it's possible that this is Windows-specific.  Windows is I think
(thought) a bit peculiar when it comes to its auto-selecting a new frame -  but
you said that most window mgrs do that now.  I still wonder if this isn't
Windows-specific, since you cannot reproduce it and it is systematic for me when
I follow the same recipe.

> Maybe some .el files have to be recompiled in order to work
> with my later fixes

Do you mean my .el or .el from Emacs sources?  In the files I provided for the
test, please use only .el, no .elc.

> so it's likely best to wait till Sean uploads the new binaries
> (IIRC this happens every Monday).  As soon as you tried with
> the new binaries tell me what you get.

I'll certainly do that.

But what about that `display-buffer' call in
`icicle-display-candidates-in-Completions'?  Can you suggest a change for it?
Does that code look like it _should_ work after your changes, or should it be
changed?

And you mentioned the `save-selected-window' around that `display-buffer' call.
Does that need to be changed somehow?






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 16:15                                                   ` Drew Adams
@ 2011-06-25 17:00                                                     ` martin rudalics
  2011-06-25 17:48                                                       ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-25 17:00 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 >> I downloaded your Icicles tarball and tried with throw-10.  Everything
 >> seems to work as expected including focus redirection and resurrection
 >> of an iconified Completions frame.
 >
 > There should be no iconfied Completions frame in the test I gave you.

When I type foo and eventually get the sole completion footnote-mode the
Completions frame iconifies automatically.  I didn't check why that
happens, shouldn't it?  When I then type M-x f TAB again it gets orderly
resurrected.

 > The problem arises only when the Completions frame is newly _created_, as I
 > tried to explain.  If you use `M-x f TAB o' (recipe) after the frame has already
 > been created then the input focus is not a problem.
 >
 > If you have the frame already,

The Completions frame?  It pops up automatically when I hit TAB and
redirects focus to the Minibuffer frame.

 > then please delete it and try `M-x f TAB o'
 > again.
 >
 >> So if you don't use any additional strings the problem seems
 >> fixed.  I can't tell why it doesn't work on your machine.
 >
 > As I said, it's possible that this is Windows-specific.  Windows is I think
 > (thought) a bit peculiar when it comes to its auto-selecting a new frame -  but
 > you said that most window mgrs do that now.  I still wonder if this isn't
 > Windows-specific, since you cannot reproduce it and it is systematic for me when
 > I follow the same recipe.

But I test this on Windows XP.

 >> Maybe some .el files have to be recompiled in order to work
 >> with my later fixes
 >
 > Do you mean my .el or .el from Emacs sources?  In the files I provided for the
 > test, please use only .el, no .elc.

 From the Emacs sources.  Maybe some completions-related stuff.

 >> so it's likely best to wait till Sean uploads the new binaries
 >> (IIRC this happens every Monday).  As soon as you tried with
 >> the new binaries tell me what you get.
 >
 > I'll certainly do that.

OK.

 > But what about that `display-buffer' call in
 > `icicle-display-candidates-in-Completions'?  Can you suggest a change for it?
 > Does that code look like it _should_ work after your changes, or should it be
 > changed?

It should work vacuously.  But I'd like to know why you needed it
earlier.  Earlier Emacsen had `display-buffer' do

      ((let ((frames (or frame

here frame is the value "0" you provide as argument

			(and (or use-pop-up-frames
				 display-buffer-reuse-frames
				 (not (last-nonminibuffer-frame)))
			     0)

and the "0" you see in the previous line means exactly the same.  Any
visible or iconified frame provided you use either `pop-up-frames' or
`display-buffer-reuse-frames'.  And I suppose it doesn't make sense to
use Icicles with these set to nil.  Now if you insisted on searching
only visible frames here I would see a problem ...

			(last-nonminibuffer-frame))))
	(setq window-to-use
	      (catch 'found
		;; Search frames for a window displaying BUFFER.  Return
		;; the selected window only if we are allowed to do so.
		(dolist (window (get-buffer-window-list buffer 'nomini frames))
		  (when (or can-use-selected-window
			    (not (eq (selected-window) window)))
		    (throw 'found window))))))
       ;; The buffer is already displayed in some window; use that.
       (window--display-buffer-1 window-to-use))

I can easily resurrect the old semantics of that argument for the few
values t, 0, visible and a live frame but I would first like to see a
real use case for it.

 > And you mentioned the `save-selected-window' around that `display-buffer' call.
 > Does that need to be changed somehow?

I'm not quite sure what you expect it to do.  IIUC you want the
Completions window selected with focus redirected to the Minibuffer
window.  Now which window is the one whose selection you want to save
here?  Anyway, it shouldn't harm so leave it alone.

martin





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 17:00                                                     ` martin rudalics
@ 2011-06-25 17:48                                                       ` Drew Adams
  2011-06-26 13:50                                                         ` martin rudalics
  0 siblings, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-25 17:48 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

>  > There should be no iconfied Completions frame in the test 
>  > I gave you.
> 
> When I type foo and eventually get the sole completion 
> footnote-mode the Completions frame iconifies automatically.
> I didn't check why that happens, shouldn't it?
> When I then type M-x f TAB again it 
> gets orderly resurrected.

Yes, that is all "normal" Emacs behavior.

But that was not the recipe.

1. I don't think you are in Icicle mode when testing.
Did you do `M-x icy-mode' at the start, to get in the mode?

I mentioned that you can try the same test (starting from Emacs startup each
time) both in and out of Icicle mode, to see the difference.  If not in Icicle
mode then you will not see the bug.

2. If you are in Icicle mode then you won't even get to `foo' after hitting `M-x
f TAB'.

After starting Emacs as I indicated and getting into Icicle mode, when you hit
`M-x f TAB' the Completions frame is created and it incorrectly gets the input
focus.  When you then hit `o' you get the read-only error.

It is important to test from scratch: no Completions frame or buffer, not even
iconified.  Then just type `M-x f TAB o'.

Note that even in Emacs 23, where there is no such bug, when you complete to
footnote-mode in Icicle mode the Completions frame is not iconified.  It is
instead deleted.

If you are seeing iconification of Completions then you are not in Icicle mode,
I think.  You can easily tell when you are in Icicle mode by looking at the mode
line - you will see `Icy' there.

FYI - The Completions frame/window removal code is in file icicles-mcmd.el,
function `icicle-remove-Completions-window', which calls
`icicle-delete-windows-on'.  In this case *Completions* is dedicated, and
`delete-frame' is called.

>  > The problem arises only when the Completions frame is 
>  > newly _created_, as I tried to explain.  If you use
>  > `M-x f TAB o' (recipe) after the frame has already
>  > been created then the input focus is not a problem.
>  >
>  > If you have the frame already,
> 
> The Completions frame?  It pops up automatically when I hit TAB and
> redirects focus to the Minibuffer frame.

Yes, it should.

>  > then please delete it and try `M-x f TAB o' again.

I was trying to direct you to follow the recipe, which starts with (a) Icicle
mode and (b) _no_ Completions frame.  Once the frame has been created you will
not see the bug.

See above for, I hope, clear instructions: Start Emacs again, get in Icicle
mode, then hit `M-x f TAB o'.  That's all there is to it.

> But I test this on Windows XP.

Ah, excellent.  I'm on XP too, so we should be able to work this out.  So far,
it seems like you did not test in Icicle mode.  Try that and see, please.

>  > But what about that `display-buffer' call in
>  > `icicle-display-candidates-in-Completions'?
> 
> It should work vacuously.  But I'd like to know why you
> needed it earlier... And I suppose it doesn't make sense to
> use Icicles with these set to nil.

Yes, it does make sense!  See my previous message.  I tried to say clearly that
Icicles has nothing to do with my personal setup where I use `pop-up-frames'
etc.  Icicles is a general package, and most of its users, I believe, do not use
non-nil `pop-up-frames' - and most certainly don't use my oneonone.el setup.

> I can easily resurrect the old semantics of that argument for the few
> values t, 0, visible and a live frame but I would first like to see a
> real use case for it.

I have a real use case for it.  See above.  My code needs to work for users who
have nil and users who have non-nil `pop-up-frames' etc.

And see what I wrote wrt the `display-buffer' doc.  For nil `pop-up-frames' etc.
an argument of 0 is not at all the same as an argument of nil, according to the
doc.  Why do you think they added the 0 value?  Why do you think it is
superfluous?  What am I missing here?

>  > And you mentioned the `save-selected-window' around that 
>  > `display-buffer' call.  Does that need to be changed somehow?
> 
> I'm not quite sure what you expect it to do.  IIUC you want the
> Completions window selected with focus redirected to the Minibuffer
> window.  Now which window is the one whose selection you want to save
> here?  Anyway, it shouldn't harm so leave it alone.

The selected window can I believe be any window, depending on the context.  It
could be the minibuffer window or another buffer window.  It could (I think,
without bothering to verify) even be the Completions window.  Thanks for
confirming that it does no harm - I will leave it.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-25 17:48                                                       ` Drew Adams
@ 2011-06-26 13:50                                                         ` martin rudalics
  2011-06-26 14:56                                                           ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-26 13:50 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]

 > 1. I don't think you are in Icicle mode when testing.
 > Did you do `M-x icy-mode' at the start, to get in the mode?

No.

 > I mentioned that you can try the same test (starting from Emacs startup each
 > time) both in and out of Icicle mode, to see the difference.  If not in Icicle
 > mode then you will not see the bug.
 >
 > 2. If you are in Icicle mode then you won't even get to `foo' after hitting `M-x
 > f TAB'.
 >
 > After starting Emacs as I indicated and getting into Icicle mode, when you hit
 > `M-x f TAB' the Completions frame is created and it incorrectly gets the input
 > focus.  When you then hit `o' you get the read-only error.
 >
 > It is important to test from scratch: no Completions frame or buffer, not even
 > iconified.  Then just type `M-x f TAB o'.

I see it now.  The Completions buffer pop ups up in a normal frame instead.

 > Note that even in Emacs 23, where there is no such bug, when you complete to
 > footnote-mode in Icicle mode the Completions frame is not iconified.  It is
 > instead deleted.

I attached a fixed copy of window.el, please try it.  Completing now
deletes the Completions frame.  I also restored the old meaning of the
third argument of `display-buffer' for the described frame values.

martin

[-- Attachment #2: window.zip --]
[-- Type: application/zip, Size: 65148 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-26 13:50                                                         ` martin rudalics
@ 2011-06-26 14:56                                                           ` Drew Adams
       [not found]                                                             ` <0721F495F4A441529FCB91280D284E42@us.oracle.com! >
  2011-06-26 15:15                                                             ` Drew Adams
  0 siblings, 2 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-26 14:56 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> I see it now.  The Completions buffer pop ups up in a normal 
> frame instead.  I attached a fixed copy of window.el, please try it.
> Completing now deletes the Completions frame.  I also restored the
> old meaning of the third argument of `display-buffer' for the
> described frame values.

Bravo!  And thank you.  Completions is now correctly redirected: no more
read-only error.

However, I now see this problem, which might or might not be due to this fix -
dunno.  It seems that the *Completions* window is still not a proper dedicated
window, at least some of the time (?).

`C-g' and `C-]' in Icicles during completion invoke
`icicle-abort-recursive-edit' (in file icicles-mcmd.el), which does this:

(if (not (active-minibuffer-window))
    (when (get-buffer "*Completions*")
      (kill-buffer (get-buffer "*Completions*")))
  (icicle-remove-Completions-window 'FORCE))
(abort-recursive-edit)

This should remove the *Completions* window/frame.  In the case in question, the
second branch of the `if' is taken, invoking `icicle-remove-Completions-window'
(which is also in file icicles-mcmd.el).

What is happening now is that the first `C-g' does not remove Completions (e.g.
delete the frame) - a second `C-g' is needed.

Similarly, if you do `C-x 0' in the minibuffer it should remove Completions (it
is bound to `icicle-remove-Completions-window').  That also does not work (no
matter how many times you use it in a row).

Here is what is happening, by `M-x debug-on-entry icicle-abort-recursive-edit'.

Debugger entered--returning value: nil
  window-dedicated-p(#<window 14 on *Completions*>)
* (if (window-dedicated-p (get-buffer-window "*Completions*" (quote visible)))
(progn (condition-case nil (icicle-delete-windows-on "*Completions*") (error
nil))))
* (when (window-dedicated-p (get-buffer-window "*Completions*" (quote visible)))
(condition-case nil (icicle-delete-windows-on "*Completions*") (error nil)))
* (cond ((and (get-buffer-window "*Completions*") (or force (and (window-live-p
swin) (not (eq (window-buffer swin) (get-buffer "*Completions*"))))
(interactive-p))) (condition-case nil (delete-window (get-buffer-window
"*Completions*")) (error nil)) (bury-buffer (get-buffer "*Completions*"))) ((and
(get-buffer-window "*Completions*" (quote visible)) (or force (and
(window-live-p swin) (not (eq (window-buffer swin) (get-buffer
"*Completions*")))) (interactive-p))) (when (window-dedicated-p
(get-buffer-window "*Completions*" (quote visible))) (condition-case nil
(icicle-delete-windows-on "*Completions*") (error nil))) (bury-buffer
(get-buffer "*Completions*"))))
* (let ((swin (selected-window))) (when (and (window-minibuffer-p swin) (fboundp
(quote minibuffer-selected-window))) (setq swin (minibuffer-selected-window)))
(cond ((and (get-buffer-window "*Completions*") (or force (and (window-live-p
swin) (not (eq ... ...))) (interactive-p))) (condition-case nil (delete-window
(get-buffer-window "*Completions*")) (error nil)) (bury-buffer (get-buffer
"*Completions*"))) ((and (get-buffer-window "*Completions*" (quote visible)) (or
force (and (window-live-p swin) (not (eq ... ...))) (interactive-p))) (when
(window-dedicated-p (get-buffer-window "*Completions*" (quote visible)))
(condition-case nil (icicle-delete-windows-on "*Completions*") (error nil)))
(bury-buffer (get-buffer "*Completions*")))))
* icicle-remove-Completions-window(FORCE)
* (if (not (active-minibuffer-window)) (when (get-buffer "*Completions*")
(kill-buffer (get-buffer "*Completions*"))) (icicle-remove-Completions-window
(quote FORCE)))
  icicle-abort-recursive-edit()
  call-interactively(icicle-abort-recursive-edit nil nil)

Thx - Drew






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-26 14:56                                                           ` Drew Adams
       [not found]                                                             ` <0721F495F4A441529FCB91280D284E42@us.oracle.com! >
@ 2011-06-26 15:15                                                             ` Drew Adams
  2011-06-26 15:54                                                               ` martin rudalics
  1 sibling, 1 reply; 42+ messages in thread
From: Drew Adams @ 2011-06-26 15:15 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> What is happening now is that the first `C-g' does not remove 
> Completions (e.g. delete the frame) - a second `C-g' is needed.

And sometimes a second C-g does nothing either.
And sometimes C-g replaces buffer *Completions* in its frame with another buffer
(e.g. *scratch*), leaving the frame there.

I don't have a recipe to reproduce these latter symptoms.  But perhaps this is
all due to the window not being dedicated.






^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-26 15:15                                                             ` Drew Adams
@ 2011-06-26 15:54                                                               ` martin rudalics
  2011-06-26 16:06                                                                 ` Drew Adams
  0 siblings, 1 reply; 42+ messages in thread
From: martin rudalics @ 2011-06-26 15:54 UTC (permalink / raw)
  To: Drew Adams; +Cc: 8856

 > I don't have a recipe to reproduce these latter symptoms.  But perhaps this is
 > all due to the window not being dedicated.

The window was dedicated initially but due to another `display-buffer'
call "reusing it" it became undedicated again.

Please use the `display-buffer-in-window' function below which doesn't
reset the status when the buffer remains unchanged.

martin


(defun display-buffer-in-window (buffer window specifiers)
   "Display BUFFER in WINDOW and raise its frame if needed.
WINDOW must be a live window and defaults to the selected one.
Return WINDOW.

SPECIFIERS must be a list of buffer display specifiers, see the
documentation of `display-buffer-alist' for a description."
   (setq buffer (normalize-live-buffer buffer))
   (setq window (normalize-live-window window))
   (let* ((old-frame (selected-frame))
	 (new-frame (window-frame window))
	 (dedicated (cdr (assq 'dedicated specifiers)))
	 (no-other-window (cdr (assq 'no-other-window specifiers))))
     ;; Show BUFFER in WINDOW.
     (unless (eq buffer (window-buffer window))
       ;; If we show another buffer in window, undedicate it first.
       (set-window-dedicated-p window nil))
     (set-window-buffer window buffer)
     (when dedicated
       (set-window-dedicated-p window dedicated))
     (when no-other-window
       (set-window-parameter window 'no-other-window t))
     (unless (or (eq old-frame new-frame)
		(not (frame-visible-p new-frame))
		;; Assume the selected frame is already visible enough.
		(eq new-frame (selected-frame))
		;; Assume the frame from which we invoked the minibuffer
		;; is visible.
		(and (minibuffer-window-active-p (selected-window))
		     (eq new-frame
			 (window-frame (minibuffer-selected-window)))))
       (raise-frame new-frame))
     ;; Return window.
     window))





^ permalink raw reply	[flat|nested] 42+ messages in thread

* bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated
  2011-06-26 15:54                                                               ` martin rudalics
@ 2011-06-26 16:06                                                                 ` Drew Adams
  0 siblings, 0 replies; 42+ messages in thread
From: Drew Adams @ 2011-06-26 16:06 UTC (permalink / raw)
  To: 'martin rudalics'; +Cc: 8856

> The window was dedicated initially but due to another `display-buffer'
> call "reusing it" it became undedicated again.
> 
> Please use the `display-buffer-in-window' function below which doesn't
> reset the status when the buffer remains unchanged.

Yes, that fixes the problem.
I see no more problems for the moment.
Thanks for your help and your work in general.

Please close this bug, if you like.
I will open another if I find other problems.
Looking forward to having these fixes in the next build, hopefully.

 - Drew






^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2011-06-26 16:06 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-13 16:08 bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated Drew Adams
2011-06-13 18:00 ` martin rudalics
2011-06-13 18:41   ` Drew Adams
2011-06-14  9:15     ` martin rudalics
2011-06-14 20:36       ` Drew Adams
     [not found]         ` <4DFB6BBF.3080504@gmx.at>
2011-06-17 15:51           ` Drew Adams
2011-06-17 16:22             ` bug#8856: " martin rudalics
2011-06-17 17:48               ` Drew Adams
2011-06-19 17:29                 ` Drew Adams
2011-06-20  3:04                   ` Stefan Monnier
2011-06-17 17:48             ` bug#8856: " Drew Adams
2011-06-19 13:26               ` martin rudalics
2011-06-19 14:31                 ` bug#8856: 24.0.50;regression: `special-display-frame' broken Drew Adams
2011-06-19 18:50                   ` Chong Yidong
2011-06-19 18:54                     ` Drew Adams
     [not found]               ` <4DFE09A7.10500@gmx.at>
2011-06-19 14:43                 ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated Drew Adams
2011-06-19 17:26                   ` Drew Adams
2011-06-19 18:40                     ` martin rudalics
2011-06-19 19:34                       ` bug#8856: 24.0.50; regression: `special-display-popup-frame' broken Drew Adams
2011-06-19 19:52                         ` Drew Adams
2011-06-20  9:46                     ` bug#8856: 24.0.50; regression: special-display-frame is no longer dedicated martin rudalics
2011-06-20 13:01                       ` Drew Adams
     [not found]                         ` <4E00C54C.5080108@gmx.at>
2011-06-21 18:10                           ` Drew Adams
2011-06-22  0:13                             ` Drew Adams
2011-06-22  0:14                             ` Drew Adams
2011-06-22  0:15                             ` Drew Adams
2011-06-23 16:45                               ` Drew Adams
     [not found]                               ` <4E033CBA.1050700@gmx.at>
     [not found]                                 ` <DB9EDF1C454F42A0BC437F0E0AEE6CA2@us.oracle.com>
     [not found]                                   ` <4E037708.2000205@gmx.at>
2011-06-23 22:06                                     ` Drew Adams
2011-06-24  8:53                                       ` martin rudalics
2011-06-24 21:21                                         ` Drew Adams
2011-06-25 14:15                                           ` martin rudalics
2011-06-25 14:52                                             ` Drew Adams
     [not found]                                               ` <8A3D5626004B4 945A624B69463A0B849@us.oracle.com>
2011-06-25 15:04                                               ` Drew Adams
2011-06-25 15:57                                                 ` martin rudalics
2011-06-25 16:15                                                   ` Drew Adams
2011-06-25 17:00                                                     ` martin rudalics
2011-06-25 17:48                                                       ` Drew Adams
2011-06-26 13:50                                                         ` martin rudalics
2011-06-26 14:56                                                           ` Drew Adams
     [not found]                                                             ` <0721F495F4A441529FCB91280D284E42@us.oracle.com! >
2011-06-26 15:15                                                             ` Drew Adams
2011-06-26 15:54                                                               ` martin rudalics
2011-06-26 16:06                                                                 ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).