unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: [drew.adams@oracle.com: RE: weirddefadvicebugwithbyte-compilation]
Date: Tue, 13 Dec 2005 17:05:02 -0800	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICOEDCDAAA.drew.adams@oracle.com> (raw)
In-Reply-To: <E1EmJeJ-0002bX-BB@fencepost.gnu.org>

        Not sure what you want. Below is the test case again. It is
        self-contained for reproducing the crash bug (on Windows).
        Are you perhaps asking about the
        define-minor-mode questions, or is this what you wanted?

    That is the test case I tested before.

         Are you perhaps asking about the
        define-minor-mode questions,

    Yes--here's what I said:

    	    Please see my previous emails, where I describe the
    	    original case (which uses define-minor-mode).

    	Could you send that test case again?

    My response refers to "the original case".

I shouldn't have said "original case", but "original context". That is what
led to the misunderstanding. What you tested was the original case I
submitted. It contains everything needed for the crash bug.

What I was referring to was my original use context. You don't want all the
files I load (but I can point you to them, if you like). I described what I
did, but I will try to be clearer here. Let me know if this is what you want
or not.

1. I load files of mine with stuff like that shown in bar.el - just think of
this code as being in my .emacs.

2. I load a file of mine that does a defadvice like that seen in bar.el. It
has the `compile' keyword. There is no mention of variable `my-mode' or
foo.el in that file. To me, that defadvice should have no connection with
the problems seen, but if I don't do that defadvice the problem goes away.

3. I do (require 'foo) from a file I load (e.g. .emacs). foo.el has (provide
'foo).

4. In foo.el, I do, _in order_:

a. A defvar of a keymap variable, followed by code that defines keys in that
map and does (put ... 'menu-enable (and my-mode...)). This includes menu-bar
bindings for the (existing) Search menu.

b. A defadvice like the one shown in foo.el. It has _no_ `compile'. The body
refers to variable `my-mode'.

c. A define-minor-mode for mode `my-mode'.

d. This, at the very end (of foo.el): (if my-mode (my-mode 1)). I do that to
make sure that the mode-line lighter correctly corresponds to the mode state
(on/off).

5. Near the end of my .emacs (after loading foo.elc), I do this: (my-mode
1).

Here's my understanding of the "problems" (or misunderstanding on my part)
surrounding `define-minor-mode':

1. When foo.elc is loaded, it adds a binding to the menu-bar Search map, and
it adds a corresponding `menu-enable' that tests `my-mode'.

2. Then, loading foo.elc causes the defadvice in that file to be
byte-compiled. I do not understand why, since there is no `compile' in it.

3. That byte-compilation causes a warning to be displayed in buffer *Compile
Log*.

4. To display *Compile Log*, a new frame is created, because of the
special-display regexp.

5. When creating the new frame, the menu-bar Search menu is created for it,
and the `menu-enable' property with test `my-mode' is evaluated.

6. Since the `define-minor-mode' has not yet been evaluated during loading
of foo.elc, `my-mode' is still unbound when it is evaled for the Search
menu, so a backtrace is displayed with a void-variable error.

7. The backtrace is also a special-display buffer, so a new frame is created
to display it, provoking the same problem of step 5. Eli has explained the
ensuing crash bug on Windows.

If I don't use `define-minor-mode', I will naturally place a defcustom for
`my-mode' near the beginning of file foo.el. I was mistakenly expecting that
the automatic generation of the defcustom by `define-minor-mode' would also,
in effect, place it near the beginning of the byte-compiled file foo.elc.
Naive.

Now I understand that I must either place the `define-minor-mode' at the
file beginning or use an explicit defcustom (can I use a defcustom plus
`define-minor-mode' here, or will that provoke an error?). Actually, it is
sufficient to place the `define-minor-mode' before the defadvice in foo.el.

I still don't understand why the defadvice in foo.el, which has no
`compile', is byte-compiled on the fly. Nor do I understand why removing the
defadvice from bar.el (which has a `compile') causes the error to go away.
It's as if the `compile' from bar.el's defadvice were somehow transferred to
foo.el's defadvice, or the `compile' turned on a compile-advices-from-now-on
mode, so foo.el's defadvice was also compiled. I'm unclear on the way to use
defadvice, I guess.

I'm not claiming there is actually anything wrong (another bug). I'm just
confessing my confusion and naive expectations for `define-minor-mode'.
IIUC, we tell people to use the minor-mode function to set the minor-mode
variable, so that's what I do in .emacs. If I instead set the variable there
(setq), there is of course no unbound-variable error.

If there is a lesson here, besides my own learning, perhaps it is that we
could explain the use of `define-minor-mode' a bit better. And I wonder
about the behavior of the on-the-fly defadvice byte-compiling. Again, I'm no
doubt confused about that - I'd like to understand what's happening there
and why.

Does this help? If not, I'll be glad to point you to the source files.
They're all on Emacs Wiki.

  reply	other threads:[~2005-12-14  1:05 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-05  2:36 [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard Stallman
2005-12-07 18:55 ` Chong Yidong
2005-12-08  4:53   ` Richard M. Stallman
2005-12-08 16:14     ` Drew Adams
2005-12-09 13:17       ` Eli Zaretskii
2005-12-09 14:07         ` Chong Yidong
2005-12-09 18:37         ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-10  4:14         ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard M. Stallman
2005-12-11 18:17           ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-12  5:23             ` Richard M. Stallman
2005-12-12  5:40               ` [drew.adams@oracle.com: RE: weird defadvice bugwithbyte-compilation] Drew Adams
2005-12-13  3:14                 ` Richard M. Stallman
2005-12-13  3:52                   ` [drew.adams@oracle.com: RE: weird defadvicebugwithbyte-compilation] Drew Adams
2005-12-13 23:33                     ` Richard M. Stallman
2005-12-14  1:05                       ` Drew Adams [this message]
2005-12-14  1:24                         ` [drew.adams@oracle.com: RE: weirddefadvicebugwithbyte-compilation] Johan Bockgård
2005-12-14  3:41                           ` [drew.adams@oracle.com: Drew Adams
2005-12-14  3:45                             ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-14 17:17                             ` [drew.adams@oracle.com: Johan Bockgård
2005-12-14 21:29                               ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-14 23:43                                 ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Johan Bockgård
2005-12-15  1:46                                   ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-11 20:21         ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Eli Zaretskii
2005-12-11 21:35           ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-12  5:52             ` Eli Zaretskii
2005-12-12  6:11               ` [drew.adams@oracle.com: RE: weird defadvice bugwithbyte-compilation] Drew Adams
2005-12-12  6:44                 ` [drew.adams@oracle.com: RE: weird defadvicebugwithbyte-compilation] Drew Adams
2005-12-12 21:22                   ` Eli Zaretskii
2005-12-12 21:53                     ` [drew.adams@oracle.com: RE: weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-13  4:30                       ` Eli Zaretskii
2005-12-13  4:59                         ` [drew.adams@oracle.com: Drew Adams
2005-12-12  5:23           ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard M. Stallman
2005-12-12  6:11             ` Eli Zaretskii
2005-12-13  3:14               ` Richard M. Stallman
2005-12-13  4:39                 ` Eli Zaretskii
2005-12-13 23:33                   ` Richard M. Stallman
2005-12-14 19:38                     ` Eli Zaretskii
2005-12-15  2:09                       ` Richard M. Stallman
2005-12-15  4:46                         ` Eli Zaretskii
2005-12-16  1:51                           ` Richard M. Stallman
2005-12-16 19:48                             ` Eli Zaretskii
2005-12-16 20:14                             ` Eli Zaretskii
2005-12-17  1:05                               ` Richard M. Stallman
2005-12-17  8:29                                 ` Eli Zaretskii
2005-12-17 23:59                                   ` Richard M. Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICOEDCDAAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).