i'm encountering a serious problem with a function created using define-minor-mode - and the problem is only occurring when operating with the byte-compiled version of the function. i've tried to debug the problem, but am stumped. i'm able to reproduce the problem in a few versions of emacs, though, and have created a bzr branch on launchpad with a copy of the code. one of the final steps in my updates to allout.el is migrating allout-mode minor mode to `define-minor-mode'. however, some key substitutions way deep in my code do only happen properly when i use a explicitly evaluated (via eval-defun or eval-when-compile) version of the define-minor-mode to define the allout-mode function. if the minor mode was established by a byte-compiled version of the function the same key substitutions do not show in the mode. (there are some other keybinding problems that occur, as well.) i wonder whether i'm somehow misusing define-minor-mode in a dumb way, but am entirely missing it if that's the case. the problem happens identically on the x toolkit and chiba-u versions of emacs, both running on macox X snow leopard: GNU Emacs 23.2.91.1 (x86_64-apple-darwin10.5.0, Carbon Version 1.6.0 AppKit 1038.35) of 2010-12-20 on crisp GNU Emacs 23.1.90.2 (x86_64-apple-darwin10.4.0, X toolkit) of 2010-11-05 on crisp i can reproduce the problem by wrapping the define-minor-mode in either `eval-and-compile' or `eval-when-compile' and doing an `emacs-lisp-byte-compile-and-load' to show the different behaviors. i've created a bzr branch on launchpad.net with a prepared version (details, below) of allout.el for others to try: http://bazaar.launchpad.net/~ken-manheimer/emacs/alloutdev/annotate/head:/lisp/allout.el?start_revid=102483 in this version i've wrapped the define-minor-mode with eval-and-compile. that can be changed to test the different behaviors. when byte-compiling and loading with the eval-when-compile, invoking the mode yields the key substitutions, as it ought. (of course, the step of loading the byte-compiled code is irrelevant at that point, because the function isn't in the byte-compiled code. it's only defined because it was evaluated during the byte-compile.) with the eval-and-compile, loading the byte-compiled allout.elc wipes out the key substitutions - they're no longer in effect. of course, the lack of the function in the byte-compiled code when using eval-when-compile makes the byte-compiled code useless, so i have no workaround for the problem, just a weird demonstration of it. i've tried tracking down the failed key substitutions, by wrapping define-key with some advice that noted when the key defines happened, and they do every time the mode is activated, whether or not it's via the byte-compiled version of the mode function (when defined by define-minor-mode). my function which does the key substitutions (allout-setup-mode-map) uses fset to ensure that the mode map is properly globally established, so it's already kind of complicated. i'm also wondering whether i'm just misunderstanding something about the way define-minor-mode is supposed to work. to see the problem, visit this version (see link, above) of allout.el and start allout-mode. then emacs-lisp-byte-compile-and-load the code, and you'll find that \C-a is bound to move-beginning-of-line, as it normally is - not replaced by allout-beginning-of-line, as it should be. then change the `eval-and-compile' that's wrapped around the define-minor-mode allout-mode to `eval-when-compile', do emacs-lisp-byte-compile-and-load, and you'll find that \C-a is properly bound to allout-beginning-of-line. (you can also just manually evaluate the define-minor-mode - that will also the keysubsitutions in the keymap immediately.) help would be much appreciated! -- ken manheimer http://myriadicity.net