One way to look into the source code of any function in Emacs is to use the M-. (find tag). When I do this in Windows platform Emacs 24 I get Find tag: in the minibuffer asking to enter the name of a function like for example, forward-paragraph function I don't get any. It seems there is no TAGS file there. When I wanted to create one, using M-x compile RET etags *.el RET, of no avail. Can you pls help me figure out what is the right way to get TAGS file in Windows?

I managed to make TAGS file in c:\GNU Emacs 24.3\ from Windows Terminal: etags -o c:\GNU Emacs 24.3\TAGS c:/GNU Emacs 24.3/lisp/*.el. After some googling, and the -o option is to tell where to write the generated TAGS file (destination). But, first as nanny pointed out, this should be run where etags.exe file resides. So I ran this from the c:\GNU Emacs 24.3\bin\. My questions:

  • Where to put the TAGS file, what is the best practice?

  • Why pressing M-.: find tag, then asks about table tags and I should point out to same dir where TAGS is, that is too much, how to make emacs automatically recognize TAGS?

  • Even after finding TAGS by emacs, the function forward-paragraph was not among the completion items? How to cover all .el files given a default dir structure of Emacs in Windows platform?

  • I found beside etags there is exuberant ctags, which one is better in Windows?

  • 1
    What do you mean "of no avail"? What happens? Any errors? – nanny Nov 10 '14 at 19:54
  • I still cannot use the find-tag. – doctorate Nov 10 '14 at 20:05
  • 1
    You need to be more description of your problem. Why can't you use find-tag? Does running the command do nothing? Is it giving you an error? Is it telling you to select a tags table? Or what? – nanny Nov 10 '14 at 20:10
  • I updated the post, pls don't make any assumptions, I am new to Emcas. – doctorate Nov 10 '14 at 20:17
  • 1
    I suggest trying the Windows port of exuberant ctags (run it with the -e argument to get Emacs-compatible output) which (a) tends to be better than the GNU etags binary, and (b) can do recursive processing on its own (with the -R argument), without you needing to use find (which is another pitfall on Windows) to walk the directory tree. – phils Nov 10 '14 at 20:54

If you use Cygwin, just download Exuberant Ctags and compiled then install it; or install via Cygwin installer. Then, you can simply run:

ctags -e -R 

At your project root to generate Emacs-compatible TAGS file for your project.

  • ok, I have a problem after tag-find: whatever function entered after completion, it returns this message: File c:/emacs/lisp/button.el (with or without extensions ( .Z .bz2 .gz .xz .tgz)) not found how to fix? – doctorate Nov 11 '14 at 17:49
  • 1
    Your Emacs is missing that file. I suggest you use this 64 bit Windows build. – Tu Do Nov 11 '14 at 17:58

etags can't find any *.el files because there are none in the directory that you ran it in (see, the compile command says: default-directory "~/"). etags is not recursive. If you'd like it to be, you need to pass it file names like this:

dir /b /s *.el | etags

Or on Unix-like systems/with find:

find . -type f -iname "*.el" | xargs etags --append

See also: http://www.emacswiki.org/emacs/BuildTags

  • in using terminal: I got this message: c:\GNU Emacs 24.3> dir /b /s *.el | etags dir /b /s *.el | etags 'etags' is not recognized as an internal or external command, operable program or batch file. – doctorate Nov 10 '14 at 20:50
  • I've just noticed that you skipped the compile command, right? – doctorate Nov 10 '14 at 20:53
  • You can put it in your compile command. But first, you have to figure out in which directory all these *.el are in. Then, use the dir command in that directory. Like: dir /b /s /path/to/emacs/src/*.el For instance using my Emacs source directory, the command would be: dir /b /s C:\Users\nanny\emacs-25.0.50-windows-x64\share\emacs\25.0.50\lisp\*.el | etags. – nanny Nov 10 '14 at 20:53
  • Compile just runs a shell command. You can use this dir ... | etags in compile if you want. This will generate a TAGS file in the directory you pass to dir. – nanny Nov 10 '14 at 20:54
  • The reason you got 'etags' is not recognized as an internal or external command, operable program or batch file. is because etags is not in your PATH. You'll need to add it to your path (use Google) or specify the full file path to etags.exe. In your case I assume it would be C:\GNU Emacs 24.3\bin\etags.exe. – nanny Nov 10 '14 at 20:58

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.