23

emacs - with-current-buffer does not move point - Stack Overflow

 4 years ago
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.

Asked 7 years, 10 months ago
Viewed 1k times

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?

share | |
asked Feb 6 '13 at 3:26

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).

share | |
answered Feb 6 '13 at 4:10

You might have to use switch-to-buffer and then switch back.

share | |
answered Feb 6 '13 at 4:05

Try doing:

(set-buffer "foo")
(goto-char (point-max))
share | |
answered Feb 6 '13 at 3:30

Your Answer

Sign up or log in

Sign up using Google
Sign up using Facebook
Sign up using Email and Password

Post as a guest

Name
Email

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK