I like Ruby a lot, but I really dislike seeing the following in the
middle of my code all the time:
end
end
end
I’m not offended nearly so much by some other languages’
}
}
}
because there’s much less clutter and my eye isn’t fooled into saying
’Ooh, a word, it must be important!’ (For the same reason, I use _
instead of self when I write Python code.)
Anyway, it occured to me that there might be an easy way to get 90% of
what I want, just by making the keyword ‘end’ be almost invisible.
With this change, Ruby code looks just like Python (whose style I
like, and if you don’t, just stop reading here instead of expressing
your disapproval), except with a few more blank-with-subliminal-text
lines.
Here’s how I did it.
- Put the following code in your .emacs or wherever:
(defface font-lock-subliminal-face
’((t :inherit default :foreground “#eee”))
“Font Lock mode face used for subliminal text.”
:group 'font-lock-highlighting-faces)
(defvar font-lock-subliminal-face 'font-lock-subliminal-face
"Face name to use for things that should be barely visible.")
- In ruby-mode.el, add the marked two lines at the beginning of the
definition of ruby-font-lock-keywords:
(defvar ruby-font-lock-keywords
(list
- '("\(^\|[^:.@$]\|\.\.\)\b\(end\)\b\([^]\|$\)"
-
(cons (concat2 font-lock-subliminal-face)
"\(^\|[^_:.@$]\|\.\.\)\b\("
(mapconcat
’identity
’(“alias”
“and”
“begin”
Use M-x customize-face if you don’t like the color choice.
This simple change increased the comprehensibility of Ruby code by a
large amount for me. Your mileage will undoubtedly vary, but if you
think you might like it, give it a shot.
Dan