Subject: bug#20100: closed (Re: bug#20100: 24.4.91; Can't scroll a window while in minibuffer)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 14 Mar 2015 08:18:02 +0000

Your bug report

#20100: 24.4.91; Can't scroll a window while in minibuffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
20100: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20100
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#20100: 24.4.91; Can't scroll a window while in minibuffer
From: martin rudalics <[email-masked]>
To: Oleh Krehel <[email-masked]>
Cc: [email-masked]
Date: Sat, 14 Mar 2015 09:17:04 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

 > Thanks, using `with-selected-window' instead of `with-current-buffer'
 > solved it. I thought that they should be equivalent. Apparently they are not.

It's a trap.  Commands that implicitly work on the selected window
should not be used programmatically.  Such commands are `recenter',
`enlarge-window', `shrink-window', `split-window-below' and
`split-window-right'.  When used in applications the only way to make
them behave is to wrap them in `with-selected-window' :-(

There are also more specialized commands like `recenter-top-bottom' or
`move-to-window-line-top-bottom' whose doc-strings don't explain what
they do.  Never use them in programs!

martin, closing this bug

Subject: 24.4.91; Can't scroll a window while in minibuffer
From: Oleh Krehel <[email-masked]>
To: [email-masked]
Date: Fri, 13 Mar 2015 13:51:36 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

I'm trying to write a completion package using `read-from-minibuffer'
combined with `post-command-hook'.

Everything is working OK, except when I want to sync the current
completion candidate (one of buffer's lines) with the corresponding line
in the buffer.

This code, specifically `recenter', doesn't work:

(with-current-buffer buf
  (goto-char (point-min))
  (forward-line (1- num))
  (recenter))

However, this code will scroll the window (`buf' and `wnd' correspond to
each other):

(with-current-buffer buf
  (goto-char (point-min))
  (forward-line (1- num))
  (setf (window-point wnd)
        (point)))

Still, it's not a perfect solution, since even after setting
`window-point', (window-start wnd) and (window-end wnd t) will not
return the correct thing.

I'm pretty sure it's a bug and the code above should work as is, but I'd
also appreciate pointers for achieving the scrolling and window bounds
re-calculation for the current Emacs.

regards,
Oleh