Subject: Re: bug#75946: [PATCH] Avoid infinite questions if TAGS file was removed

From: Eli Zaretskii <[email-masked]>
Date: Sat, 01 Feb 2025 12:03:28 +0200

> From: Konstantin Kharlamov <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 30 Jan 2025 18:44:31 +0300
> 
> On Thu, 2025-01-30 at 17:37 +0200, Eli Zaretskii wrote:
> > > From: Konstantin Kharlamov <[email-masked]>
> > > Date: Thu, 30 Jan 2025 17:16:13 +0300
> > >
> > > When the visited TAGS file was removed, commands that depend on
> > > TAGS
> > > such as auto-completion may invoke an interactive question whether
> > > a
> > > user wants to re-read the file.  From that point on, the question
> > > will
> > > be asked over and over, because the file no longer exists, which
> > > results in mtime mismatch and inability to "fix the mismatch" by
> > > reading from the file.  Fix that by simply ignoring the mismatch if
> > > the file no longer exists.
> >
> > Thanks, but can you please show a recipe, starting from "emacs -Q",
> > which could be used to reproduce this problem?
> 
> Sure. Idk of any Emacs tags auto-completion functions, but I don't it's particularly
> important in the context. I use below a `(tags-completion-table)` instead.
> 
> 1. Create empty tags `touch /tmp/TAGS`
> 2. Launch Emacs with `emacs -Q --eval '(visit-tags-table "/tmp/TAGS")'`
> 3. Remove the tags: `rm /tmp/TAGS`
> 4. In Emacs evaluate `(tags-completion-table)`
> 
> You'll get the question if you want to re-read from TAGS file, and disregarding
> whether you reply "yes" or "no", each time you execute `(tags-completion-table)`
> again you'll get the prompt again and again.

When I repeat these steps, Emacs signals an error:

  (error "File .../TAGS no longer exists!")

This comes from revert-buffer, called by tags-verify-table.  I wonder
why you see something different.

> In autocompletion context it results in complete inability type text, because the
> user gets spammed by the prompt on every letter.

Maybe the autocompletion runs with ignore-errors or something?

As for your patch: verify-visited-file-modtime returns t for files
that never existed -- is that case covered by the patch?  Maybe we
should text file-exists-p before calling verify-visited-file-modtime?