GNU logs - #37862, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.
Resent-From: Hong Xu <hong@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 22 Oct 2019 03:14:03 +0000
Resent-Message-ID: <handler.37862.B.157171398430368 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 37862
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: 37862 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.157171398430368
          (code B ref -1); Tue, 22 Oct 2019 03:14:03 +0000
Received: (at submit) by debbugs.gnu.org; 22 Oct 2019 03:13:04 +0000
Received: from localhost ([127.0.0.1]:58124 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iMkbX-0007tk-NJ
	for submit <at> debbugs.gnu.org; Mon, 21 Oct 2019 23:13:03 -0400
Received: from lists.gnu.org ([209.51.188.17]:41407)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <hong@HIDDEN>) id 1iMkbW-0007tT-Bi
 for submit <at> debbugs.gnu.org; Mon, 21 Oct 2019 23:13:02 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45886)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <hong@HIDDEN>) id 1iMkbV-0003Vk-0a
 for bug-gnu-emacs@HIDDEN; Mon, 21 Oct 2019 23:13:02 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <hong@HIDDEN>) id 1iMkbS-0004TD-HS
 for bug-gnu-emacs@HIDDEN; Mon, 21 Oct 2019 23:13:00 -0400
Received: from sender4-of-o54.zoho.com ([136.143.188.54]:21475)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <hong@HIDDEN>) id 1iMkbR-0004RH-9T
 for bug-gnu-emacs@HIDDEN; Mon, 21 Oct 2019 23:12:58 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1571713973; cv=none; 
 d=zohomail.com; s=zohoarc; 
 b=eobJvVKaXeQVPwkJUSknik3dI5QWJbrT1qAOpQNnWkKHXz4pATaNDSQcGE7zfV9S6qvWwtJxRMYB+Eygw+RmoBl70wwduRen+prRtz0DySIEaLFGwC3YaD8pevATSJqugHrBdUJgqhGTAQg0MKx/m95LCQ7OQQln7cnyL6+0uXg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc; 
 t=1571713973; h=Content-Type:Date:From:MIME-Version:Message-ID:Subject:To; 
 bh=dbgMNXChYnV02tOF/oTxVqBTb52aded0ddyv6U2c25w=; 
 b=b2jPlq9j1Wao8BIRokKOm5KaXJhjN8V0VfY/3SE98kfMUG5QH/n5RzroRIAs+4QARq+negcZTs3F+9kNlKjLvFhMTFv3qlDSe99004KKFAC2eL/BfFZSg/X5v4IxA6MiE3RrfYox6kEQi3TrRMH32FHRbFU8LOj312yZDhrx1E0=
ARC-Authentication-Results: i=1; mx.zohomail.com;
 dkim=pass  header.i=topbug.net;
 spf=pass  smtp.mailfrom=hong@HIDDEN;
 dmarc=pass header.from=<hong@HIDDEN> header.from=<hong@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1571713973; 
 s=zoho; d=topbug.net; i=hong@HIDDEN;
 h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type;
 l=1400; bh=dbgMNXChYnV02tOF/oTxVqBTb52aded0ddyv6U2c25w=;
 b=eygDlBn/427LSbnEHcaUm/v6jpHNLLRdKiO4QLATqGTEZVJn1Sa8/wNXL84jcSSo
 8sUJVv/YOaTWZ9IGvnVcKO2WxEmMDegyOzqDXETAXJh3v/4BOfvYGW6Yz19NO5YH0JE
 4clT8iWYwBfhy70/DRZ6LtmhyR1+MMUpIdCcQAJs=
Received: from home (69-215-149-151.lightspeed.sntcca.sbcglobal.net
 [69.215.149.151]) by mx.zohomail.com
 with SMTPS id 1571713971547434.48002720750753;
 Mon, 21 Oct 2019 20:12:51 -0700 (PDT)
From: Hong Xu <hong@HIDDEN>
Date: Mon, 21 Oct 2019 20:12:51 -0700
Message-ID: <87r235scb0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-ZohoMailClient: External
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 136.143.188.54
X-Spam-Score: -1.3 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


* lisp/progmodes/cc-mode.el (c-or-c++-mode): Add check for the
existence of alternative C++ source files.
---
 lisp/progmodes/cc-mode.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 6bdfb170f1ba..940bd4be3f92 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2492,16 +2492,23 @@ c-or-c++-mode
 matching on file name insufficient for detecting major mode that
 should be used.
 
-This function attempts to use file contents to determine whether
-the code is C or C++ and based on that chooses whether to enable
-`c-mode' or `c++-mode'."
-  (if (save-excursion
+This function attempts to use file contents and the existence of
+alternative C++ source files to determine whether the code is C
+or C++ and based on that chooses whether to enable `c-mode' or
+`c++-mode'."
+  (if (or
+       (save-excursion
         (save-restriction
           (save-match-data
             (widen)
             (goto-char (point-min))
             (re-search-forward c-or-c++-mode--regexp
                                (+ (point) c-guess-region-max) t))))
+       ;; We could have gone through auto-mode-alist here, but it
+       ;; might be too slow.
+       (let ((base-name (file-name-sans-extension (buffer-file-name))))
+	 (seq-find (lambda (ext) (file-exists-p (concat base-name ext)))
+		   '(".cc" ".cpp" ".cxx" ".c++"))))
       (c++-mode)
     (c-mode)))
 
-- 
2.20.1






Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Hong Xu <hong@HIDDEN>
Subject: bug#37862: Acknowledgement ([PATCH] Use alternative C++ source
 files for determining C/C++ header files.)
Message-ID: <handler.37862.B.157171398430368.ack <at> debbugs.gnu.org>
References: <87r235scb0.fsf@HIDDEN>
X-Gnu-PR-Message: ack 37862
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 37862 <at> debbugs.gnu.org
Date: Tue, 22 Oct 2019 03:14:03 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 37862 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
37862: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D37862
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 26 Oct 2019 11:07:01 +0000
Resent-Message-ID: <handler.37862.B37862.1572088021385 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 37862
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Hong Xu <hong@HIDDEN>, Alan Mackenzie <acm@HIDDEN>
Cc: 37862 <at> debbugs.gnu.org
Received: via spool by 37862-submit <at> debbugs.gnu.org id=B37862.1572088021385
          (code B ref 37862); Sat, 26 Oct 2019 11:07:01 +0000
Received: (at 37862) by debbugs.gnu.org; 26 Oct 2019 11:07:01 +0000
Received: from localhost ([127.0.0.1]:39754 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iOJuO-000069-Lx
	for submit <at> debbugs.gnu.org; Sat, 26 Oct 2019 07:07:00 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52878)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iOJuM-00005n-VW
 for 37862 <at> debbugs.gnu.org; Sat, 26 Oct 2019 07:06:59 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39712)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iOJuH-0003MK-GC; Sat, 26 Oct 2019 07:06:53 -0400
Received: from [176.228.60.248] (port=2793 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iOJuF-0002s9-PP; Sat, 26 Oct 2019 07:06:53 -0400
Date: Sat, 26 Oct 2019 14:06:39 +0300
Message-Id: <83eeyzvk8w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-reply-to: <87r235scb0.fsf@HIDDEN> (message from Hong Xu on Mon, 21 Oct
 2019 20:12:51 -0700)
References: <87r235scb0.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Hong Xu <hong@HIDDEN>
> Date: Mon, 21 Oct 2019 20:12:51 -0700
> 
> 
> * lisp/progmodes/cc-mode.el (c-or-c++-mode): Add check for the
> existence of alternative C++ source files.

Thanks.

Alan, are you looking at this?
 




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.
Resent-From: Alan Mackenzie <acm@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 26 Oct 2019 15:20:02 +0000
Resent-Message-ID: <handler.37862.B37862.15721031661486 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 37862
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 37862 <at> debbugs.gnu.org, Hong Xu <hong@HIDDEN>
Received: via spool by 37862-submit <at> debbugs.gnu.org id=B37862.15721031661486
          (code B ref 37862); Sat, 26 Oct 2019 15:20:02 +0000
Received: (at 37862) by debbugs.gnu.org; 26 Oct 2019 15:19:26 +0000
Received: from localhost ([127.0.0.1]:41334 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iONqg-0000Nu-FQ
	for submit <at> debbugs.gnu.org; Sat, 26 Oct 2019 11:19:26 -0400
Received: from colin.muc.de ([193.149.48.1]:52857 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iONqe-0000Nf-4y
 for 37862 <at> debbugs.gnu.org; Sat, 26 Oct 2019 11:19:24 -0400
Received: (qmail 35913 invoked by uid 3782); 26 Oct 2019 15:19:22 -0000
Received: from acm.muc.de (p2E5D5144.dip0.t-ipconnect.de [46.93.81.68]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 26 Oct 2019 17:19:20 +0200
Received: (qmail 22051 invoked by uid 1000); 26 Oct 2019 15:19:20 -0000
Date: Sat, 26 Oct 2019 15:19:20 +0000
Message-ID: <20191026151920.GE17424@ACM>
References: <87r235scb0.fsf@HIDDEN>
 <83eeyzvk8w.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83eeyzvk8w.fsf@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Oct 26, 2019 at 14:06:39 +0300, Eli Zaretskii wrote:
> > From: Hong Xu <hong@HIDDEN>
> > Date: Mon, 21 Oct 2019 20:12:51 -0700


> > * lisp/progmodes/cc-mode.el (c-or-c++-mode): Add check for the
> > existence of alternative C++ source files.

> Thanks.

> Alan, are you looking at this?

Yes, I've been thinking about it for a few days, now.

I think what we could do with is a function `auto-mode' which, given a
file name, would return the corresponding major mode as recorded in
auto-mode-alist.  At the moment, this functionality is a part of
set-auto-mode, making it more difficult for other functions to do the
same thing.  It shouldn't be difficult.

-- 
Alan Mackenzie (Nuremberg, Germany).




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.
Resent-From: Alan Mackenzie <acm@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 27 Oct 2019 13:31:01 +0000
Resent-Message-ID: <handler.37862.B37862.157218304529904 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 37862
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Hong Xu <hong@HIDDEN>
Cc: 37862 <at> debbugs.gnu.org
Received: via spool by 37862-submit <at> debbugs.gnu.org id=B37862.157218304529904
          (code B ref 37862); Sun, 27 Oct 2019 13:31:01 +0000
Received: (at 37862) by debbugs.gnu.org; 27 Oct 2019 13:30:45 +0000
Received: from localhost ([127.0.0.1]:41798 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iOid2-0007mF-RO
	for submit <at> debbugs.gnu.org; Sun, 27 Oct 2019 09:30:45 -0400
Received: from colin.muc.de ([193.149.48.1]:63743 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iOid0-0007m5-G9
 for 37862 <at> debbugs.gnu.org; Sun, 27 Oct 2019 09:30:43 -0400
Received: (qmail 47103 invoked by uid 3782); 27 Oct 2019 13:30:40 -0000
Received: from acm.muc.de (p2E5D5E17.dip0.t-ipconnect.de [46.93.94.23]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Sun, 27 Oct 2019 14:30:38 +0100
Received: (qmail 28236 invoked by uid 1000); 27 Oct 2019 13:30:38 -0000
Date: Sun, 27 Oct 2019 13:30:38 +0000
Message-ID: <20191027133038.GA27906@ACM>
References: <87r235scb0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <87r235scb0.fsf@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Hong.

On Mon, Oct 21, 2019 at 20:12:51 -0700, Hong Xu wrote:

> * lisp/progmodes/cc-mode.el (c-or-c++-mode): Add check for the
> existence of alternative C++ source files.
> ---
>  lisp/progmodes/cc-mode.el | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)

> diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
> index 6bdfb170f1ba..940bd4be3f92 100644
> --- a/lisp/progmodes/cc-mode.el
> +++ b/lisp/progmodes/cc-mode.el
> @@ -2492,16 +2492,23 @@ c-or-c++-mode
>  matching on file name insufficient for detecting major mode that
>  should be used.
 
> -This function attempts to use file contents to determine whether
> -the code is C or C++ and based on that chooses whether to enable
> -`c-mode' or `c++-mode'."
> -  (if (save-excursion
> +This function attempts to use file contents and the existence of
> +alternative C++ source files to determine whether the code is C
> +or C++ and based on that chooses whether to enable `c-mode' or
> +`c++-mode'."
> +  (if (or
> +       (save-excursion
>          (save-restriction
>            (save-match-data
>              (widen)
>              (goto-char (point-min))
>              (re-search-forward c-or-c++-mode--regexp
>                                 (+ (point) c-guess-region-max) t))))
> +       ;; We could have gone through auto-mode-alist here, but it
> +       ;; might be too slow.
> +       (let ((base-name (file-name-sans-extension (buffer-file-name))))
> +	 (seq-find (lambda (ext) (file-exists-p (concat base-name ext)))
> +		   '(".cc" ".cpp" ".cxx" ".c++"))))
>        (c++-mode)
>      (c-mode)))
 
> -- 
> 2.20.1

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.

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).

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.

-- 
Alan Mackenzie (Nuremberg, Germany).




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37862: [PATCH] Use alternative C++ source files for determining C/C++ header files.
Resent-From: Hong Xu <hong@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 27 Oct 2019 20:32:02 +0000
Resent-Message-ID: <handler.37862.B37862.15722083018862 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 37862
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alan Mackenzie <acm@HIDDEN>
Cc: 37862 <at> debbugs.gnu.org
Received: via spool by 37862-submit <at> debbugs.gnu.org id=B37862.15722083018862
          (code B ref 37862); Sun, 27 Oct 2019 20:32:02 +0000
Received: (at 37862) by debbugs.gnu.org; 27 Oct 2019 20:31:41 +0000
Received: from localhost ([127.0.0.1]:43581 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iOpCO-0002Iq-QJ
	for submit <at> debbugs.gnu.org; Sun, 27 Oct 2019 16:31:41 -0400
Received: from sender4-of-o54.zoho.com ([136.143.188.54]:21492)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <hong@HIDDEN>) id 1iOpCL-0002Ia-44
 for 37862 <at> debbugs.gnu.org; Sun, 27 Oct 2019 16:31:38 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1572208294; cv=none; 
 d=zohomail.com; s=zohoarc; 
 b=UL+DOvEDw1vOsRMvQSoMYXXBMuDl4bP1ta3RHDsIqQdZMyPU2DQWFac+DXJqfKXm6tLrPKw32o0tMOmUK2tAWQNi6e3mmJd+bTfrV2rTXCNYOFf7YyWUJU37CVbTkwzZfK6UpiSIPjxNppi572N8bHw0pJBvHX+ZvIyOAwvcjUg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc; t=1572208294;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To;
 bh=vSHJb4v52vrPaTvekFFa+3c3Gc1/lEvy8015bfMaBxE=; 
 b=IqPT4an2sC3yvBUDf7pHjvLYVLAkQFY8yRiNbmCY/r19EWHBgWSemYV6+l1ATpsa9W3+F92I9Nmj20yTIwQjQ2gVFajxktF1UKzvgEWpDALvK/6TQxE7nufFBNd1AM5NxQMfIQgznEcwRWY43AulpHvfBxzlCNse7oKJ9oiGWDo=
ARC-Authentication-Results: i=1; mx.zohomail.com;
 dkim=pass  header.i=topbug.net;
 spf=pass  smtp.mailfrom=hong@HIDDEN;
 dmarc=pass header.from=<hong@HIDDEN> header.from=<hong@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1572208294; 
 s=zoho; d=topbug.net; i=hong@HIDDEN;
 h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 l=1334; bh=vSHJb4v52vrPaTvekFFa+3c3Gc1/lEvy8015bfMaBxE=;
 b=Ul1ZKlkOb4Yp62MevGaFfdrfcFXCRil9whzWYbMA4w6SAKwkq8dZon9dMy+H1g/s
 P+TKe/UnlQpJLVJawVSnB6aWu67qLKA/KNdlCQUbo9z1y8Mm1FGNntem1JLLGmzyHtU
 BabwsQQm0WG9PgIn/CdGne0dALOZ85boTt/2ntRk=
Received: from [192.168.88.88] (69-215-149-151.lightspeed.sntcca.sbcglobal.net
 [69.215.149.151]) by mx.zohomail.com
 with SMTPS id 1572208294404234.7524913405265;
 Sun, 27 Oct 2019 13:31:34 -0700 (PDT)
References: <87r235scb0.fsf@HIDDEN> <20191027133038.GA27906@ACM>
From: Hong Xu <hong@HIDDEN>
Openpgp: preference=signencrypt
Message-ID: <89b138ad-e044-d117-e26f-414d29ca7732@HIDDEN>
Date: Sun, 27 Oct 2019 13:31:33 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.9.0
MIME-Version: 1.0
In-Reply-To: <20191027133038.GA27906@ACM>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-ZohoMailClient: External
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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.





Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 8 Nov 2019 01:07:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 07 20:07:17 2019
Received: from localhost ([127.0.0.1]:44195 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iSsk9-0002Z0-Bq
	for submit <at> debbugs.gnu.org; Thu, 07 Nov 2019 20:07:17 -0500
Received: from host.gofardesign.uk ([208.79.239.190]:40683)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefan@HIDDEN>) id 1iSsk7-0002Yi-Mc
 for control <at> debbugs.gnu.org; Thu, 07 Nov 2019 20:07:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; 
 s=default;
 h=Subject:From:To:Date:Sender:Reply-To:Message-ID:Cc:MIME-Version
 :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=iFTWZr249Iwej09CP93MWhhJ1FE5LAD1AhOY0Wh9YXY=; b=i+J9cPPYVIJJNva3+O+Sbpgvl7
 rUFn2+7+3jqsQUFwuakcA9p/i57AqnKDkLL5n/VsUiOIMS6tH3SKvpfSW5Nu4mH4KNAOvTnKF7GIq
 /+6oOiFK1GIpGdlJysHfxKhpmaeLsRuKfbNwgLh1q+vcR0eiV4BmAScg/r7Z0fOtaMDo=;
Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:50176
 helo=localhost)
 by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 (Exim 4.92) (envelope-from <stefan@HIDDEN>) id 1iSsk2-0001Uw-11
 for control <at> debbugs.gnu.org; Thu, 07 Nov 2019 19:07:10 -0600
Date: Fri, 08 Nov 2019 02:07:08 +0100
To: control <at> debbugs.gnu.org
From: Stefan Kangas <stefan@HIDDEN>
Subject: control message for bug #37862
X-OutGoing-Spam-Status: No, score=-1.0
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - host.gofardesign.uk
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - marxist.se
X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id:
 stefan@HIDDEN
X-Authenticated-Sender: host.gofardesign.uk: stefan@HIDDEN
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Message-Id: <E1iSsk9-0002Z0-Bq <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

reassign 37862 emacs,cc-mode
quit





Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 27 Feb 2020 02:22:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 26 21:22:25 2020
Received: from localhost ([127.0.0.1]:57986 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1j78oj-0002JQ-Gn
	for submit <at> debbugs.gnu.org; Wed, 26 Feb 2020 21:22:25 -0500
Received: from mail-qv1-f51.google.com ([209.85.219.51]:36989)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1j78oi-0002JC-R5
 for control <at> debbugs.gnu.org; Wed, 26 Feb 2020 21:22:25 -0500
Received: by mail-qv1-f51.google.com with SMTP id ci20so845341qvb.4
 for <control <at> debbugs.gnu.org>; Wed, 26 Feb 2020 18:22:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:mime-version;
 bh=QE059cK+WU7bHEf3MpiTL9JyOnmqFlNW7trdjDp94vA=;
 b=e5sVEzHVHKCK1gCKIZfDPUU8tRXfvB0go9NctKR9WTXdT8GB0/FlJ1gIpXM+bqT3m3
 r6d46w4o75flrX4VvptOGzTFJP+UHEmnGWeckHFzL1MjugqrzxMD+3euAWIAwpKy6VjE
 4H3NGJeAzb9fZxNi1qPcwroe2eGf0w0udeoCe2d2R1FXxapCdlIkyRgutrzStGmyd4ie
 Ft61ZS9sKwEugqM345TBhrPHrpIyD5x4Vzx5oCTSztQQVU4fb+um0AlQ/lF/UyFKXml6
 d+XqbwQsM7Il0C5Wi8ebZWOb5rQBZxXaEVqJjpSdEtTej7Rc1/VtiB61ObAWgMxCHZfw
 cx+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version;
 bh=QE059cK+WU7bHEf3MpiTL9JyOnmqFlNW7trdjDp94vA=;
 b=l9uez8GIqNEXxCl42OLtc3zLhUsFDuBXZdeAMm55ns2MjoV5o9nyg6doTJvgBCRPnb
 Ff9jGNY0l0sVsMLceA8Tekzc9ZZIHBycEog1j6UWTOck4kD7RWdlJGNunuEKIBHgQHsg
 wzosMh+fqpTGXkRdmH+7FFezt4tJwyUVlxKoHAWNuS49C0poQpmvJlmoi3/Ty7juYaAS
 MXZ+sQdrv5oTzG4KdnEeFvj41xGkGtCbOTOqlhCxYTNMMRNARlUKi/1YcykogPpisgHA
 mVSzqqswAdfsJEi7uQu1FChVM7EO5rnwVOFF3M8terQs8mkcr4j+oS4BbcDAL4S0udru
 JwnQ==
X-Gm-Message-State: APjAAAWqqrSymnaUZrNcbpCUfYaZFs2w8k960BDG7cJ2vJ7GcpSlyPO7
 TUxFuZ1NIN5dQcytQa9txku96QFcgcY=
X-Google-Smtp-Source: APXvYqxNKvocV7IH/TprJO2i5sOo4QS7VWPKsiIUlJh2u+kyKjzzKMs70gQyIG4w8xu90GZvm84Lgg==
X-Received: by 2002:a0c:a998:: with SMTP id a24mr2352553qvb.11.1582770139190; 
 Wed, 26 Feb 2020 18:22:19 -0800 (PST)
Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47])
 by smtp.gmail.com with ESMTPSA id
 b23sm932510qkc.39.2020.02.26.18.22.18 for <control <at> debbugs.gnu.org>
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Wed, 26 Feb 2020 18:22:18 -0800 (PST)
From: Noam Postavsky <npostavs@HIDDEN>
To: control <at> debbugs.gnu.org
Subject: control message for bug #0
Date: Wed, 26 Feb 2020 21:22:18 -0500
Message-ID: <87mu94ahwl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

severity 37862 wishlist
quit






Last modified: Thu, 27 Feb 2020 02:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.