Subject: bug#36828: 27.0.50; Uninstalled emacs shows installed documentation

From: Óscar Fuentes <[email-masked]>
Date: Mon, 28 Oct 2019 22:45:44 +0100

Eli Zaretskii <[email-masked]> writes:

>> We have plenty to choose (lib-src/emacsclient, for instance) but IMO if
>> Makefile exists in installation-directory that's a sure sign.
>
> If it is not nil, and the test of equality between srcdir and
> invocation-directory fails, then you already know that you are running
> uninstalled, but outside of the src directory.  Right?  Then you don't
> need looking for Makefile or anything else, right?

Indeed, this simple patch does the trick:

modified   src/callproc.c
@@ -1567,7 +1567,7 @@ init_callproc (void)
 
       tem = Fexpand_file_name (build_string ("NEWS"), Vdata_directory);
       if (!NILP (Fequal (srcdir, Vinvocation_directory))
-	  || NILP (Ffile_exists_p (tem)))
+	  || NILP (Ffile_exists_p (tem)) || !NILP (Vinstallation_directory))
 	{
 	  Lisp_Object newdir;
 	  newdir = Fexpand_file_name (build_string ("../etc/"), lispdir);

But then we can also get rid of

!NILP (Fequal (srcdir, Vinvocation_directory))

because that condition should always be true when Vinvocation_directory
is non-nil, right?

Actually, we can remove the `if' altogether because if we enter

  if (data_dir == 0)
    {

then we know that this is a non-installed emacs and even if we end
assigning a non-existent directory to Vdata_directory within that `if'
(for reasons I can't imagine) it is not a regression: Vdata_directory
would contain a wrong directory anyways.

All that function looks unnecessarily complex to me. It comes from a
long time ago and it smells like it didn't adapt to the availability of
new variables. I'm a bit reluctant to adding yet another condition and
cause future hackers to scratch their heads trying to figure out whas is
about with the redundant stuff.

Said that, if you don't want me to touch other parts of the function and
just add the new condition, ok. Later I'll try to adapt C-h i to show
the non-installed `dir' file.