From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#25122: 24.5; function describe-variable hangs on large variables Date: Mon, 13 Mar 2017 00:47:38 -0400 Message-ID: <87lgs97pg5.fsf@users.sourceforge.net> References: <20161206022112.GF25778@E15-2016.optimum.net> <87twahk19y.fsf@gmail.com> <87d1h4fld5.fsf@users.sourceforge.net> <871sxkyv2m.fsf@gmail.com> <87mvcs8j7w.fsf@users.sourceforge.net> <87lgsbtxwe.fsf@gmail.com> <871su38ogm.fsf@users.sourceforge.net> <87d1dnrq96.fsf@gmail.com> <87wpbu7f9i.fsf@users.sourceforge.net> <87r32278wf.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1489380439 32272 195.159.176.226 (13 Mar 2017 04:47:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 13 Mar 2017 04:47:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 25122@debbugs.gnu.org, Stefan Monnier , Boruch Baum To: Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 13 05:47:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnHt1-0007AC-Kl for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Mar 2017 05:47:11 +0100 Original-Received: from localhost ([::1]:50115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnHt4-00060H-8U for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Mar 2017 00:47:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnHsw-0005xw-FD for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 00:47:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnHss-00053D-Gs for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 00:47:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnHss-000533-D4 for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 00:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cnHss-0001nw-5n for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 00:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Mar 2017 04:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25122 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25122-submit@debbugs.gnu.org id=B25122.14893803906892 (code B ref 25122); Mon, 13 Mar 2017 04:47:02 +0000 Original-Received: (at 25122) by debbugs.gnu.org; 13 Mar 2017 04:46:30 +0000 Original-Received: from localhost ([127.0.0.1]:53129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnHsM-0001n0-6V for submit@debbugs.gnu.org; Mon, 13 Mar 2017 00:46:30 -0400 Original-Received: from mail-it0-f43.google.com ([209.85.214.43]:37445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnHsJ-0001mg-M6; Mon, 13 Mar 2017 00:46:28 -0400 Original-Received: by mail-it0-f43.google.com with SMTP id g138so25236000itb.0; Sun, 12 Mar 2017 21:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=+HVfNan0vzQbhsFpVI3DS0tkNCwHH97eXeXRsVbcBjo=; b=UMY3uVeUNDTxRdi96i2yfH4q5h/D3IQ484RDHqw1DV4ksKrxqvreNjtECcGYj142Np nGyXxMm2Jpw0KIlkJzYFEi+zIfPdIy2HR6HPfigAE10BUKhx8I1ArHbj4an+pnNTOlXg jearI/37Rsa/alLW/FbqUgipgqTkpfjMIgml7i9fm1XGyCsdIVY6Z0MSIs+Oc8PAS3+w 7eigdt7alR4kw7zV9ik7K87Co9lzqQlQbtC99Mh0fpQ8DgK2r16EFy4RmtwrlqXn/Mfp 9QqBucgg+WQuIL3jXnm5mkI/QPs/Yj0u6Wj9jAPSQdp3YALlJ4mkMoGEt53OK4MrXrUy 0zvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=+HVfNan0vzQbhsFpVI3DS0tkNCwHH97eXeXRsVbcBjo=; b=ZUfrUTyAjt21TtuMJH3LlolP5XMwjccEf5Wjkg/PABbuNmnf3nZr3keKO5qpdSEJKX 87MPQxxvE9F5sP6kp7Rv8ChSO+BVK+KaMUoiaMgyRcPxLj+v8/qKaZ2w2u1Mk4zHNogF CC1lWzG0WF9mo75/rmyfhrr0UuFyxUy7KKnBB88P6zOT0dJT9ljx0sTQm2wI4BkLqrjC uPb+Tmnlw4jw5eVVuaNywfHXQr8g9dfesJv6iV5Os20MFJqMGwIATDOK5JMSKJ3/yzQd ErQYYU1Rvr4ejq15x2IPW4pOJUWQz2Gno36kGAM6OJ/68iI5klsmTlUQBaO6d8/wzOtn i8hg== X-Gm-Message-State: AFeK/H3d87TE8551ojJet+4S4hGDfh0WO1KWmsvoXP3CiUAjC4Z3ZaZuoou3OoGw/f+dwA== X-Received: by 10.36.153.197 with SMTP id a188mr9297425ite.5.1489380382055; Sun, 12 Mar 2017 21:46:22 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id 62sm3744204itl.1.2017.03.12.21.46.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Mar 2017 21:46:21 -0700 (PDT) In-Reply-To: <87r32278wf.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Sun, 12 Mar 2017 12:32:48 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:130532 Archived-At: --=-=-= Content-Type: text/plain tags 25122 patch quit npostavs@users.sourceforge.net writes: > Also, this doesn't really solve the performance problem, it just makes > it much less likely to occur, e.g., (pp (list load-history)) is still > slow. Okay, I think I found the real fix now: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Don-t-reparse-the-sexp-in-indent-sexp-Bug-25122.patch Content-Description: patch >From 5188d6e366426d83934505296b585744f50e24a5 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 12 Mar 2017 23:59:19 -0400 Subject: [PATCH] Don't reparse the sexp in indent-sexp (Bug#25122) * lisp/emacs-lisp/lisp-mode.el (calculate-lisp-indent): Let PARSE-START be a parse state that can be reused. (indent-sexp): Pass the running parse state to calculate-lisp-indent instead of the sexp beginning position. --- lisp/emacs-lisp/lisp-mode.el | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index eb07c18b03..8d4abc24e8 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -781,6 +781,10 @@ calculate-lisp-indent If the value is nil, that means don't change the indentation because the line starts inside a string. +PARSE-START may be a buffer position to start parsing from, or a +parse state as returned by calling `parse-partial-sexp' up to the +beginning of the current line. + The value can also be a list of the form (COLUMN CONTAINING-SEXP-START). This means that following lines at the same level of indentation should not necessarily be indented the same as this line. @@ -794,12 +798,14 @@ calculate-lisp-indent (desired-indent nil) (retry t) calculate-lisp-indent-last-sexp containing-sexp) - (if parse-start - (goto-char parse-start) - (beginning-of-defun)) - ;; Find outermost containing sexp - (while (< (point) indent-point) - (setq state (parse-partial-sexp (point) indent-point 0))) + (cond ((or (markerp parse-start) (integerp parse-start)) + (goto-char parse-start)) + ((null parse-start) (beginning-of-defun)) + (t (setq state parse-start))) + (unless state + ;; Find outermost containing sexp + (while (< (point) indent-point) + (setq state (parse-partial-sexp (point) indent-point 0)))) ;; Find innermost containing sexp (while (and retry state @@ -1070,11 +1076,6 @@ indent-sexp ENDPOS is encountered." (interactive) (let* ((indent-stack (list nil)) - ;; If ENDPOS is non-nil, use beginning of defun as STARTING-POINT. - ;; If ENDPOS is nil, it is safe not to scan before point - ;; since every line we indent is more deeply nested than point is. - (starting-point (save-excursion (if endpos (beginning-of-defun)) - (point))) ;; Use `syntax-ppss' to get initial state so we don't get ;; confused by starting inside a string. We don't use ;; `syntax-ppss' in the loop, because this is measurably @@ -1132,8 +1133,12 @@ indent-sexp (unless (or (eolp) (eq (char-syntax (char-after)) ?<)) (let ((this-indent (car indent-stack))) (when (listp this-indent) - (let ((val (calculate-lisp-indent - (or (car this-indent) starting-point)))) + ;; The state here is actually to the end of the + ;; previous line, but that's fine for our purposes. + ;; And continuing the parse to the next line would + ;; destroy element 2 (last sexp position) which + ;; `calculate-lisp-indent' needs. + (let ((val (calculate-lisp-indent state))) (setq this-indent (cond ((integerp val) -- 2.11.1 --=-=-=--