joaotavora / autopair

Automagically pair braces and quotes in emacs like TextMate
208 stars 35 forks source link

limit the search area for a matching pair #30

Closed cpoile closed 10 years ago

cpoile commented 10 years ago

I have a 500k org file that I keep notes in, and if I try to insert a parenthesis near the beginning, autopair will freeze emacs for about 10 seconds while it looks for a matching paren in the rest of the document. So here is a new variable and condition that will limit the search space. It seems to work and doesn't break backward or forward search, at least as far as I can tell from a day of working with the patched version.

joaotavora commented 10 years ago

Can you provide your org file or try with the very latest version? There should be less forward-sexp calls and I suspect performance will have increased dramatically, without the need for the restriction you suggest.

joaotavora commented 10 years ago

I just tried the newest autopair with a 5 meg org file created with the following code:

(loop repeat 100000 do (insert "* TODO foo\n** ONGOING foobarbaz\n** DONE quux\n"))

The I inserted a closing paren at the end of the file. Back at the beginning of the file, it takes less than a second for autopair to realize that it should not pair that opening paren.

Removing the closing paren at the end of the file and opening again at the beginnin yields the desired autoparing.

Marking this as solved.

cpoile commented 10 years ago

Yep, looks like it's much improved, thank you kindly.