unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Fabrice Nicol <fabrnicol@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 47408@debbugs.gnu.org
Subject: bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for existentially-quantified procedures
Date: Thu, 17 Jun 2021 13:19:26 +0200	[thread overview]
Message-ID: <CANTSrJuwZ0o4pRAeah+Ai7pdQrKU9Nk5uTcHEZVN6HWY5q2Ptw@mail.gmail.com> (raw)
In-Reply-To: <83y2b8zrxa.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3568 bytes --]

Hi Eli,


Thanks.  I confirm that this works, but I have 2 follow-up issues with
> this patch:
>
> 1. It adds tags for some identifiers that AFAUI are actually
>    keywords, and shouldn't be in the TAGS tables.  Examples:
>    "interface" (e.g., on line 146 of accumulator.m) and
>    "implementation" (e.g., on line 166).  I guess this is unintended?
>    If so, how to fix it?
>

This is intended. I commented this in the commit message (one-word
declarations).
I confirm that
':- implementation' and ':-interface' are *formally* declarations in
Mercury as all others are.
They were not included in the previous version bercause of an incomplete
switch.
It is quite useful from a practical point of view to add them to the tag
base. When interfaces are big (they can reach a couple of thousand lines in
real-world programming) it is sometimes useful to have a bookmark to jump
to the start of the implementation section and back. I used to create an
ad-hoc emacs bookmark for this. Tagging removes the need for this. Simply
strike M-. at a blank line an select the interface/implementation tag.
In the C family this is the same as striking M-. on an header include
declaration and jumping to the header file and back. Some IDEs use F4 for
this. Think of Mercury interfaces as C headers.



>
>
> 2. It always produces "explicitly named" tags, which I think is
>    unnecessary.  AFAICT, this is related to the following snippet from
>    mercury_pr:
>
> > +      /* Left-trim type definitions.  */
> > +
> > +      while (pos > namelength + offset
> > +          && c_isspace (s[pos - namelength - offset]))
> > +     --offset;
> > +
> > +      /* There is no need to correct namelength or call notinname.  */
> > +      s[pos - offset - 1] = '\0';
> > +
> > +      make_tag (s + pos - namelength - offset, namelength, true, s,
> pos, lineno, linecharno);
> > +      return pos;
>
>    I don't understand why you need to overwrite s[pos - offset -1]
>    with the null byte: the same effect could be obtained by adjusting
>    the POS argument passed to make_tag.  Also, you in effect chop off
>    the last character of NAME, but don't adjust NAMELENGTH
>    accordingly.  These factors together cause make_tag to decide that
>    an explicitly-named tag is in order, because name[namelength-1] is
>    a null byte, which is rejected as being "not-a-name" character.
>
>    To fix this second issue, I propose the change below, which should
>    be applied on top of your patches:
>
> diff --git a/lib-src/etags.c b/lib-src/etags.c
> index 370e825..2b0288e 100644
> --- a/lib-src/etags.c
> +++ b/lib-src/etags.c
> @@ -6585,10 +6585,8 @@ mercury_pr (char *s, char *last, ptrdiff_t lastlen)
>              && c_isspace (s[pos - namelength - offset]))
>         --offset;
>
> -      /* There is no need to correct namelength or call notinname.  */
> -      s[pos - offset - 1] = '\0';
> -
> -      make_tag (s + pos - namelength - offset, namelength, true, s, pos,
> lineno, linecharno);
> +      make_tag (s + pos - namelength - offset, namelength - 1, true,
> +               s, pos - offset - 1, lineno, linecharno);
>        return pos;
>      }
>
> I've verified that etags after this change still produces the correct
> TAGS file, including for the file univ.m you sent up-thread.
>
> Do you agree with the changes I propose?  If not, could you please
> explain what I miss here?
>

OK, this is another way of achieving an equivalent result. Please leave me
until tomorrow to perform more tests so that I can formally confirm that
this is fine.
Best
Fabrice

>

[-- Attachment #2: Type: text/html, Size: 4950 bytes --]

  reply	other threads:[~2021-06-17 11:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.12421.1623412982.2554.bug-gnu-emacs@gnu.org>
2021-06-14 15:10 ` bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for existentially-quantified procedures fabrice nicol
2021-06-14 16:04   ` Eli Zaretskii
2021-06-14 17:10     ` fabrice nicol
2021-06-14 17:42       ` Eli Zaretskii
2021-06-14 18:52         ` fabrice nicol
2021-06-17 10:50           ` Eli Zaretskii
2021-06-17 11:19             ` Fabrice Nicol [this message]
2021-06-17 11:42               ` Eli Zaretskii
2021-06-17 18:36                 ` fabrice nicol
2021-06-18 11:29                   ` Eli Zaretskii
2021-06-18 11:54                     ` Francesco Potortì
2021-06-18 12:33                       ` Eli Zaretskii
2021-06-18 13:53                         ` fabrice nicol

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANTSrJuwZ0o4pRAeah+Ai7pdQrKU9Nk5uTcHEZVN6HWY5q2Ptw@mail.gmail.com \
    --to=fabrnicol@gmail.com \
    --cc=47408@debbugs.gnu.org \
    --cc=eliz@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).