all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Sebastian Wiesner <swiesner@lunaryorn.com>
Cc: 19206@debbugs.gnu.org
Subject: bug#19206: 25.0.50; CC Mode tracks wrong source files
Date: 28 Nov 2014 22:25:42 -0000	[thread overview]
Message-ID: <20141128222542.60510.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.14863.1417170074.1147.bug-gnu-emacs@gnu.org>

Hello, Sebastian.
In article <mailman.14863.1417170074.1147.bug-gnu-emacs@gnu.org> 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).






  parent reply	other threads:[~2014-11-28 22:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28 10:19 bug#19206: 25.0.50; CC Mode tracks wrong source files Sebastian Wiesner
2014-11-28 19:49 ` Stefan Monnier
     [not found] ` <mailman.14863.1417170074.1147.bug-gnu-emacs@gnu.org>
2014-11-28 22:25   ` Alan Mackenzie [this message]
2014-11-28 22:37     ` Sebastian Wiesner
2014-11-30 18:42     ` Alan Mackenzie
     [not found]     ` <20141130184221.GA12974@acm.acm>
2014-12-02 11:03       ` Sebastian Wiesner
2014-12-02 12:02         ` Alan Mackenzie
2014-12-02 14:02           ` Stefan Monnier
2014-12-07 22:46           ` Alan Mackenzie
2014-12-08  2:59             ` Stefan Monnier
2015-01-13 16:09 ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141128222542.60510.qmail@mail.muc.de \
    --to=acm@muc.de \
    --cc=19206@debbugs.gnu.org \
    --cc=swiesner@lunaryorn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.