Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

with-current-buffer does not move point

Tags:

emacs

elisp

In Elisp this seemingly easy peace of code does not actually move the point.

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

AFAIK with-current-buffer should not restore the point in the target buffer. If not, then how do I manipulate point in a buffer?

like image 850
navgeet Avatar asked Feb 06 '13 03:02

navgeet


1 Answers

I think you're confusing the buffer's point with the window's point. If you want to move the cursor in some window showing "foo", you need to select that window while you do the goto-char, or else you need to use set-window-point.

In general a buffer has N+1 points (one is its own, and the N are for the N windows that display the buffer).

like image 132
Stefan Avatar answered Sep 22 '22 22:09

Stefan