From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.bugs Subject: bug#13182: [PATCH] long delays in python-mode buffer parsing Date: Fri, 14 Dec 2012 22:44:19 -0800 Message-ID: <50CC1C43.8060809@dancol.org> References: <50CB102C.6020306@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2D80B6B641AD3271BA7F42F1" X-Trace: ger.gmane.org 1355553914 27295 80.91.229.3 (15 Dec 2012 06:45:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Dec 2012 06:45:14 +0000 (UTC) To: 13182@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 15 07:45:28 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TjlUt-0008Bl-Ha for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Dec 2012 07:45:19 +0100 Original-Received: from localhost ([::1]:57304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjlUg-0007jc-G5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Dec 2012 01:45:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjlUd-0007hn-6S for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 01:45:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjlUb-00040z-Mj for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 01:45:03 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjlUb-000405-Iu for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 01:45:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TjlVa-00032V-Hf for bug-gnu-emacs@gnu.org; Sat, 15 Dec 2012 01:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Colascione Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Dec 2012 06:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13182 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13182-submit@debbugs.gnu.org id=B13182.135555392911639 (code B ref 13182); Sat, 15 Dec 2012 06:46:02 +0000 Original-Received: (at 13182) by debbugs.gnu.org; 15 Dec 2012 06:45:29 +0000 Original-Received: from localhost ([127.0.0.1]:43283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjlV3-00031f-5T for submit@debbugs.gnu.org; Sat, 15 Dec 2012 01:45:29 -0500 Original-Received: from dancol.org ([96.126.100.184]:58125) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjlUz-00031X-Pb for 13182@debbugs.gnu.org; Sat, 15 Dec 2012 01:45:27 -0500 Original-Received: from c-76-22-66-162.hsd1.wa.comcast.net ([76.22.66.162] helo=[0.0.0.0]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1TjlTy-0007Vo-Ti for 13182@debbugs.gnu.org; Fri, 14 Dec 2012 22:44:22 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: <50CB102C.6020306@dancol.org> X-Enigmail-Version: 1.4.6 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:68537 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2D80B6B641AD3271BA7F42F1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 12/14/2012 3:40 AM, Daniel Colascione wrote: > Some python-mode operations slow down noticeably when the region being = edited > contains an unclosed bracket or string: these constructs lead to python= -mode > scanning the entire remainder of the buffer, and this scan appears to t= ake time > O(nr_lines^2). When which-func mode is enabled, this slowness renders E= macs > unusable, since we'll call python-info-current-defun frequently in orde= r to > update the modeline, and this function will take several seconds to com= plete. >=20 > The following patch appears to remedy the problem without breaking anyt= hig. Here's a bugfixed patch. Review would be appreciated. =3D=3D=3D modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-10 18:33:59 +0000 +++ lisp/ChangeLog 2012-12-15 06:38:59 +0000 @@ -1,3 +1,12 @@ +2012-12-15 Daniel Colascione + + * progmodes/python.el (python-nav-end-of-statement): Don't loop forever= =2E + +2012-12-14 Daniel Colascione + + * progmodes/python.el (python-nav-end-of-statement): Rewrite in + order to improve efficiency. + 2012-12-10 Jambunathan K * hi-lock.el: Refine the choice of default face. =3D=3D=3D modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2012-11-27 03:10:32 +0000 +++ lisp/progmodes/python.el 2012-12-15 06:28:38 +0000 @@ -1184,13 +1184,23 @@ (defun python-nav-end-of-statement () "Move to end of current statement." (interactive "^") - (while (and (goto-char (line-end-position)) - (not (eobp)) - (when (or - (python-info-line-ends-backslash-p) - (python-syntax-context 'string) - (python-syntax-context 'paren)) - (forward-line 1)))) + + (let (string-start bs-pos) + (while (and (goto-char (line-end-position)) + (not (eobp)) + (cond ((setq string-start (python-syntax-context 'string= )) + (goto-char string-start) + (let (forward-sexp-function) + (forward-sexp))) + ((python-syntax-context 'paren) + ;; The statement won't end before we've escaped + ;; at least one level of parenthesis. + (condition-case err + (goto-char (scan-lists (point) 1 -1)) + (scan-error (goto-char (nth 3 err))))) + ((setq bs-pos (python-info-line-ends-backslash-p))= + (goto-char bs-pos) + (forward-line 1)))))) (point-marker)) (defun python-nav-backward-statement (&optional arg) --------------enig2D80B6B641AD3271BA7F42F1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Cygwin) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlDMHEMACgkQ17c2LVA10VszJQCdEQV4YgdWWADkU8PJ7HvFKKlj V+8AoMbfLY7CXNsWNbVcOu+RF4mOOq+9 =X1VL -----END PGP SIGNATURE----- --------------enig2D80B6B641AD3271BA7F42F1--