From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Redundant font-locking in comint buffers Date: 28 May 2004 19:14:04 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1085808923 529 80.91.224.253 (29 May 2004 05:35:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 29 May 2004 05:35:23 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat May 29 07:35:19 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BTwV5-0000hC-00 for ; Sat, 29 May 2004 07:35:19 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BTwV4-000413-00 for ; Sat, 29 May 2004 07:35:18 +0200 Original-Received: from [127.0.0.1] (helo=mailman.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BTwV8-0002Sj-V6 for emacs-devel@quimby.gnus.org; Sat, 29 May 2004 01:35:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BTwUz-0002SU-JN for emacs-devel@gnu.org; Sat, 29 May 2004 01:35:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BTwUy-0002SI-Rh for emacs-devel@gnu.org; Sat, 29 May 2004 01:35:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BTwUy-0002SF-IA for emacs-devel@gnu.org; Sat, 29 May 2004 01:35:12 -0400 Original-Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BTw5o-0001tS-Pe for emacs-devel@gnu.org; Sat, 29 May 2004 01:09:13 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by mx20.gnu.org with esmtp (Exim 4.34) id 1BTqYI-00012l-CZ for emacs-devel@gnu.org; Fri, 28 May 2004 19:14:15 -0400 Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 3E61DB302C6; Fri, 28 May 2004 19:14:04 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 304F88CA23; Fri, 28 May 2004 19:14:04 -0400 (EDT) Original-To: emacs-devel@gnu.org Original-Lines: 74 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=0, requis 5) X-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24136 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24136 Text in comint buffers (especially prompts and input text) tends to be re-fontified excessively because comint adds/removes text-properties on them frequently, which is always considered as a buffer-modification and thus triggers font-lock. This is generally a minor issue of performance, especially with jit-lock which delays the font-locking until display, thus bundling most of the redundant re-fontification into a single one. But if you use compilation-shell-minor-mode, then the redundant fontification becomes more noticeable because jit-lock is turned off and because font-lock does more work. So I suggest the patch below which wraps all the text-property manipulation inside `inhibit-modification-hooks' to make sure font-lock will not be unnecessarily triggered. Any objection? Stefan --- orig/lisp/comint.el +++ mod/lisp/comint.el @@ -1482,7 +1482,8 @@ (concat input "\n"))) (let ((beg (marker-position pmark)) - (end (if no-newline (point) (1- (point))))) + (end (if no-newline (point) (1- (point)))) + (inhibit-modification-hooks t)) (when (> end beg) ;; Set text-properties for the input field (add-text-properties @@ -1578,7 +1576,8 @@ freeze its attributes in place, even when more input comes a long and moves the prompt overlay." (when comint-last-prompt-overlay - (let ((inhibit-read-only t)) + (let ((inhibit-read-only t) + (inhibit-modification-hooks t)) (add-text-properties (overlay-start comint-last-prompt-overlay) (overlay-end comint-last-prompt-overlay) (overlay-properties comint-last-prompt-overlay))))) @@ -1709,7 +1708,8 @@ (goto-char (process-mark process)) ; in case a filter moved it (unless comint-use-prompt-regexp-instead-of-fields - (let ((inhibit-read-only t)) + (let ((inhibit-read-only t) + (inhibit-modification-hooks t)) (add-text-properties comint-last-output-start (point) '(rear-nonsticky t field output @@ -1718,7 +1718,8 @@ ;; Highlight the prompt, where we define `prompt' to mean ;; the most recent output that doesn't end with a newline. (let ((prompt-start (save-excursion (forward-line 0) (point))) - (inhibit-read-only t)) + (inhibit-read-only t) + (inhibit-modification-hooks t)) (when comint-prompt-read-only (or (= (point-min) prompt-start) (get-text-property (1- prompt-start) 'read-only) @@ -2347,7 +2354,8 @@ If the character after point does not have a front-sticky read-only property, any read-only property of `fence' on the preceding newline is removed." - (let* ((pt (point)) (lst (get-text-property pt 'front-sticky))) + (let* ((pt (point)) (lst (get-text-property pt 'front-sticky)) + (inhibit-modification-hooks t)) (and (bolp) (not (bobp)) (if (and (get-text-property pt 'read-only)