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 03:40:28 -0800 Message-ID: <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="------------enig387F8FE4CC0F41E7B2CCFF17" X-Trace: ger.gmane.org 1355485270 23439 80.91.229.3 (14 Dec 2012 11:41:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Dec 2012 11:41:10 +0000 (UTC) To: 13182@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 14 12:41:24 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 1TjTds-0000sj-5r for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Dec 2012 12:41:24 +0100 Original-Received: from localhost ([::1]:58723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTde-0000sO-Lr for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Dec 2012 06:41:10 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTdb-0000sG-4v for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:41:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjTdZ-0000mc-Sf for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:41:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTdZ-0000mV-Oy for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:41:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TjTeU-0006db-OS for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:42: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: Fri, 14 Dec 2012 11:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13182 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.135548531225495 (code B ref -1); Fri, 14 Dec 2012 11:42:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Dec 2012 11:41:52 +0000 Original-Received: from localhost ([127.0.0.1]:42007 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjTeK-0006dA-I6 for submit@debbugs.gnu.org; Fri, 14 Dec 2012 06:41:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37412) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjTeH-0006d2-0s for submit@debbugs.gnu.org; Fri, 14 Dec 2012 06:41:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjTdK-0000kJ-Iu for submit@debbugs.gnu.org; Fri, 14 Dec 2012 06:40:51 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:40053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTdK-0000kF-BQ for submit@debbugs.gnu.org; Fri, 14 Dec 2012 06:40:50 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTdF-0000rH-7a for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:40:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjTdB-0000i2-PA for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:40:45 -0500 Original-Received: from dancol.org ([96.126.100.184]:48014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjTdB-0000hJ-JZ for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 06:40:41 -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 1TjTd4-0002bx-4M for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2012 03:40:34 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 X-Enigmail-Version: 1.4.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:68509 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig387F8FE4CC0F41E7B2CCFF17 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Some python-mode operations slow down noticeably when the region being ed= ited contains an unclosed bracket or string: these constructs lead to python-m= ode scanning the entire remainder of the buffer, and this scan appears to tak= e time O(nr_lines^2). When which-func mode is enabled, this slowness renders Ema= cs unusable, since we'll call python-info-current-defun frequently in order = to update the modeline, and this function will take several seconds to compl= ete. The following patch appears to remedy the problem without breaking anythi= g. =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-14 11:28:58 +0000 @@ -1184,13 +1184,21 @@ (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) + (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)))))) (point-marker)) (defun python-nav-backward-statement (&optional arg) --------------enig387F8FE4CC0F41E7B2CCFF17 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/ iEYEARECAAYFAlDLEC8ACgkQ17c2LVA10Vs8BACguuokbFLMRVt0bK7J8/nVmkQC TOsAn3SqllZxdDCtY3VF+Sb2lJVwrosS =Oy7/ -----END PGP SIGNATURE----- --------------enig387F8FE4CC0F41E7B2CCFF17--