Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs - scroll automatically when inserting text

Tags:

emacs

elisp

This is driving me nuts and I've been on it all day.

I am trying to write a process filter for communicating with a serial device. That works OK, but when I insert text in to a buffer, I want the buffer to scroll so I can see the text, just like it does when you type text in to a buffer. I insert text into several buffers showing different information on the serial line. As it is, every time I issue a serial command I have to drag each scrollbar down so I can see the text.

Changing 'point' just changes the insertion point - the window scrolling doesn't follow. Attempts to call scrolling functions and 'recenter' seem to do nothing. How do I get the windows to scroll?

I'd also like to change the buffer so you can't type in to it, or change the position of 'point' by clicking in the window. Is there a mode that I should be using or something?

Many thanks if anyone can help,

David.

like image 566
David Wallis Avatar asked Nov 23 '12 13:11

David Wallis


1 Answers

I suspect your problem comes from the fact that point position is not attached to a buffer, but to the window displaying the buffer (since you can have different windows displaying the same buffer at different locations).

You could try something like this:

(with-selected-window (get-buffer-window YOUR-BUFFER)
  (goto-char (point-max)))
like image 173
François Févotte Avatar answered Sep 30 '22 05:09

François Févotte