unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: divya@subvertising.org
Cc: monnier@iro.umontreal.ca, 74281@debbugs.gnu.org
Subject: bug#74281: 30.0.91; font-lock mode hangs on scrolling large Scheme file
Date: Sat, 28 Dec 2024 13:09:46 +0200	[thread overview]
Message-ID: <86msggt66d.fsf@gnu.org> (raw)
In-Reply-To: <8634iqwqtr.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Dec 2024 11:34:40 +0200)

Ping! Ping! Ping! Divya, please respond.

> Cc: monnier@iro.umontreal.ca, 74281@debbugs.gnu.org
> Date: Sat, 14 Dec 2024 11:34:40 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> Ping! Ping!  Divya, are you there?
> 
> > Cc: 74281@debbugs.gnu.org
> > Date: Sat, 30 Nov 2024 11:51:49 +0200
> > From: Eli Zaretskii <eliz@gnu.org>
> > 
> > Ping!  Divya, could you please try Stefan's suggestions and report
> > back?
> > 
> > > Cc: Divya Ranjan <divya@subvertising.org>, 74281@debbugs.gnu.org
> > > From: Stefan Monnier <monnier@iro.umontreal.ca>
> > > Date: Thu, 14 Nov 2024 11:56:37 -0500
> > > 
> > > > Stefan, what tools do we have to investigate slowness related to
> > > > parse-partial-sexp?  Or maybe you have suggestions for how to speed up
> > > > font-lock in this case?
> > > 
> > > Hmm... `parse-partial-sexp` is normally expected to be fast, unless it
> > > has to scan a lot of text.
> > > 
> > > > Here's the profile I get while moving with C-p through the above file:
> > > 
> > > A stab in the dark, but maybe the relevant call is the one in:
> > > 
> > >           (state (if (or syntax-ppss-table
> > >                          (not font-lock--syntax-table-affects-ppss))
> > >                      (syntax-ppss start)
> > >                    ;; If `syntax-ppss' doesn't have its own syntax-table and
> > >                    ;; we have installed our own syntax-table which
> > >                    ;; differs from the standard one in ways which affects PPSS,
> > >                    ;; then we can't use `syntax-ppss' since that would pollute
> > >                    ;; and be polluted by its cache.
> > >                    (parse-partial-sexp (point-min) start)))
> > > 
> > > so the origin of the slowdown would be the (?#. "w 14") in the setting
> > > below in `scheme.el`:
> > > 
> > >   (setq font-lock-defaults
> > >         '((scheme-font-lock-keywords
> > >            scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
> > >           nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14"))
> > >           beginning-of-defun
> > >           (font-lock-mark-block-function . mark-defun)))
> > > 
> > > in which case, setting a `syntax-ppss-table` should fix the problem, tho
> > > we could also fix it by being more careful: AFAICT the purpose of this
> > > (?#. "w 14") is only to change the syntax of `#` from "prefix" to "word"
> > > without changing the comment-related flags, so it shouldn't cause
> > > `font-lock--syntax-table-affects-ppss` to be set.
> > > So, we could solve it by improving the code that sets
> > > `font-lock--syntax-table-affects-ppss`, as in the patch below.
> > > 
> > > 
> > >         Stefan
> > > 
> > > 
> > > diff --git a/lisp/font-lock.el b/lisp/font-lock.el
> > > index 203131bfd5a..f6299920c0a 100644
> > > --- a/lisp/font-lock.el
> > > +++ b/lisp/font-lock.el
> > > @@ -1955,14 +1955,15 @@ font-lock-set-defaults
> > >  	    (dolist (char (if (numberp (car selem))
> > >  			      (list (car selem))
> > >  			    (mapcar #'identity (car selem))))
> > > -	      (unless (memq (car (aref font-lock-syntax-table char))
> > > -	                    '(1 2 3))    ;"." "w" "_"
> > > -	        (setq font-lock--syntax-table-affects-ppss t))
> > > -	      (modify-syntax-entry char syntax font-lock-syntax-table)
> > > -	      (unless (memq (car (aref font-lock-syntax-table char))
> > > -	                    '(1 2 3))    ;"." "w" "_"
> > > -	        (setq font-lock--syntax-table-affects-ppss t))
> > > -	      ))))
> > > +	      (let ((old-syntax (aref font-lock-syntax-table char)))
> > > +	        (modify-syntax-entry char syntax font-lock-syntax-table)
> > > +	        (let ((new-syntax (aref font-lock-syntax-table char)))
> > > +	          (unless (and (equal (cdr old-syntax) (cdr new-syntax))
> > > +	                       (memq (logand (car old-syntax) 255) '(1 2 3 6))
> > > +	                       (memq (logand (car new-syntax) 255) '(1 2 3 6))
> > > +	                       (equal (ash (car old-syntax) -8)
> > > +	                              (ash (car new-syntax) -8)))
> > > +	            (setq font-lock--syntax-table-affects-ppss t))))))))
> > >        ;; (nth 4 defaults) used to hold `font-lock-beginning-of-syntax-function',
> > >        ;; but that was removed in 25.1, so if it's a cons cell, we assume that
> > >        ;; it's part of the variable alist.
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> > 
> > 
> > 
> 
> 
> 
> 





  reply	other threads:[~2024-12-28 11:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-09 16:04 bug#74281: 30.0.91; font-lock mode hangs on scrolling large Scheme file Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14  8:44 ` Eli Zaretskii
2024-11-14  9:32   ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 10:06     ` Eli Zaretskii
2024-11-14 11:09       ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 11:42         ` Eli Zaretskii
2024-11-14 16:56   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30  9:51     ` Eli Zaretskii
2024-12-14  9:34       ` Eli Zaretskii
2024-12-28 11:09         ` Eli Zaretskii [this message]
2024-12-29 18:38           ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-28 15:03       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-28 16:33         ` Eli Zaretskii
2024-12-29 15:20           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-29 18:01             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-29 18:58               ` Eli Zaretskii
2024-12-29 20:01                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-30 12:47                   ` Eli Zaretskii
2024-12-29 18:43             ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-30  4:45               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-30  5:35                 ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-30 21:06                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-02 14:12                     ` divya--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86msggt66d.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=74281@debbugs.gnu.org \
    --cc=divya@subvertising.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).