emacs - with-current-buffer does not move point - Stack Overflow
source link: https://stackoverflow.com/questions/14720962/with-current-buffer-does-not-move-point/14721382#14721382
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
with-current-buffer does not move point
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
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?
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 thatwindow 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).
You might have to use switch-to-buffer
and then switch back.
Try doing:
(set-buffer "foo")
(goto-char (point-max))
Your Answer
Post as a guest
Required, but never shown
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 emacs elisp or ask your own question.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK