unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Syntax Highlighting Latency in Emacs
@ 2004-12-12  1:42 jab3
  2004-12-12 13:13 ` Thien-Thi Nguyen
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: jab3 @ 2004-12-12  1:42 UTC (permalink / raw)


Hello -

I don't want to start a war or anything (because it probably has something
to do with my system), but I am curious about something I've noticed with
Emacs as compared with vim.  If I'm looking at a source code file in vim,
(and it doesn't even have to be that large - maybe a few thousand K) the
syntax highlighting is automatic.  And if I edit something, which changes
the highlighting of the rest of the file, it is instantaneous.  But in
Emacs, there is a 2 or 3 second delay in the updating of the highlighting. 
Is there a setting I'm missing somewhere?  (I'm new to Emacs, and I am
trying to move to it instead of vim for serious editing)  Has anyone else
noticed this?

My system is a P4 2Ghz with 256M RAM.


Thanks,
jab3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
@ 2004-12-12 13:13 ` Thien-Thi Nguyen
  2004-12-12 13:22 ` Peter Dyballa
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Thien-Thi Nguyen @ 2004-12-12 13:13 UTC (permalink / raw)


jab3 <manual@helpdesk.org> writes:

> My system is a P4 2Ghz with 256M RAM.

1/10th the clock frequency but i don't see a lag.
maybe my mind is the limiting rate, i don't want to nag.
though it's true that accessing files over miles is a drag,
they stay, once in core, w/ vars set just right, in the bag.

but what vars are just right to write in the init file?
does init mean restart mean context lost to the wild?
what's context but preference, a variation of style?
do programmers fall fashion victim, yet dress as a child?

well, emacs has always supported tweaks up the wazoo.
no desire once shared to its programmers is taboo.
though not answering directly (for which i hope you won't sue),
maybe {in,this} time you'll become an emacs programmer, too.

thi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
  2004-12-12 13:13 ` Thien-Thi Nguyen
@ 2004-12-12 13:22 ` Peter Dyballa
       [not found] ` <mailman.5367.1102858474.27204.help-gnu-emacs@gnu.org>
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Peter Dyballa @ 2004-12-12 13:22 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 12.12.2004 um 02:42 schrieb jab3:

> a few thousand K

In other words: a few MB. Then it's quite normal.

Remember that it's Lisp that finds and then checks the words and then 
does appropriate syntax-highlighting.

How is it in a source of a few K bytes?

--
Greetings

   Pete

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
       [not found] ` <mailman.5367.1102858474.27204.help-gnu-emacs@gnu.org>
@ 2004-12-12 22:23   ` jab3
  2004-12-21 18:38     ` Peter Lee
  0 siblings, 1 reply; 13+ messages in thread
From: jab3 @ 2004-12-12 22:23 UTC (permalink / raw)


Peter Dyballa finally wrote on Sun December 12 2004 08:22 am:

> 
> Am 12.12.2004 um 02:42 schrieb jab3:
> 
>> a few thousand K
> 
> In other words: a few MB. Then it's quite normal.
> 

In other words, yeah, I wasn't thinking and I'm an idiot, etc. :-)  I meant
a few K.  I remember in the manual Stallman saying something about large
files requiring more time to process, so with the 'few thousand K' I was
trying to say that that wasn't the problem, but of course I misspoke. 
Whoops.  (I've got the GNU Emacs manual (the paper version from FSF) so I'm
going to look through it to see if I can figure something out)  It just
seems odd; I mean, it's still slower than vim with the same file, no matter
the size.  Maybe it is the overhead that vim doesn't have to account for
(i.e. - maybe it's because Emacs is a more powerful program checks and does
so much at once; I don't mean anything derogatory); I don't know.

> Remember that it's Lisp that finds and then checks the words and then
> does appropriate syntax-highlighting.

Yeah, I wondered about that.  I'm also interested in figuring out (maybe
with regular expressions) a way to make Emacs emulate another vim feature
that I do like: highlighting control characters in quoted strings in a C
file.  For instance, in printf("Hello %s\n", name); I would like the %s and
\n highlighted in a different color from the normal string quote color.  So
I may be adding more overhead, which is why I wanted to see if it was a
problem that could be diminished a bit. 


Cheers and thanks,
jab3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.5367.1102858474.27204.help-gnu-emacs@gnu.org>
@ 2004-12-13  9:35 ` Pierre-Charles David
  2004-12-13 12:08 ` Kai Grossjohann
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Pierre-Charles David @ 2004-12-13  9:35 UTC (permalink / raw)


jab3 <manual@helpdesk.org> writes:

> I don't want to start a war or anything (because it probably has something
> to do with my system), but I am curious about something I've noticed with
> Emacs as compared with vim.  If I'm looking at a source code file in vim,
> (and it doesn't even have to be that large - maybe a few thousand K) the
> syntax highlighting is automatic.  And if I edit something, which changes
> the highlighting of the rest of the file, it is instantaneous.  But in
> Emacs, there is a 2 or 3 second delay in the updating of the highlighting. 
> Is there a setting I'm missing somewhere?  (I'm new to Emacs, and I am
> trying to move to it instead of vim for serious editing)  Has anyone else
> noticed this?

The font-locking system supports different modes of operation, which
determine when fontification occurs. On my system (GNU Emacs 21.3) the
default is `jit-lock-mode', with `jit-lock-stealth-time' set to 3. The
doc says:

  "Stealthy buffer fontification if `jit-lock-stealth-time' is
  non-nil. This means remaining unfontified areas of buffers are
  fontified if Emacs has been idle for `jit-lock-stealth-time'
  seconds, while Emacs remains idle. This is useful if any buffer has
  any deferred fontification."

This would be consistent with the behaviour you describe. Check the
variables `font-lock-support-mode', `jit-lock-mode' and
`jit-lock-stealth-time' variables, and try different values.

-- 
Pierre-Charles David (pcdavid <at> emn <dot> fr)
Computer Science PhD Student, Ecole des Mines de Nantes, France
Homepage: http://pcdavid.net/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
                   ` (3 preceding siblings ...)
  2004-12-13  9:35 ` Pierre-Charles David
@ 2004-12-13 12:08 ` Kai Grossjohann
       [not found] ` <mailman.5589.1102940728.27204.help-gnu-emacs@gnu.org>
  2004-12-21 20:04 ` jab3
  6 siblings, 0 replies; 13+ messages in thread
From: Kai Grossjohann @ 2004-12-13 12:08 UTC (permalink / raw)


jab3 <manual@helpdesk.org> writes:

> I don't want to start a war or anything (because it probably has something
> to do with my system), but I am curious about something I've noticed with
> Emacs as compared with vim.  If I'm looking at a source code file in vim,
> (and it doesn't even have to be that large - maybe a few thousand K) the
> syntax highlighting is automatic.  And if I edit something, which changes
> the highlighting of the rest of the file, it is instantaneous.  But in
> Emacs, there is a 2 or 3 second delay in the updating of the highlighting. 

I think Emacs now uses jit-lock as the font-lock-support-mode.  This
exhibits the symptoms you're mentioning.  You can also turn off
font-lock-support-mode completely, then font-locking should be
instantaneous.  However, then you also have to wait long after opening
a large file, because font-lock then goes through and fontifies the
whole file.

(lazy-lock is another alternative for font-lock-support-mode which
works similarly to jit-lock but is implemented in Lisp.)

Of course, there are various tunables, as others have mentioned.

Kai

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
       [not found] ` <mailman.5589.1102940728.27204.help-gnu-emacs@gnu.org>
@ 2004-12-13 23:42   ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2004-12-13 23:42 UTC (permalink / raw)


>> I don't want to start a war or anything (because it probably has something
>> to do with my system), but I am curious about something I've noticed with
>> Emacs as compared with vim.  If I'm looking at a source code file in vim,
>> (and it doesn't even have to be that large - maybe a few thousand K) the
>> syntax highlighting is automatic.  And if I edit something, which changes
>> the highlighting of the rest of the file, it is instantaneous.  But in
>> Emacs, there is a 2 or 3 second delay in the updating of the highlighting. 

> I think Emacs now uses jit-lock as the font-lock-support-mode.  This
> exhibits the symptoms you're mentioning.

It's indeed the jit-lock-stealth-time delay.  In Emacs-CVS this delay has
been separated from the stealth font-locking and can be made
"instantaneous".


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12 22:23   ` jab3
@ 2004-12-21 18:38     ` Peter Lee
  2004-12-21 20:03       ` jab3
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Lee @ 2004-12-21 18:38 UTC (permalink / raw)


>>>> jab3  writes:

    jab3> I'm also interested in figuring out (maybe
    jab3> with regular expressions) a way to make Emacs emulate another vim feature
    jab3> that I do like: highlighting control characters in quoted strings in a C
    jab3> file.  For instance, in printf("Hello %s\n", name); I would like the %s and
    jab3> \n highlighted in a different color from the normal string quote color.

Do you mean like 
M-x highlight-regexp [ret] \%s
M-x highlight-regexp [ret] \\n

C-x w h

Or do you mean something more permanent?  You could probably use
highlight-regexp in conjunction with one of the font-lock
callbacks... But there's probably a better way.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-21 18:38     ` Peter Lee
@ 2004-12-21 20:03       ` jab3
  2004-12-22 21:55         ` Peter Lee
  0 siblings, 1 reply; 13+ messages in thread
From: jab3 @ 2004-12-21 20:03 UTC (permalink / raw)


Peter Lee finally wrote on Tue December 21 2004 01:38 pm:

>>>>> jab3  writes:
> 
>     jab3> I'm also interested in figuring out (maybe
>     jab3> with regular expressions) a way to make Emacs emulate another
>     vim feature jab3> that I do like: highlighting control characters in
>     quoted strings in a C
>     jab3> file.  For instance, in printf("Hello %s\n", name); I would like
>     the %s and jab3> \n highlighted in a different color from the normal
>     string quote color.
> 
> Do you mean like
> M-x highlight-regexp [ret] \%s
> M-x highlight-regexp [ret] \\n
> 
> C-x w h
> 
> Or do you mean something more permanent?  You could probably use
> highlight-regexp in conjunction with one of the font-lock
> callbacks... But there's probably a better way.

Ah.  That seems to be doing what I want.  What if I just put the commands in
my .emacs file?  How would I type the command for that file?

(highlight-regexp "\%s" 'font-lock-function-name-face) ???

I know that's probably not right, but would something like that work?


Thanks,
jab3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
                   ` (5 preceding siblings ...)
       [not found] ` <mailman.5589.1102940728.27204.help-gnu-emacs@gnu.org>
@ 2004-12-21 20:04 ` jab3
  6 siblings, 0 replies; 13+ messages in thread
From: jab3 @ 2004-12-21 20:04 UTC (permalink / raw)


jab3 finally wrote on Sat December 11 2004 08:42 pm:

> Hello -
> 
> I don't want to start a war or anything (because it probably has something
> to do with my system), but I am curious about something I've noticed with
> Emacs as compared with vim.  If I'm looking at a source code file in vim,
> (and it doesn't even have to be that large - maybe a few thousand K) the
> syntax highlighting is automatic.  And if I edit something, which changes
> the highlighting of the rest of the file, it is instantaneous.  But in
> Emacs, there is a 2 or 3 second delay in the updating of the highlighting.
> Is there a setting I'm missing somewhere?  (I'm new to Emacs, and I am
> trying to move to it instead of vim for serious editing)  Has anyone else
> noticed this?
> 
> My system is a P4 2Ghz with 256M RAM.

Thanks to everyone for their help.  I'm on my way.  (I know it's been a
while since my post, I've been distracted) :-)


-jab3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-21 20:03       ` jab3
@ 2004-12-22 21:55         ` Peter Lee
  2004-12-23  0:18           ` jab3
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Lee @ 2004-12-22 21:55 UTC (permalink / raw)


>>>> jab3  writes:

    jab3> Ah.  That seems to be doing what I want.  What if I just put the commands in
    jab3> my .emacs file?  How would I type the command for that file?

    jab3> (highlight-regexp "\%s" 'font-lock-function-name-face) ???

maybe something like:

(global-set-key (kbd "C-c m") (lambda () (interactive) (highlight-regexp "\%s" "hi-yellow")))

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-22 21:55         ` Peter Lee
@ 2004-12-23  0:18           ` jab3
  2004-12-27 17:09             ` Kevin Rodgers
  0 siblings, 1 reply; 13+ messages in thread
From: jab3 @ 2004-12-23  0:18 UTC (permalink / raw)


Peter Lee finally wrote on Wed December 22 2004 04:55 pm:

>>>>> jab3  writes:
> 
>     jab3> Ah.  That seems to be doing what I want.  What if I just put the
>     commands in
>     jab3> my .emacs file?  How would I type the command for that file?
> 
>     jab3> (highlight-regexp "\%s" 'font-lock-function-name-face) ???
> 
> maybe something like:
> 
> (global-set-key (kbd "C-c m") (lambda () (interactive) (highlight-regexp
> "\%s" "hi-yellow")))

Excellent.  I got that to work with font-lock-function-name-face, so
everything's all starting to come together.  I have a question though.  I
had to do something odd (at least I consider it odd :); to make '\n' work
in the .emacs file with the lambda function, I had to use 4 \ for it to
only use the '\n'.  That is, 

(highlight-regexp "\\\\n" "font-lock-function-name-face")

is the only thing that worked correctly.  If I only did "\\n" then Emacs
highlighted all 'n's.  Why is it necessary to use '\\\\n' to represent
'\n'?  I can understand '\\n' - it's just the double that is confusing
me. :)


Thanks for all your help,
jab3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Syntax Highlighting Latency in Emacs
  2004-12-23  0:18           ` jab3
@ 2004-12-27 17:09             ` Kevin Rodgers
  0 siblings, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2004-12-27 17:09 UTC (permalink / raw)


jab3 wrote:
 > Peter Lee finally wrote on Wed December 22 2004 04:55 pm:
 >>maybe something like:
 >>
 >>(global-set-key (kbd "C-c m") (lambda () (interactive) (highlight-regexp
 >>"\%s" "hi-yellow")))
 >
 > Excellent.  I got that to work with font-lock-function-name-face, so
 > everything's all starting to come together.  I have a question though.  I
 > had to do something odd (at least I consider it odd :); to make '\n' work
 > in the .emacs file with the lambda function, I had to use 4 \ for it to
 > only use the '\n'.  That is,
 >
 > (highlight-regexp "\\\\n" "font-lock-function-name-face")
 >
 > is the only thing that worked correctly.  If I only did "\\n" then Emacs
 > highlighted all 'n's.  Why is it necessary to use '\\\\n' to represent
 > '\n'?  I can understand '\\n' - it's just the double that is confusing
 > me. :)

You want to match the 2-character sequence `backslash lowercase-n',
right?  In order to match the backslash character, the regular
expression is `\\'; the string that contains 2 backslashes is "\\\\".

This is discussed in the Regexps node [aka Syntax of Regular Expressions 
=============================]
of the Emacs manual; also look for the description of strings in the
Init Syntax node [aka Init File Syntax] and Glossary node.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-12-27 17:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-12  1:42 Syntax Highlighting Latency in Emacs jab3
2004-12-12 13:13 ` Thien-Thi Nguyen
2004-12-12 13:22 ` Peter Dyballa
     [not found] ` <mailman.5367.1102858474.27204.help-gnu-emacs@gnu.org>
2004-12-12 22:23   ` jab3
2004-12-21 18:38     ` Peter Lee
2004-12-21 20:03       ` jab3
2004-12-22 21:55         ` Peter Lee
2004-12-23  0:18           ` jab3
2004-12-27 17:09             ` Kevin Rodgers
2004-12-13  9:35 ` Pierre-Charles David
2004-12-13 12:08 ` Kai Grossjohann
     [not found] ` <mailman.5589.1102940728.27204.help-gnu-emacs@gnu.org>
2004-12-13 23:42   ` Stefan Monnier
2004-12-21 20:04 ` jab3

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).