From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#13815: Wrong mode for files with awkward shebang lines Date: Mon, 25 Feb 2013 21:59:30 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361847635 13761 80.91.229.3 (26 Feb 2013 03:00:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Feb 2013 03:00:35 +0000 (UTC) Cc: 13815@debbugs.gnu.org To: Andrew Pennebaker Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 26 04:00:58 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UAAmn-0004Tb-Qr for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Feb 2013 04:00:57 +0100 Original-Received: from localhost ([::1]:36122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAAmT-0004TS-2i for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 22:00:37 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAAmN-0004TG-1q for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 22:00:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAAmG-0003XW-16 for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 22:00:27 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAAmF-0003XH-To for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 22:00:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UAAnq-0004Oy-3S for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 22:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Feb 2013 03:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13815 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13815-submit@debbugs.gnu.org id=B13815.136184767716873 (code B ref 13815); Tue, 26 Feb 2013 03:02:01 +0000 Original-Received: (at 13815) by debbugs.gnu.org; 26 Feb 2013 03:01:17 +0000 Original-Received: from localhost ([127.0.0.1]:50248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAAn6-0004O5-QD for submit@debbugs.gnu.org; Mon, 25 Feb 2013 22:01:17 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:59793) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAAn4-0004Ny-Ms for 13815@debbugs.gnu.org; Mon, 25 Feb 2013 22:01:15 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFHO+KLv/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOIYZwZgV6DFQ X-IPAS-Result: Av4EABK/CFHO+KLv/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOIYZwZgV6DFQ X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="2460740" Original-Received: from 206-248-162-239.dsl.teksavvy.com (HELO pastel.home) ([206.248.162.239]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 25 Feb 2013 21:59:30 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 0D9056C0A9; Mon, 25 Feb 2013 21:59:30 -0500 (EST) In-Reply-To: (Andrew Pennebaker's message of "Mon, 25 Feb 2013 16:56:03 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71818 Archived-At: > This could be solved a variety of ways, but I think the simplest is to > prioritize file extension over mimetype when a file extension is available. IIRC no strict priority will do, because for some files, the content is more important than the filename. > We can't trust mimetypes for code that contains these awkward shebangs. [ FWIW Emacs doesn't actually use "mimtypes" but its own set of file-contents-based rules. Not that it matters to this discussion, really. ] I think the right way is to check both file content and file name and if the type they specify do not agree, fall back on a disambiguation function, which should include various ad-hoc rules, and may ultimately prompt the user if none of the ad-hoc rules resolved the ambiguity. But in your specific case, you might get away with tweaking inhibit-local-variables-regexps. Stefan