GNU bug report logs - #73218
[PATCH] Fix Fortran indent below do_not_a_loop=42

Previous Next

Package: emacs;

Reported by: Ken Mankoff <km <at> kenmankoff.com>

Date: Fri, 13 Sep 2024 03:59:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ken Mankoff <km <at> kenmankoff.com>
Cc: 73218 <at> debbugs.gnu.org
Subject: bug#73218: [PATCH] Fix Fortran indent below do_not_a_loop=42
Date: Sat, 14 Sep 2024 14:15:32 +0300
> From: Ken Mankoff <km <at> kenmankoff.com>
> Cc: 73218 <at> debbugs.gnu.org
> Date: Fri, 13 Sep 2024 08:44:45 -0700
> 
> >> --- a/lisp/progmodes/fortran.el
> >> +++ b/lisp/progmodes/fortran.el
> >> @@ -1631,7 +1631,7 @@ fortran-calculate-indent
> >>                 (setq icol (+ icol fortran-if-indent)))
> >>                ((looking-at "where[ \t]*(.*)[ \t]*\n")
> >>                 (setq icol (+ icol fortran-if-indent)))
> >> -              ((looking-at "do\\b")
> >> +              ((looking-at "do[\\ |0-9]+.*=[\\ a-z0-9_]*,[\\ a-z0-9_]*")
> >
> > What do you intend with the likes of "[\\ |0-9]+" ?  Is this a
> > character alternative, or is that an alternative of matches?  If the
> > former, there's no need to escape a backslash, but then why is '|'
> > there?
> 
> I agree the '|' is not needed. I'm not sure what 'character alternative' or 'alternative of matches' means. I meant the '|' as an "OR" (is that an alterntative?), but realize now it is not needed. I now suggest
> 
> "do[\\ 0-9]+.*=[\\ a-z0-9_]*,[\\ a-z0-9_]*"

Why do we need a backslashes before SPC?

Since the SPC is optional in Fortran, how about the following instead?

  "do *[0-9]* *[a-z0-9_]+ *= *[a-z0-9_]+ *, *[a-z0-9_]+"

> The pattern attempts to match "do", then either (space, numbers, or nothing), then equal sign, then something that looks like two numbers or valid variable names separated by a comma. I used these as tests:
> 
>       do42I=1,42 ! match
>       do_foo = bar()
>       do i = 1,42 ! match
>       do i = 1,n ! match
>       do i_var = a_var,b_var ! match
>       do i_var5 = a_var,b_var ! match
>       do42i_var = a_var,b_var ! match
>       DO42 = [1,2]
>       DO6I=5 7
>       DO6I=5,7  ! match
>       do_not_loop = [a,b]
>       donot_loop = (/4,5/)
>       donotloop = 42
>       do_notloop = 42

Please use the above to test my suggestion.

> Should I submit an updated patch? Or is the patch applier able to make this small change?

An updated patch would be better, but let's first find the correct
regexp to use.

Thanks.




This bug report was last modified 310 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.