Subject: bug#70329: 29.3; etags-regen-mode fails in projects that have spaces in their root path elements

From: Eli Zaretskii <[email-masked]>
Date: Thu, 11 Apr 2024 10:29:43 +0300

> Date: Wed, 10 Apr 2024 21:32:57 +0200
> From:  Magiel Bruntink via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> I wanted to try to the new etags-regen-mode and loaded its lisp manually.
> 
> There is an issue with how the new mode deals with paths containing spaces,
> however.
> 
> Running the etags--xref-backend through eg. xref-find-definitions
> within a file in a project that has spaces in its path elements,
> eg. "c:/temp/test project/test.c" will cause an error.
> 
> Messages seen are:
> Generating new tags table...
> (Shell command failed with code 1 and some error output)
> visit-tags-table-buffer: File c:/temp/test project/TAGS does not exist
> 
> Error message in the etags-regen-tags-errors* buffer:
> c:/temp/test: Permission denied

Stab in the dark: does the patch below fix the problem?

If not, please repeat your recipe with debug-on-error non-nil, and
post the backtrace here.

diff --git a/lisp/progmodes/etags-regen.el b/lisp/progmodes/etags-regen.el
index 6cd78d3..02d666c 100644
--- a/lisp/progmodes/etags-regen.el
+++ b/lisp/progmodes/etags-regen.el
@@ -279,7 +279,7 @@ etags-regen--tags-generate
                                      " ")
                           ;; ctags's etags requires '-L' for stdin input.
                           (if ctags-p "-L" "")
-                          tags-file)))
+                          (shell-quote-argument tags-file))))
     (with-temp-buffer
       (mapc (lambda (f)
               (insert f "\n"))