0

I'm struggling with Xref M-? finding references to symbols (C-code). It doesn't work for (e)tags nor for any symbol even in the buffered file. The Xref window/buffer with results is not opened instead an error-message ist displayed in the minibuffer 'No references found for: ' The strange thing is: M-. works perfectly!

emacs-version 26.3, Windows 7 (on Macintosh the same Emacs version has no such problem)

Is there anything missing under Windows, which is needed for Xref?

Output of functions: (project-roots (project-current)) "Minbuffer: No applicable method: project-roots, nil"

(insert (format " >%s<" (semantic-symref-detect-symref-tool))) >grep<

7
  • Please elaborate - specify what you mean by "doesn't work". The question so far risks being deleted as underspecified. Thx.
    – Drew
    Aug 4, 2020 at 15:28
  • Could you evaluate this? What does it return: (project-root (project-current)).
    – Dmitry
    Aug 4, 2020 at 15:50
  • And this: (semantic-symref-detect-symref-tool).
    – Dmitry
    Aug 4, 2020 at 15:51
  • It doesn't open the Xref-buffer with results, instead an error message in minibuffer is displayed like 'no refrences found', but there are, even in the actual buffer, where it was called from. Sorry i'm not on the Windows-machine now, i will check Dimitry's suggestions, when on the machine again.
    – chris-tian
    Aug 4, 2020 at 18:10
  • Don't complete your question with comments: edit your question instead.
    – Stefan
    Aug 4, 2020 at 19:50

2 Answers 2

0

Try downloading grep.exe, find.exe and xargs.exe and putting them somewhere in PATH.

Last I checked, https://sourceforge.net/projects/ezwinports/ had good binaries for MS Windows.

4
  • I've copied the GnuWin utilities findutils, grep, pcre to the Windows-machine and put them to the PATH but Xref still complains, that it can't find any symbol. When I try to start 'grep' and 'find' from the shell, the tools could be found. Hmmm...
    – chris-tian
    Aug 5, 2020 at 16:47
  • Rgrep also does not work as expected. Grep exits with code 2 on Windows. That is (part) of the constructed command: Confirm: find . -type d "(" ... -o -path "/{arch}" ")" -prune -o ^"^!^" -type d "(" ... -o -name ".pyo" ")" -prune -o -type f "(" -iname "*.[ch]" ")" -exec grep --color=always -n --null -e "SafeTLib_ErrorData" "{}" NUL ";" Could it be a PATH-priority problem? I think Windows has also a find. I can not change the system PATH, because I have no admin rights. So i try to put find in the emacs/bin...
    – chris-tian
    Aug 5, 2020 at 17:23
  • Still does not work. For the next try i will modify the exec-path. Maybe this helps...
    – chris-tian
    Aug 5, 2020 at 17:33
  • What happens if you run the same command from the command line? Just exit code 2, no extra error message?
    – Dmitry
    Aug 7, 2020 at 0:16
0

The problem is really because of grep and find missing on the Windows-system. You need the GnuWin or equivalent tools on the Windows-system. That is the easy part. I took GnuWin findutils, grep and pcre. Afterwards they must be added to the environment variable PATH. Which is also not a problem and won't need any further work, if there wasn't the fact, that Windows also comes with a 'find' which isn't compatible with the GNU-version. So you have to make sure, that the GNU-find comes first. Without admin rights or 'batching' impossible on Windows (my knowledge).

Emacs has it's own search-path called exec-path, which is at start a copy of the components of PATH. I decided to adapt my configuration file to extend both by placing the search-tools before anything else, for PATH and for exec-path:

 (cond
   ((string-equal system-type "windows-nt")  
     (setq lh-add-path '("C:/Users/user/app/findutils/bin"
                         "C:/Users/user/app/grep/bin"
                         "C:/Users/user/app/pcre/bin"))
     (setq exec-path (append lh-add-path exec-path))
     (setq lh-tmp-path "")
     (while lh-add-path
       (setq lh-tmp-path (concat lh-tmp-path (format "%s;" (car lh-add-path))))
     (setq lh-add-path (cdr lh-add-path)))
     (setq lh-tmp-path (replace-regexp-in-string "/" "\\\\" lh-tmp-path))
     (setenv "PATH" (concat lh-tmp-path (getenv "PATH")))))
1
  • You can also try this: rename find.exe to gfind.exe, then customize find-program to "gfind.exe". And restart Emacs.
    – Dmitry
    Aug 7, 2020 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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