From: Ken Mankoff <km@kenmankoff.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Fortran indentation
Date: Tue, 27 Aug 2024 06:15:33 -0700 [thread overview]
Message-ID: <87bk1e5cp6.fsf@kenmankoff.com> (raw)
In-Reply-To: <86v7zmi2il.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 27 Aug 2024 15:17:06 +0300")
On 2024-08-27 at 05:17 -07, Eli Zaretskii <eliz@gnu.org> wrote...
>> From: Ken Mankoff <km@kenmankoff.com>
>>
>> do_foo = some_function()
>> if (do_foo) then
>>
>> The if statement should not be indented, because do_foo is not the
>> start of a do loop. I can fix this behavior if I change line 1634 of
>> fortrtan.el from
>>
>> ((looking-at "do\\b")
>>
>> to
>>
>> ((looking-at "do\\ \\b")
>>
>
> DO42000I=1,42
>
> AFAIR is a valid Fortran do-loop starter.
You're right, that is valid. The 'looking-at' regex can be improved to handle this case - match "DO42I=1,42" but not "do_foo = f()".
My first attempt is to expect a space or numbers after "DO": "do[\\ |0-9]+". This still matches a vector assignment of: DO42 = [1,2]
More comprehensive - search for only certain characters on the RHS. do[\\ |0-9]+.*=[\\ a-z0-9_]*,[\\ a-z0-9_]*
The last regex appears to work in regexp-builder with these few 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
do42i_var = a_var,b_var ! match
DO42 = [1,2]
Would this change be acceptable?
-k.
next prev parent reply other threads:[~2024-08-27 13:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 23:37 Fortran indentation Ken Mankoff
2024-08-27 12:17 ` Eli Zaretskii
2024-08-27 13:15 ` Ken Mankoff [this message]
2024-08-27 13:56 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bk1e5cp6.fsf@kenmankoff.com \
--to=km@kenmankoff.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.