Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.

From: Alan Mackenzie <[email-masked]>
Date: Sat, 4 Jul 2020 17:10:22 +0000

Hello, Hong.

On Sun, Oct 27, 2019 at 13:31:33 -0700, Hong Xu wrote:
> On 10/27/19 6:30 AM, Alan Mackenzie wrote:

> > Thanks for writing this proposal.

> > I think it would be better, given a foo.h, to find all files foo.*, and
> > test each one in turn for a match in auto-mode-alist.  Searching this
> > alist is really not that slow, particularly as it is only being done a
> > few times, and not in a tight loop.

> I agree with this approach, if it would not be too slow. Perhaps we can
> set a limit on the number of files that match foo.*.

> > For this, we really want a function in the Emacs core which would find
> > the match in auto-mode-alist.  Currently, this functionality is open
> > coded in set-auto-mode (in .../lisp/files.el).

> I like the idea to create a separate function that provides this
> feature. Do you mean it's somewhat buried in `set-auto-mode'? It's
> probably also useful in other places.

> > However, I'm a bit sceptical about the use of this proposed facility.
> > Many projects (possibly most) have .c/.c++ files in a directory called
> > "src", and .h files in a separate directory called "include".  This
> > proposed facility wouldn't work in such a set up.  To extend it to cope
> > with separate "src"/"include" directories would make it messy.

> This is true; but I think no guessing is perfect. At least the proposed
> solution should help with some smaller projects.

After thinking it over for some time, I'm sorry to say I've decided not
to commit your change to Emacs.  I think the disadvantages would
outweigh the advantages.

But again, thanks for taking the trouble to post the idea on the buglist.

-- 
Alan Mackenzie (Nuremberg, Germany).