Emacs highlighting, keywords

  • Thread starter rolf.andreassen
  • Start date
R

rolf.andreassen

Hi,

I'm a new user trying to set up a Ruby dev environment. I've gotten to
the point where emacs is willing to highlight some syntax, but not all.
Specifically, I get strings in grey and comments in red, but keywords
('class', 'def', 'end') stay stubbornly black, as do class and variable
names. Keywords do get highlighted in .C files, so it does not seem to
be a global emacs issue.

I wonder if the issue can be that font-lock-defaults is not getting
defined properly, for its value is nil in my test.rb file. Can anyone
help me understand how to get it properly set?

Background information: I am using GNU Emacs 21.3.1
(i386-mingw-nt5.1.2600), on Windows XP, and Ruby version 1.8.6. I am
loading ruby mode with the following lines in my .emacs:

(setq load-path (append load-path
'("D:/ruby/doc/ruby/ruby-1.8.6/misc")))
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts."
t)
(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))


Thanks,

Rolf Andreassen.
 
R

Rob

Hi,

I'm a new user trying to set up a Ruby dev environment. I've gotten to
the point where emacs is willing to highlight some syntax, but not
all.
Specifically, I get strings in grey and comments in red, but keywords
('class', 'def', 'end') stay stubbornly black, as do class and
variable
names. Keywords do get highlighted in .C files, so it does not seem to
be a global emacs issue.

I wonder if the issue can be that font-lock-defaults is not getting
defined properly, for its value is nil in my test.rb file. Can anyone
help me understand how to get it properly set?

Background information: I am using GNU Emacs 21.3.1
(i386-mingw-nt5.1.2600), on Windows XP, and Ruby version 1.8.6. I am
loading ruby mode with the following lines in my .emacs:

(setq load-path (append load-path
'("D:/ruby/doc/ruby/ruby-1.8.6/misc")))
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby
scripts."
t)
(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))


Thanks,

Rolf Andreassen.

I set these font faces before I autoload the ruby-mode. It's old
'cause I've been using Emacs for a looong time, but my keywords in
ruby-mode are now cyan (and have been for ages so I have no clue what
they were normally). I use a black background so you may have to
change some of the colors if you prefer a light background.

(require 'font-core)
(require 'font-lock)

(setq font-lock-maximum-decoration t)
(global-font-lock-mode t nil) ; this is what I want! (8/26/01)

(setq font-lock-face-attributes
(list
'(font-lock-comment-face "firebrick" nil nil nil nil)
'(font-lock-function-name-face "orange" nil nil nil nil)
'(font-lock-keyword-face "cyan" nil nil nil nil)
;; '(font-lock-reference-face "red" nil nil nil nil)
'(font-lock-string-face "blue" nil nil nil nil)
'(font-lock-type-face "magenta" nil nil nil nil)
'(font-lock-variable-name-face "green" nil nil nil nil)
))


I also have this bit (probably from a couple years ago) that, I think,
shows a better way to set fonts that are at least minimally aware of
the lightness or darkness of the background. (e.g., the '(background
light) list)

(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(cperl-array ((((class color) (background light)) :)background
"lightyellow2" :foreground "Blue"))))
'(cperl-hash ((((class color) (background light)) :)background
"lightyellow2" :foreground "Red" :slant italic))))
)


-Rob

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top