Subject: Re: bug#14974: 24.3.50; adaptive-wrap 0.3 calls potentially void function easy-menu-add-item

From: Stephen Berman <[email-masked]>
Date: Mon, 29 Jul 2013 23:35:11 +0200

On Mon, 29 Jul 2013 12:40:31 -0400 Stefan Monnier <[email-masked]> wrote:

>>>> Thanks for the report; fixed.
>>> I don't think that's enough: the error is signaled before
>>> adaptive-wrap.el is loaded, i.e. before seeing the code you modified.
>>> You'd need to add a ;;;###autoload in front of the new (require 'easymenu).

Hmm, I guess I don't understand what is going wrong -- what error is
being signaled and what is causing it?  From the shell I invoked 

emacs -Q --batch --eval "(package-install 'adaptive-wrap)"

and that returns "package.el is not yet initialized!" -- but the same
thing happens with any other package, so that can't be the problem.
What is a recipe to getting the error, so I can understand what the
issue is?

>> Shouldn't adaptive-wrap rather use one of the autoloadable functions
>> from "easymenu"?
>
> It could, but that would load easymenu just as well.
>
> An alternative would be to do the same with define-key rather than
> using easymenu.

The following seems to DTRT (and also allows dispensing with
adaptive-wrap-unload-function):

(define-key-after (lookup-key menu-bar-options-menu [line-wrapping])
  [adaptive-wrap]
  '(menu-item "Adaptive Wrap" (lambda ()
				(interactive)
				(if adaptive-wrap-prefix-mode
				    (adaptive-wrap-prefix-mode -1)
				  (adaptive-wrap-prefix-mode 1)))
	      :enable t
	      :visible (and (menu-bar-menu-frame-live-and-visible-p)
			    (featurep 'adaptive-wrap))
	      :help "Show wrapped long lines with an adjustable prefix"
	      :button (:toggle . adaptive-wrap-prefix-mode))
  word-wrap)

Should I install it in place of the easy-menu definition?  (Though in
any case I'd still like to understand just what the problem with the
latter is.)

Steve Berman