Daniel Wengelin <[log in to unmask]> writes:

> I have downloaded Emacs 20.2.1 and emacs-ada-mode 2.23.
> I am having problems with the Xref function. When I try to Goto Declaration of
> something, I often get the message "file C doesn't exist". It appears as if it
> only runs into trouble when the file the declaration is in has been prefixed
> with a full path by gnatf. I even get the feeling that the C in the above statement
> is the disk, as in C: (I edited the .xrb file and found that I could set it to W or anything)
> It appears as if the failing function is ada-xref-get-filename in the ada-xref.el lisp file.
> M. Laurent Guerby has inserted a cryptic comment in the code where the bug
> should be, but I fail to interpret it and with my total lack of LISP knowledge
> I cannot get any further.

This is what I have in my version of ada-xref.el:

(defun ada-xref-get-filename ()
  "Returns the name of the file where the declaration should be.
Assumes point to be on the name of the identifier in the Xref file."
    (re-search-backward "^\\(%%\\|--\\) \\([a-zA-Z0-9\\._/\\-]+\\)"
                        nil t)
;;    Laurent Guerby                                      ^^^
;    (file-name-nondirectory
     (buffer-substring (match-beginning 2)
                       (match-end 2))))

We can dissect the regexp as follows:

 "^"  means beginning of line

 "\\(%%\\|--\\) "
  means double percent or double-hyphen, followed by a space

  means one or more letters, numbers, periods, underscores, forward
  slashes, or hyphens (this is the syntax of a Unix path-name, including
  dir and file)

The (match-beginning 2) and (match-end 2) simply mean the range of text
in the second set of parens of the regexp; here, the name of the

Can you post the code that's failing?  I will try to help you.