From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#47408: Etags support for Mercury [v0.5] Date: Thu, 10 Jun 2021 20:20:45 +0300 Message-ID: <83h7i5bpqq.fsf@gnu.org> References: <70503251-f8ea-9006-b7e7-b13b93bb71de@gmail.com> <838s4gxurw.fsf@gnu.org> <53162dfb-0715-3077-78d1-3a8340943f2f@gmail.com> <838s3y6kaq.fsf@gnu.org> <83k0n7iarj.fsf@gnu.org> <65f059b1-149d-146d-3b8d-36db60ff1044@gmail.com> <87o8cin9fb.fsf@tucano.isti.cnr.it> <39f683d3-65d7-a7d9-18b1-cf6dfa7d254a@gmail.com> <83fsxthnye.fsf@gnu.org> <87lf7kmxuk.fsf@tucano.isti.cnr.it> <83bl8gfuhy.fsf@gnu.org> <87k0n4msku.fsf@tucano.isti.cnr.it> <834ke5ddnb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7711"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47408@debbugs.gnu.org To: fabrice nicol Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 10 19:22:17 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrONl-0001uv-PT for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Jun 2021 19:22:17 +0200 Original-Received: from localhost ([::1]:40632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrONk-0004J0-Rr for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Jun 2021 13:22:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrONW-0004In-Jv for bug-gnu-emacs@gnu.org; Thu, 10 Jun 2021 13:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrONV-0002yc-RQ for bug-gnu-emacs@gnu.org; Thu, 10 Jun 2021 13:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lrONV-0006UJ-Jw for bug-gnu-emacs@gnu.org; Thu, 10 Jun 2021 13:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Jun 2021 17:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47408 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47408-submit@debbugs.gnu.org id=B47408.162334567024877 (code B ref 47408); Thu, 10 Jun 2021 17:22:01 +0000 Original-Received: (at 47408) by debbugs.gnu.org; 10 Jun 2021 17:21:10 +0000 Original-Received: from localhost ([127.0.0.1]:37676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrOMf-0006TB-OD for submit@debbugs.gnu.org; Thu, 10 Jun 2021 13:21:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrOMc-0006SV-65 for 47408@debbugs.gnu.org; Thu, 10 Jun 2021 13:21:08 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60380) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrOMV-0002ZO-Jl; Thu, 10 Jun 2021 13:20:59 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4145 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrOMV-00055d-6f; Thu, 10 Jun 2021 13:20:59 -0400 In-Reply-To: (message from fabrice nicol on Thu, 10 Jun 2021 18:52:49 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:208333 Archived-At: > Cc: 47408@debbugs.gnu.org > From: fabrice nicol > Date: Thu, 10 Jun 2021 18:52:49 +0200 > > your latest fix for Mercury 'etags' support has introduced a regression > for existentially quantified predicates. Is it a "regression" in the sense that "M-." no longer finds the definitions? > These predicates have the following (somewhat simplified) syntax (in > extended regexp  form, \s for white space): > > :-[:blank:]+some[:blank:]*\[[:blank:]*T(,[:blank:]*[:upper:]{1})*[:blank:]*\][:blank:]+pred[:blank:]+([:lower:]+([:alnum:]|[:punct:])*)+[:blank:]*\([^()]+\)([:blank:]|[:lower:])*\. > > Example: > > :- some [T] pred unravel_univ(univ::in, T::out) is det. > > Your fix incorrectly outputs such quantified predicates. For example on > tagging univ.m (attached), your commit version yields: > > > :- some [T] pred unravel_univ(^?[T] pred unravel_univ^A141,4333 > > > whilst my original code yields the correct tag: > > > :- some [T] pred unravel_univ(^?141,4333 Why do you think the current result is incorrect, while the previous result was correct? > In other words, 'pred unravel_univ' is wrongly repeated in your latest > commit. It isn't "wrongly repeated". TAGS files support 2 different ways of specifying a tag: implicitly named or explicitly named. The "repeated name" form is the latter; it should be used whenever the NAME argument passed to make_tag includes characters that etags.el doesn't expect to find in an identifier; see the function notinname and the comments before make_tag. It should have been the job of mercury_pr to find the identifier itself within the line whose pointer it accepts as S, and pass only that to make_tag as NAME/NAMELEN arguments. I made a step in that direction, but it turns out I didn't go far enough. Feel free to propose improvements to the code I installed so as to identify the name of the identifier and nothing else, as other callers of make_tag do. > The issue seems to be located at the patch line below: > > > + char *name = skip_non_spaces (s + len0); The only problem with the above line is that it assumes there's only one non-space "word" before the identifier proper, whereas the example you show makes it clear there could be more than one. Which means the code might need to repeatedly skip these non-identifier words until we exhaust them all. I will look into fixing that (but I really prefer that you do it in my stead, as I don't know enough about the Mercury's syntax). But other than that, the changes I installed are IMO a step in the right direction: your original code incorrectly passed to make_tag the same arguments as both NAME and LINESTART, and passed zero as NAMELEN, which was the immediate reason why ctags didn't output anything for Mercury sources. Please compare the way you called make_tag with how the rest of the code calls that function. > Pending a more accurate 'fix for the fix', it would probably be wiser to > revert to original code, as it - at least - gives a correct output for > 'etags' invocation. The original code was incorrect, so it doesn't sound right to me to revert to it. I will work on fixing the cases you described (unless you beat me to it). Thanks for turning my attention to this issue.