From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#19206: 25.0.50; CC Mode tracks wrong source files Date: 28 Nov 2014 22:25:42 -0000 Organization: muc.de e.V. Message-ID: <20141128222542.60510.qmail@mail.muc.de> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1417213586 6347 80.91.229.3 (28 Nov 2014 22:26:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Nov 2014 22:26:26 +0000 (UTC) Cc: 19206@debbugs.gnu.org To: Sebastian Wiesner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 28 23:26:21 2014 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 1XuTzY-0002er-5P for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Nov 2014 23:26:20 +0100 Original-Received: from localhost ([::1]:46212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuTzX-0008RS-NC for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Nov 2014 17:26:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuTzQ-0008Nc-Cr for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 17:26:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuTzL-0006IJ-TO for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 17:26:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuTzG-0006Hq-Ub; Fri, 28 Nov 2014 17:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XuTzG-0007ep-Iz; Fri, 28 Nov 2014 17:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 28 Nov 2014 22:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19206 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 19206-submit@debbugs.gnu.org id=B19206.141721354729415 (code B ref 19206); Fri, 28 Nov 2014 22:26:02 +0000 Original-Received: (at 19206) by debbugs.gnu.org; 28 Nov 2014 22:25:47 +0000 Original-Received: from localhost ([127.0.0.1]:48715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XuTz1-0007eM-Ap for submit@debbugs.gnu.org; Fri, 28 Nov 2014 17:25:47 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:19476 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XuTyx-0007e8-QI for 19206@debbugs.gnu.org; Fri, 28 Nov 2014 17:25:45 -0500 Original-Received: (qmail 60511 invoked by uid 3782); 28 Nov 2014 22:25:42 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:96715 Archived-At: Hello, Sebastian. In article you wrote: > CC Mode tracks wrong source files when a CC Mode derived mode is > installed non-interactively. The rest of your post describes your detective work to track down the problem, which is brilliant. But you haven't said what the problem itself is, at least not in high level terms. What does the file look like which does the non-interactive installation, when do you see an error, and what is this error message? > To reproduce, save the following code as `cc-miscompile.el' > (require 'package) > (require 'cc-defs) > (defun main () > (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) > (setq package-user-dir (make-temp-file "cc-miscompile" 'directory)) > (package-initialize) > (package-refresh-contents) > (package-install 'd-mode) > (require 'd-mode) > (let ((source (get (intern "c-typedef-decl-kwds" c-lang-constants) 'source))) > (message "Sources: %S" (mapcar 'car source))) > (delete-directory package-user-dir 'recursive)) > (main) > and run it with `emacs -Q --script cc-miscompile.el'. The output is as > follows (package.el output shortened for readility): > Contacting host: melpa.org:80 > Contacting host: elpa.gnu.org:80 > [?] > Sources: (d-mode cc-miscompile cc-langs) > Note that `cc-miscompile' ends up in the source list of > `c-typedef-decl-kwds', even though it never actually calls any `c-*' > functions at all. The byte compilation of d-mode.el is being done during the loading of cc-miscompile.el. This somewhat unusual constellation, I think, is causing the problem. When CC Mode determines the file name to put onto a c-lang-defconst's 'source property, it gives priority to the load file name, and only when this is nil does it use the byte-compile file name. (This is in defsubst c-get-current-file in cc-defs.el). It would seem this is not the correct priority. I think swapping the first two arms of the `cond' form in c-get-current-file may solve the problem. It's a bit late to try this tonight, I'll try it tomorrow. > Naturally, CC Mode will later try to load this file, and fail if it is > not in the `load-path'. This effectively breaks installations of D > Mode from non-interactive Emacs sessions. > I did not try to find the culprit. The CC Mode code is convoluted > beyond my understanding. The mechanism for the c-lang-defvar's may appear complicated, but it this concentration of the complexity in a single place that enables the simple, tabular definition of language dependent constants, even (especially) in derived modes. -- Alan Mackenzie (Nuremberg, Germany).