Subject: bug#55016: 28.1; xref-find-references finds no matches if project dir contains a space

From: Eli Zaretskii <[email-masked]>
Date: Tue, 19 Apr 2022 21:24:18 +0300

> Date: Tue, 19 Apr 2022 21:17:03 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > > Actually, one more idea: perhaps the quoting makes things first
> > > because your file names begin with "~/"?  In that case, doing
> > > something like this instead should do better:
> > >
> > >    (shell-quote-argument (expand-file-name rootdir))
> > 
> > That works! Both 'space dir' and 'nospace' dir cases work the same way now.
> 
> OK, thanks.  Now I understand what's going on, and can work on a real
> fix for Emacs 29.

Dmitry, there's something here I don't understand.  In
semantic-symref-perform-search method that uses find/grep, we do this:

    (with-current-buffer b
      (erase-buffer)
      (setq default-directory rootdir)
      (let ((cmd (semantic-symref-grep-use-template
                  (directory-file-name (file-local-name rootdir))
                  filepattern grepflags greppat)))
        (process-file semantic-symref-grep-shell nil b nil
                      shell-command-switch cmd)))

Since we bind default-directory to ROOTDIR, why do we also need to
pass ROOTDIR to semantic-symref-grep-use-template?  Why not use ".",
or even nil (which gets expanded to "." AFAIU)?  Then this entire
issue with embedded blanks in ROOTDIR would not have happened, because
the problematic directory name would not be exposed to the shell.

What am I missing here?