I have been a emacs user for a while now, and recently I converted a program from f77 to f90. Here is the problem: if I use fortran-mode, all what is past the 72 columns is commented out, which is ugly to work with. On the other hand, I have a bunch of comments starting with "c" on the first column that were left from the f77 version, and if I use f90-mode they are not displayed as comment, which is also ugly to work with.

If there a way I can tell f90-mode to color-code "comment" all the lines that have a "c" on the first column?

Thanks,

Efo

Last edited by Efo on Wed Apr 14, 2010 5:19 pm, edited 1 time in total.

As I look at fortran.el, the F77 comment syntax is implemented as hack, as Emacs doesn't really support positional syntax. The correct thing to do would be to replace all old syntax comments with new, with for example M-x query replace<RET>^c<RET>!<RET> . The less correct thing to do is add to .emacs:

Thank you for the prompt response.The first solution seems to be a little cumbersome given the different files and lines of code... but I guess I could do that as I go, even though I am not sure if other people using subversion are going to like that.I suppose the "^" indicates the first line, I tried it and I get "Replaced 0 occurences"

The second, less correct, solution seems to fit me better (I put it into .emac), but I get:͂͂Warning (initialization): An error occurred while loading `/home/efo/.emacs':Symbol's value as variable is void: f90-mode-hookTo ensure normal operation, you should investigate and remove thecause of the error in your initialization file. Start Emacs withthe `--debug-init' option to view a complete error backtrace.

Efo wrote:The first solution seems to be a little cumbersome given the different files and lines of code... but I guess I could do that as I go, even though I am not sure if other people using subversion are going to like that.

You could use findr which can do query-replace recursively in a directory.

Efo wrote:I suppose the "^" indicates the first line, I tried it and I get "Replaced 0 occurences"

Sorry, I meant query-replace-regexp as a command. "^" means beginning of line. You could also use just replace-regexp, but I suppose confirming the changes would be better in this case.

Efo wrote:The second, less correct, solution seems to fit me better (I put it into .emac), but I get:

I meant "^" first column (or beginning of line), not line... it was late at night Anyway, query-replace-regexp worked. But I still have the problem that the code is shared by different developers, and I dont want to mess the comments up for a color coding problem.

This is getting embarrassing... well, testing this properly requires restarting Emacs, since when I tested that before I already had loaded most of the modules, and I tested only the inner form so I got quoting wrong when wrapping. Anyway, what I just tested and hopefully will work this time: