From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: How can I predict which regions xdisp will present me for font-locking? Date: Mon, 12 Mar 2012 18:49:09 +0000 Message-ID: <20120312184909.GA2792@acm.acm> References: <20120311205903.GA3717@acm.acm> <83d38iyfox.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1331578239 21692 80.91.229.3 (12 Mar 2012 18:50:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 12 Mar 2012 18:50:39 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: John Yates Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 12 19:50:38 2012 Return-path: Envelope-to: ged-emacs-devel@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 1S7AKL-0004tE-EG for ged-emacs-devel@m.gmane.org; Mon, 12 Mar 2012 19:50:37 +0100 Original-Received: from localhost ([::1]:39408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AKK-0006n4-Tg for ged-emacs-devel@m.gmane.org; Mon, 12 Mar 2012 14:50:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AKC-0006lc-V4 for emacs-devel@gnu.org; Mon, 12 Mar 2012 14:50:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7AJs-0008Cr-Ox for emacs-devel@gnu.org; Mon, 12 Mar 2012 14:50:28 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:42342 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AJs-0008BT-En for emacs-devel@gnu.org; Mon, 12 Mar 2012 14:50:08 -0400 Original-Received: (qmail 99661 invoked by uid 3782); 12 Mar 2012 18:50:05 -0000 Original-Received: from acm.muc.de (pD9519EEC.dip.t-dialin.net [217.81.158.236]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 12 Mar 2012 19:50:03 +0100 Original-Received: (qmail 303 invoked by uid 1000); 12 Mar 2012 18:49:09 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148981 Archived-At: Hello again, John. On Mon, Mar 12, 2012 at 01:47:00PM -0400, John Yates wrote: > On Sun, Mar 11, 2012 at 5:45 PM, Eli Zaretskii wrote: > >> Date: Sun, 11 Mar 2012 20:59:03 +0000 [ .... ] > I am seeing a horrendous slowdown when editing atypical macros (though > no more than 50 lines long). Worse still I see the same slowdown when > editing a comment if even a fragment of my atypical macro is visible. What does horrendous mean? It could mean 10s per key (i.e. totally broken) or žs per key (very sluggish). Is the horrenditity any worse typing the comma? > The pattern of the macro is > #define LIST_NAME \ > _ROW_( ) \ > , _ROW_( ) \ > ... \ > , _ROW_( ) \ Here's an update to the latest current state of my optimisations. Try it out, please, and see if it make things any better. === modified file 'lisp/progmodes/cc-engine.el' *** lisp/progmodes/cc-engine.el 2012-03-02 22:16:21 +0000 --- lisp/progmodes/cc-engine.el 2012-03-12 18:32:00 +0000 *************** *** 1246,1252 **** (c-at-vsemi-p)))) (throw 'done vsemi-pos)) ;; In a string/comment? ! ((setq lit-range (c-literal-limits)) (goto-char (cdr lit-range))) ((eq (char-after) ?:) (forward-char) --- 1246,1252 ---- (c-at-vsemi-p)))) (throw 'done vsemi-pos)) ;; In a string/comment? ! ((setq lit-range (c-literal-limits from)) (goto-char (cdr lit-range))) ((eq (char-after) ?:) (forward-char) *************** *** 3250,3257 **** (if scan-forward-p (progn (narrow-to-region (point-min) here) (c-append-to-state-cache good-pos)) ! ! (c-get-cache-scan-pos good-pos)))) (t ; (eq strategy 'IN-LIT) (setq c-state-cache nil --- 3250,3256 ---- (if scan-forward-p (progn (narrow-to-region (point-min) here) (c-append-to-state-cache good-pos)) ! good-pos))) (t ; (eq strategy 'IN-LIT) (setq c-state-cache nil *************** *** 4563,4568 **** --- 4562,4599 ---- (point-min)) (t (c-determine-limit (- how-far-back count) base try-size)))))) + + (defun c-determine-+ve-limit (how-far &optional start-pos) + ;; Return a buffer position about HOW-FAR non-literal characters forward + ;; from START-POS (default point), which must not be inside a literal. + (save-excursion + (let ((pos (or start-pos (point))) + (count how-far) + (s (parse-partial-sexp (point) (point)))) ; null state + (while (and (not (eobp)) + (> count 0)) + ;; Scan over counted characters. + (setq s (parse-partial-sexp + pos + (min (+ pos count) (point-max)) + nil ; target-depth + nil ; stop-before + s ; state + 'syntax-table)) ; stop-comment + (setq count (- count (- (point) pos) 1) + pos (point)) + ;; Scan over literal characters. + (if (nth 8 s) + (setq s (parse-partial-sexp + pos + (point-max) + nil ; target-depth + nil ; stop-before + s ; state + 'syntax-table) ; stop-comment + pos (point)))) + (point)))) + ;; `c-find-decl-spots' and accompanying stuff. *************** *** 8635,8641 **** (setq pos (point))) (and c-macro-with-semi-re - (not (c-in-literal)) (eq (skip-chars-backward " \t") 0) ;; Check we've got nothing after this except comments and empty lines --- 8666,8671 ---- *************** *** 8666,8672 **** (c-backward-syntactic-ws) t)) (c-simple-skip-symbol-backward) ! (looking-at c-macro-with-semi-re))))) (defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el. --- 8696,8704 ---- (c-backward-syntactic-ws) t)) (c-simple-skip-symbol-backward) ! (looking-at c-macro-with-semi-re) ! (goto-char pos) ! (not (c-in-literal)))))) ; The most expensive check last. (defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el. *************** *** 9571,9577 **** ;; CASE 5B: After a function header but before the body (or ;; the ending semicolon if there's no body). ((save-excursion ! (when (setq placeholder (c-just-after-func-arglist-p lim)) (setq tmp-pos (point)))) (cond --- 9603,9610 ---- ;; CASE 5B: After a function header but before the body (or ;; the ending semicolon if there's no body). ((save-excursion ! (when (setq placeholder (c-just-after-func-arglist-p ! (max lim (c-determine-limit 500)))) (setq tmp-pos (point)))) (cond === modified file 'lisp/progmodes/cc-mode.el' *** lisp/progmodes/cc-mode.el 2012-02-22 19:34:32 +0000 --- lisp/progmodes/cc-mode.el 2012-03-12 18:31:49 +0000 *************** *** 925,932 **** ;; inside a string, comment, or macro. (setq new-bounds (c-extend-font-lock-region-for-macros c-new-BEG c-new-END old-len)) ! (setq c-new-BEG (car new-bounds) ! c-new-END (cdr new-bounds)) ;; Clear all old relevant properties. (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1)) (c-clear-char-property-with-value c-new-BEG c-new-END 'category 'c-cpp-delimiter) --- 925,932 ---- ;; inside a string, comment, or macro. (setq new-bounds (c-extend-font-lock-region-for-macros c-new-BEG c-new-END old-len)) ! (setq c-new-BEG (max (car new-bounds) (c-determine-limit 500 begg)) ! c-new-END (min (cdr new-bounds) (c-determine-+ve-limit 500 endd))) ;; Clear all old relevant properties. (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1)) (c-clear-char-property-with-value c-new-BEG c-new-END 'category 'c-cpp-delimiter) > /john -- Alan Mackenzie (Nuremberg, Germany).