I am using ctags to index fortran files for code navigation in Emacs with M-..

In doing so I have noticed that it doesn't recognize declarations of the form

MODULE PROCEDURE MySubroutineName   ! or

which arise when using the SUBMODULE feature.

In "https://stackoverflow.com/questions/3497538/ctags-and-fortrans-interfaces" a similar issue occurred, but there the solution was merely to enable a feature, that isn't enabled by default. For submodules no such feature exists.

Is it possible to make ctags aware of this construct?


ctags supports regular expression which could be used to parse tags.

Add below code into ~/.ctags,

--regex-fortran=/^[ \t]*MODULE[ \t]+(PROCEDURE|SUBROUTINE)[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutines/

hello.f is like,

MODULE PROCEDURE MySubroutineName1   ! or

Then run ctags -e hello.f to test.

See https://duckduckgo.com/?q=ctags+regular+expression&t=ffab&atb=v202-1&ia=web on regular expression syntax.

Please note exuberant-ctags will load ~/.ctags by default but universal-ctags loads ~/.ctags.d/*.ctags instead of ~/.ctags. So you might need run ln -s ~/.ctags ~/.ctags.d/1.ctags if you replace exuberant-ctags with universal-ctags.


The issue occurred, because ctags on my system was the "Exuberant Ctags" implementation, whose latest version is from 2009; The language feature I needed support for was standardized only in 2008.

I solved the issue by asking the administrator to install "Universal Ctags", which should be the best-maintained variant of ctags.

I'll leave this question open in the hope that someone knows a way to add support, when using a newer ctags implementation isn't possible (e.g. tight software guidelines in a company, or when encountering a feature not yet supported out of the box by any implementation).

  • Through fixing is not promised, it is worth to make an issue at u-ctags's GitHub repo page. – Masatake YAMATO Mar 6 '20 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.