4

I'll describe what I'm doing currently to get an issue. First, I store the current buffer.

M-: eval-expression

(setq bb (current-buffer))

Then, M-:

(with-current-buffer bb
  (insert "foo"))

While still in minibuffer, C-e, C-x C-e. I get the expected result: foo is inserted in the buffer bb.

However, if I change the expression to

(with-current-buffer bb
  (goto-char (point-min)))

After C-x C-e I get the result 1, but the point doesn't move. It would seem that scrolling is disabled while in minibuffer. How can I enable it?

  • Interesting problem. What's more interesting is that if you eval (with-current-buffer (other-buffer) (goto-char (point-max))) with C-x C-e then the point will move. – nanny Mar 12 '15 at 16:37
  • @nanny, doesn't work on 24.4.91 – abo-abo Mar 12 '15 at 16:39
  • I just double- and triple-checked, it definitely works for me on 24.4.1 (Cygwin). Process: run emacs -Q, open two files, hit M-:, type the elisp in my above comment (alternating point-min and point-max), hit C-x C-e, then quit eval with C-g, and the point is at the other side of other-buffer. – nanny Mar 12 '15 at 17:07
  • It might be a version issue. Although I want the scroll to happen before C-g. – abo-abo Mar 12 '15 at 17:19
  • I think this is happening because you're changing the point during recursive edit. I'm not sure how to avoid it. Try messing with window-point. – Malabarba Mar 12 '15 at 19:51
3

I think this is happening because you're changing the point during recursive edit. I'm not sure how to avoid this situation in general, but here, instead of goto-char you can set window-point:

(setf (window-point (get-buffer-window bb)) (point-min))
| improve this answer | |
  • I'm in read-from-minibuffer, trying to scroll the window from post-command-hook. While window-point can be updated, window-start and window-end still won't re-compute. – abo-abo Mar 13 '15 at 7:08
2

The problem is solved by using with-selected-window instead of with-current-buffer. I thought that they would be equivalent in this case, but they're not.

| improve this answer | |
1

You're probably after this info: (elisp) Window Point

Each window has its own value of point (*note Point::), independent of the value of point in other windows displaying the same buffer. This makes it useful to have multiple windows showing one buffer.

...

  • As long as the selected window displays the current buffer, the window's point and the buffer's point always move together; they remain equal.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.