tags:

views:

504

answers:

4

Hi Guys,

I'm pretty old school sometimes and I like working with Emacs in my terminal. (I work with IDEs all the time. But sometimes, when in the privacy of my own home, I just like a text editor a terminal and a beer)

However, the default Emacs that comes with OS X does not seem to highlight the comments in font-lock-mode. I've seen this behavior in both Python and C mode.

I've already searched some forums and I found one post where the person was having the same problem as me:

http://forums.macosxhints.com/showthread.php?p=512361

Is is there any way to fix this problem?

A: 

I'm not sure exactly how to fix it, but I'm fairly certain there's something you can put in the .emacs file. In fact, I think I've done that before. I'll look for my file and let you know what I can find.

I'll try and get you my .emacs file when I get home from work tonight.

[edit] I've looked and looked, and can't find a .emacs file on either system that I use, and on my OS X install (Leopard default), it looks like it does it correctly by default. I did some research here, and it looks like the default installations no longer use .emacs files, because there's folks like me that mess around with them and break things, and they got tired of having to help us fix it. But, there is a set of menus that will let you tweak things. Start by typing "M-x customize RET", where M is the meta character (on my OSX install, this is the esc key. Don't hold it down, just type it like a regular character. That'll get you into a menu of stuff you can change. I didn't poke around too much, so I'm not sure where in the menu you'll find what you're looking for. Sorry I couldn't be more help.

Jeff Barger
You can still customize Emacs using a .emacs file; the menu was just added to help new users a bit.
mipadi
Right, I saw that you can still use a .emacs file, but it seems like the preferred way is with the menu
Jeff Barger
A: 

Thanks! I hope you find it! Maybe you can just email me your .emacs file?

A: 

In my experience this is usually related to a unpaired quote (single-, double-, or otherwise) somewhere in an existing comment.

Hunt those occurences down and eradicate them in your source code (or if you are more ambitious, see if you can update the fontlock code in your major modes' emacs source code)

When I have encountered this in editting Perl in emacs, I often switch major modes to cperl-mode as it typically handles parsing the perl better than the default perl-mode.

popcnt
+1  A: 

I had this exact same problem. The solution is to change the color used for the comment face as follows:

(set-face-foreground 'font-lock-comment-face "red")

Or, if you only want to do this for certain modes:

;;; Only do this for the common C mode (C, C++, Objective-C)
(add-hook 'c-mode-common-hook #'(lambda () (set-face-foreground 'font-lock-comment-face "red")))

For more information on faces, see http://www.gnu.org/software/emacs/manual/html_node/emacs/Faces.html.

Adam Rosenfield