I am working on a fortran code. The sources are written in old fashion f77 style but the f90 comment style, with '!' is authorized. I want to edit the emacs behavior when hitting tab on lines with comments. I can distinguish 3 types of comments:
program helloworld
integer:: i,j
do i=1,1
do j=1,1
* This is a first type of comment
* another first type comment
! second type of comment
print *,"helloworld" ! third type of comment
enddo
enddo ! another third type comment
end program helloworld
When hitting tab on each line with a comment type, I got
program helloworld
integer:: i,j
do i=1,1
do j=1,1
* This is a first type of comment
* another first type comment
! second type of comment
print *,"helloworld" ! third type of comment
enddo
enddo ! another third type comment
end program helloworld
The behavior I would like to have is, as hitting tab on a line with:
- first type comment: do nothing
- second type comment: indent the line as an instruction line
- third type comment: indent the line as an instruction line, without adding spaces between the instruction and the comment that follows
I tried to override some function from fortran.el in my init.el but went crazy with lisp. I would be glad if some lisp/emacs warriors could help me with this.
Thanks