autopair slow with quotes in media-large python files. #38

Closed
erikcw opened this Issue Feb 28, 2014 · 4 comments

Projects

None yet

2 participants

@erikcw

I have a rather large python file (~ 5000 lines consisting of Django models). autopair crawls when trying to insert new quotes. The UI freezes for 10-15 seconds and then inserts the pair of quotes.

The closer to the top of the file I am, the longer the the UI blocks. At the bottom of the file, their is no perceptible delay.

I'm not familiar with the autopair source -- but it seems as if it may be scanning to the end of the file before inserting new quotes. Might be related to issue #36.

It only seems to happen with quotes (" and ') -- parens, braces, etc work just fine.

@joaotavora
@joaotavora
@erikcw

Yes, I'm using the github tip (4d53ffe) as my autopair version. I'm running emacs 24.3 on OSX 10.9.

The file I'm working on is non-free -- so I whipped up a sample file full of duplicate models. I stuck a bunch of docstrings in to get lots of quotes. The delay is only a few seconds on this file despite it being twice as long as the file I originally spotted the problem in. The original file has docstrings for every method, plus quotes used for dictionaries, strings, etc. I'm guessing as more quotes are added, autopair slows down....

https://gist.github.com/erikcw/9277837

@joaotavora
Owner

Thanks for the file. I still haven't had time to look at this, so please bear with me. If you're fed up waiting, and you're into it, the command

brew install emacs --cocoa --HEAD --with-gnutls --use-git-head --srgb

will install the (very stable now) trunk of upcoming Emacs 24.4. In that version, you have electric-pair-mode which I wrote to completely replace autopair.el. It works almost exactly like autopair, which I plan to deprecate in favor of electric-pair-mode

@joaotavora joaotavora added the bug label Mar 9, 2014
@joaotavora joaotavora added a commit that closed this issue Mar 11, 2014
@joaotavora Closes #38: decide faster in large files with many quotes
* autopair.el (autopair-insert-or-skip-quote): Simplify.
(autopair--in-unterminated-string-p): Also look for cases where
we're inside an unterminated string started by a generic string
delimiter.
029bdf0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment