[m-users.] Etags support for Mercury was merged in Emacs source code.

fabrice nicol fabrnicol at gmail.com
Mon Jun 7 00:17:52 AEST 2021


I'm glad to announce that the 'etags' capability of Emacs now supports 
Mercury (in current repository source code: 
https://github.com/emacs-mirror/emacs).

Etags support has been made available at commit 5a8a5a990ae today.

After much debating and arguing with the emacs core teams, I had to give 
up on my initially suggested Mercury-specific options (-m/-M) to enable 
or disable Prolog-style "definitions as declarations" support (see this 
thread: 
http://lists.mercurylang.org/archives/reviews/2021-March/021861.html). 
However, existing 'etags' options have been granted Mercury-specific 
meaning to achieve the same goals.  The Emacs core team wanted no 
language-specific option as a design choice.

By default, all Mercury declarations will be tagged, as Zoltan 
requested. In addition, if the option "--declarations" is added to 
command line, then predicates or functions appearing first in clauses 
will also be tagged, thereby facilitating Prolog code porting. (I find 
this extra tagging useful for standard Mercury development too, at least 
in some circumstances).

An unexpected issue arose from the fact that Objective-C has the same 
file extension .m as Mercury. I had to add a somewhat ad-hoc heuristic 
test to automatically disambiguate etags processing. It should work, but 
in the (unexpected) event of a failure, please use option 
--language=mercury.

The updated etags man page shipped with Emacs explains these amendments 
to existing etags options as follows:

"--declarations
               In C and derived languages, create tags for function 
declarations, and create tags for extern variables unless --no-globals 
is used.  In Lisp, create tags for (defvar foo) declarations.  In 
Mercury, declarations start a line with ":-" and are tagged by default.  
This option also tags predicates or functions in first rules of clauses, 
as in Prolog.

-l language, --language=language
               Parse the following files according to the given 
language.  More than one such options may be intermixed with filenames.  
Use --help to get a list of the available languages and their default 
filename extensions.   For  example,  as Mercury and Objective-C have 
same filename extension .m, a test based on contents tries to detect the 
language.  If this test fails, --language=mercury or --language=objc 
should be used."

**Limitations**

Emacs etags support does not (yet) tag:

- type constructors (with arity > 0)

- foreign pragma definitions (but this would be of limited use).


Fabrice Nicol




More information about the users mailing list