C-current-buffer does not move point

In Elisp, this seemingly light world of code does not actually move the point.

(with-current-buffer "foo"
  (goto-char (point-max)))

AFAIK with-current-buffershould not restore a point in the destination buffer. If not, how do I manipulate a point in the buffer?

+5
source share
3 answers

I think you are mixing a buffer point with a window point. If you want to move the cursor to some window with the image "foo", you need to select thiswindow when you execute goto-char, or you need to use set-window-point. In the general case, the buffer has N + 1 points (one is its own, and N is for N windows displaying the buffer).

+6
source

You may need to use switch-to-bufferand then go back.

+1

:

(set-buffer "foo")
(goto-char (point-max))
0

All Articles