Subject: Re: bug#3413: 23.0.94; ispell choices buffer display problem

From: martin rudalics <[email-masked]>
Date: Fri, 29 May 2009 16:43:25 +0200

> 1. emacs -Q
 > 2. Type `thre threee'
 > 3. Type `C-x 2' twice.  Now the frame has three windows stacked
 >    vertically, in the lowest window (window-height) returns 18, in each
 >    of the two upper windows (window-height) returns 9.
 > 4. Make either of the two upper windows the selected window, and in that
 >    window make the text typed in step 2 an "active region" (select with
 >    the mouse or type `C-a C-SPC C-e').
 > 5. Type `M-$'
 > => The selected window splits vertically, in the lower one of these,
 >    `thre' is highlighted, the upper window contains a two-line high
 >    *Choices* buffer displaying 10 corrections for `thre'.
 > 6. Type `SPC'
 > => In the lower window now `threee' is highlighted, the *Choices*
 >    buffer in the upper window displays one empty line, and is
 >    unscrollable.
 >
 > If at step 4 the window with (window-height) 18 is selected, then step 5
 > is the same, but in step 6, the *Choices* buffer is five lines high and
 > shows 28 alternatives for `threee'.

It's because of the obscure construct below from `ispell-command-loop'
which has max-lines equal 0 in the small window case and 11 in the large
window case.  So choices simply don't get inserted into the buffer in
the small window case.

(defun ispell-command-loop (miss guess word start end)
[...]
	;; ensure 4 context lines.
	(max-lines (- (ispell-adjusted-window-height) 4))
[...]
       (while (and choices
		  (< (if (> (+ 7 (current-column) (length (car choices))
			       (if (> count ?~) 3 0))
			    (window-width))
			 (progn
			   (insert "\n")
			   (setq line (1+ line)))
		       line)
		     max-lines))

I don't have the slightest idea what this is necessary for and suppose
that the calculations are off by one or two anyway.  Maybe the reason is
that choices buffers can't (or shouldn't) be scrolled.  You can try to
replace the binding by something like

	(max-lines (- (ispell-adjusted-window-height) (if guess 4 0)))

but this just slightly improves things.

martin