I'm editing a large (around 50k words) tex file in Emacs using AUCTeX and cursor movement is quite sluggish, especially when jumping by word. This isn't a problem in any other mode.

Edit: I did some (super-unscientific) profiling with elp.el, just moving around with

(defun movement-test ()
  (setq i 0)
  (while (< i 10000)
    (incf i)))

And the results are

  • 211 line .tex document: 36.1s
  • 5393 line .tex document: 47.7s
  • 1076 line .R file (for comparison): 32.2s

I think it might have something to do with preview-latex (which I don't use), is there any way to disable preview-latex?

Mac OS X 10.7.3, Emacs v24.0.94.1, AUCTeX/preview-latex v11.86

  • The preview mode is activated only on demand, as far as I know. – egreg Mar 25 '12 at 12:23
  • how about removing (load "preview-latex.el" nil t t) from your .emacs? – Rasmus Mar 25 '12 at 12:53
  • So you do not get this from small files? Is there something special about the big file, does it contain a large amount of some particular macros? Can you make a smaller test case? – N.N. Mar 25 '12 at 13:32
  • I don't have (load "preview-latex.el" nil t t) in my .emacs, preview-latex is loaded by default as far as I can tell because I installed AUCTeX through ELPA. I'll have a hack around and see if I can stop it loading by default. – Ben Mar 26 '12 at 0:19

preview-latex should not affect editing speed in a noticeable manner (it uses some hooks for moving in and out of previews, but those are not expensive). The most likely culprit is syntax highlighting or CEDET. Another possibility (if we are talking about the Emacs 24 development line which you apparently are using) is the setting of bidi-paragraph-direction which you might want to customize to left-to-right. Last time I checked, admittedly more than a year ago, it could seriously impact the redisplay speed of longer texts.

  • Thanks - setting bidi-paragraph-direction to nil seems to help. – Ben Jul 9 '12 at 23:40

Do you have a lot of equations in your document? I had a similar problem awhile back and the culprit was the rainbow-delimiters package. Emacs seemed to have trouble coloring the large number of braces I had in my LaTeX source. I switched to highlight-parenthesis, which only colors the braces that surround the cursor, and my lag went away.

  • No, I'm not using rainbow-delimiters. – Ben Mar 26 '12 at 0:05

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.