[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

emacs syntax highlighting problem

Tim Ferrell

2/17/2005 2:11:00 PM

Let me first say I am new to emacs ... so this may be something embarrassingly simple :-)

I am running emacs 21.4.1 on gentoo linux and I have customized it with some of the tips I have found at ruby garden and a few other places ... All is
working nicely except that I must have somehow managed to break syntax highlighting... even when I enable global font lock I get nothing but "normal" text :-(

I have posted my configs at http://www.mcgeecorp.com/downloads/emacs-c... if anyone happens to have a few minutes to look them over. Thanks much and
sorry if this is something stupid...

Cheers,
Tim


9 Answers

Tim Ferrell

2/17/2005 9:06:00 PM

0

Some further investigation uncovered the culprit: ruby-electric.el (
http://shylock.uw.hu/Emacs/ruby-e... ) ... for some reason when I
"(require 'ruby-electric)" I don't get syntax highlighting.

Anyone else using this successfully? Have I overlooked something?

Cheers,
Tim

Tim Ferrell wrote:
> Let me first say I am new to emacs ... so this may be something
> embarrassingly simple :-)
>
> I am running emacs 21.4.1 on gentoo linux and I have customized it with
> some of the tips I have found at ruby garden and a few other places ...
> All is working nicely except that I must have somehow managed to break
> syntax highlighting... even when I enable global font lock I get nothing
> but "normal" text :-(
>
> I have posted my configs at
> http://www.mcgeecorp.com/downloads/emacs-c... if anyone happens
> to have a few minutes to look them over. Thanks much and sorry if this
> is something stupid...
>
> Cheers,
> Tim
>


Kent Sibilev

2/18/2005 6:24:00 AM

0

Tim Ferrell <Tim.Ferrell@s0nspark.com> writes:

> Some further investigation uncovered the culprit: ruby-electric.el (
> http://shylock.uw.hu/Emacs/ruby-e... ) ... for some reason when
> I "(require 'ruby-electric)" I don't get syntax highlighting.
>
> Anyone else using this successfully? Have I overlooked something?
>
> Cheers,
> Tim

I'm using ruby-electric.el and never had any problems with syntax
highlighting. The problem must be somewhere else.

Cheers,
Kent.


Tim Ferrell

2/18/2005 1:03:00 PM

0

Fixed it ... I was loading ruby-electric before I turned on global-font-lock
and for some reason that killed syntax highlighting in ruby-mode...

Cheers,
Tim


Kent Sibilev wrote:
> Tim Ferrell <Tim.Ferrell@s0nspark.com> writes:
>
>
>>Some further investigation uncovered the culprit: ruby-electric.el (
>>http://shylock.uw.hu/Emacs/ruby-e... ) ... for some reason when
>>I "(require 'ruby-electric)" I don't get syntax highlighting.
>>
>>Anyone else using this successfully? Have I overlooked something?
>>
>>Cheers,
>>Tim
>
>
> I'm using ruby-electric.el and never had any problems with syntax
> highlighting. The problem must be somewhere else.
>
> Cheers,
> Kent.
>


Jeffrey Moss

2/18/2005 5:21:00 PM

0

I use emacs exclusively. I've found the ruby-mode ebuild to be sufficient
for me. What does ruby-electric offer that this doesn't?

-Jeff

----- Original Message -----
From: "Tim Ferrell" <Tim.Ferrell@s0nspark.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Thursday, February 17, 2005 2:06 PM
Subject: Re: emacs syntax highlighting problem


> Some further investigation uncovered the culprit: ruby-electric.el (
> http://shylock.uw.hu/Emacs/ruby-e... ) ... for some reason when I
> "(require 'ruby-electric)" I don't get syntax highlighting.
>
> Anyone else using this successfully? Have I overlooked something?
>
> Cheers,
> Tim
>
> Tim Ferrell wrote:
>> Let me first say I am new to emacs ... so this may be something
>> embarrassingly simple :-)
>>
>> I am running emacs 21.4.1 on gentoo linux and I have customized it with
>> some of the tips I have found at ruby garden and a few other places ...
>> All is working nicely except that I must have somehow managed to break
>> syntax highlighting... even when I enable global font lock I get nothing
>> but "normal" text :-(
>>
>> I have posted my configs at
>> http://www.mcgeecorp.com/downloads/emacs-c... if anyone happens to
>> have a few minutes to look them over. Thanks much and sorry if this is
>> something stupid...
>>
>> Cheers,
>> Tim
>>
>



Tim Ferrell

2/18/2005 6:23:00 PM

0


As I understand (I just got it working today *g*), it offers block completion...

From the extension file:

"When Ruby Electric mode is enabled, an indented 'end' is
heuristically inserted whenever typing a word like 'module',
'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin',
'do'. Simple, double and back quotes as well as braces are paired
auto-magically. Expansion does not occur inside comments and
strings."

Cheers,
Tim


Jeffrey Moss wrote:
> I use emacs exclusively. I've found the ruby-mode ebuild to be
> sufficient for me. What does ruby-electric offer that this doesn't?
>
> -Jeff
>
> ----- Original Message ----- From: "Tim Ferrell" <Tim.Ferrell@s0nspark.com>
> To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
> Sent: Thursday, February 17, 2005 2:06 PM
> Subject: Re: emacs syntax highlighting problem
>
>
>> Some further investigation uncovered the culprit: ruby-electric.el (
>> http://shylock.uw.hu/Emacs/ruby-e... ) ... for some reason when
>> I "(require 'ruby-electric)" I don't get syntax highlighting.
>>
>> Anyone else using this successfully? Have I overlooked something?
>>
>> Cheers,
>> Tim
>>
>> Tim Ferrell wrote:
>>
>>> Let me first say I am new to emacs ... so this may be something
>>> embarrassingly simple :-)
>>>
>>> I am running emacs 21.4.1 on gentoo linux and I have customized it
>>> with some of the tips I have found at ruby garden and a few other
>>> places ... All is working nicely except that I must have somehow
>>> managed to break syntax highlighting... even when I enable global
>>> font lock I get nothing but "normal" text :-(
>>>
>>> I have posted my configs at
>>> http://www.mcgeecorp.com/downloads/emacs-c... if anyone
>>> happens to have a few minutes to look them over. Thanks much and
>>> sorry if this is something stupid...
>>>
>>> Cheers,
>>> Tim
>>>
>>
>
>


Mike D.

2/18/2005 8:09:00 PM

0

I suspect that most font-lock problems like this are caused by the
internal use of ruby-mode-hook in ruby-mode.el. Suppose your .emacs
file contains

(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(add-hook 'ruby-mode-hook 'turn-on-font-lock)

Because your hook is added before ruby-mode is actually loaded on
demand, the resulting ruby-mode-hook will be

((lambda nil
(make-local-variable 'font-lock-defaults)
(make-local-variable 'font-lock-keywords)
(make-local-variable 'font-lock-syntax-table)
(make-local-variable 'font-lock-syntactic-keywords)
(setq font-lock-defaults
'((ruby-font-lock-keywords)
nil nil))
(setq font-lock-keywords ruby-font-lock-keywords)
(setq font-lock-syntax-table ruby-font-lock-syntax-table)
(setq font-lock-syntactic-keywords
ruby-font-lock-syntactic-keywords))
turn-on-font-lock)

Suppose instead that your .emacs file contained

(require 'ruby-mode)
(add-hook 'ruby-mode-hook 'turn-on-font-lock)

That seems harmless enough, but now ruby-mode adds its hook before you
add yours, and ruby-mode-hook becomes

(turn-on-font-lock
(lambda nil
(make-local-variable 'font-lock-defaults)
(make-local-variable 'font-lock-keywords)
(make-local-variable 'font-lock-syntax-table)
(make-local-variable 'font-lock-syntactic-keywords)
(setq font-lock-defaults
'((ruby-font-lock-keywords)
nil nil))
(setq font-lock-keywords ruby-font-lock-keywords)
(setq font-lock-syntax-table ruby-font-lock-syntax-table)
(setq font-lock-syntactic-keywords
ruby-font-lock-syntactic-keywords)))

For many people running GNU Emacs, that won't work properly. They'll
need to toggle font-lock off and on again to get the desired behavior.

Here's an excerpt from the GNU Emacs documentation:

31.2.3 Hooks
------------
"With rare exceptions, hooks in Emacs are empty when Emacs starts up,
so the only hook functions in any given hook are the ones you
explicitly put there as customization.
....
It is best to design your hook functions so that the order in which
they are executed does not matter. Any dependence on the order is
'asking for trouble.'"

To avoid this problem in the future, it would be nice if ruby-mode.el
could perform its font-lock initialization without using
ruby-mode-hook.

- Mike

Caio Tiago Oliveira

2/18/2005 8:40:00 PM

0

Tim Ferrell, 18/2/2005 15:23:
>
> As I understand (I just got it working today *g*), it offers block
> completion...
>
> From the extension file:
>
> "When Ruby Electric mode is enabled, an indented 'end' is
> heuristically inserted whenever typing a word like 'module',
> 'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin',
> 'do'. Simple, double and back quotes as well as braces are paired
> auto-magically. Expansion does not occur inside comments and
> strings."


It turns /#/.matches(foo) in a slash and a comment?
Turns /^bar$/ in /^bat and a global variable?
Turns /:/ in a slash and a symbol while using syntax highlighting and
breakes the indentation in the first case?

If no, no and no may be I'll switch to it.



Tim Ferrell

2/18/2005 9:11:00 PM

0


I tried all three here and (if I understood you correctly) it is, in fact, no,
no and no :-)

Cheers,
Tim

Caio Tiago Oliveira wrote:
> Tim Ferrell, 18/2/2005 15:23:
>
>>
>> As I understand (I just got it working today *g*), it offers block
>> completion...
>>
>> From the extension file:
>>
>> "When Ruby Electric mode is enabled, an indented 'end' is
>> heuristically inserted whenever typing a word like 'module',
>> 'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin',
>> 'do'. Simple, double and back quotes as well as braces are paired
>> auto-magically. Expansion does not occur inside comments and
>> strings."
>
>
>
> It turns /#/.matches(foo) in a slash and a comment?
> Turns /^bar$/ in /^bat and a global variable?
> Turns /:/ in a slash and a symbol while using syntax highlighting and
> breakes the indentation in the first case?
>
> If no, no and no may be I'll switch to it.
>
>


Dee Zsombor

2/23/2005 9:46:00 AM

0

My intention was for ruby-electric to be a complement for ruby-mode
offering some additional services.

Zsombor