6

I am using the term of Emacs to compile some code, with linum-mode enabled to display the line numbers for the terminal, and the line numbers stop increasing as soon as they reach 2049.

If I write source code and I reach 2049 lines will this happen too? Why is that happening? Shouldn't the numbers keep increasing?

  • Because I am new to Emacs I will try to answer to you as well as I can. I used C-x 3 to split the window and then I opened term with M-x term. When compiling the numbers stop increasing in 2049 meaning that all lines would have sometimes the number 2048 and sometimes 2049. Never less never more. At the end of the compilation procedure there would always be 2049. – Adam Oct 28 '14 at 2:55
12

Like most terminals, Emacs' term has a scrollback limit -- which will naturally mess with the consistency of linum's counting, as lines will be deleted from the beginning of the buffer.

The term-buffer-maximum-size variable controls this, and sure enough it has a default value of 2048.

So linum was telling you the truth: the terminal buffer was never more than 2049 lines long at any time.

If you customize this variable1 and set the default value to zero, Emacs will not delete lines in this way, so linum will remain accurate. Of course without this protection, a runaway -- or intentional -- process outputting vast amounts of data into the terminal may cause Emacs to eat up large amounts of memory.

Failing that, I'd say don't use linum and term together.

1 Start here: C-hv term-buffer-maximum-size

  • Yes the size is 2048! So you think that the best solution is to use my terminal and not the one in Emacs? You mean that all the terminals erase lines and we just not noticing it as they don't use line numbers? – Adam Oct 28 '14 at 3:31
  • There's nothing wrong with using Emacs' terminal (I certainly make heavy use of it). But yes, for obvious reasons I think you'll find that all terminals will default to imposing a limit on the number of lines they'll retain. Basically your problem is that linum-mode is not intended for use in buffers which are subject to this sort of modification, as all it's doing is counting and numbering the lines of current content in the buffer -- it knows nothing at all about old/deleted content. – phils Oct 28 '14 at 3:49

Your Answer

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 or ask your own question.