3

I recently found yascroll and have added it to my .emacs to enable it permanently. Specifically, I added this line (as described here: https://github.com/m2ym/yascroll-el):

(global-yascroll-bar-mode 1)

When Emacs starts, evaluation of my .emacs halts with this error:

Symbol's function definition is void: global-yascroll-bar-mode

Strangely, though, everything works if I open .emacs and run M-x eval-buffer, which I thought was in essence the same thing.

I can also enable yascroll by simply running M-x global-yascroll-bar-mode. The problem only appears when Emacs is starting. What am I doing wrong?

7

It looks like your forgot to call package-initialize in your init file before enabling global-yascroll-bar-mode. Add the following to your init file:

(package-initialize)
(setq package-enable-at-startup nil)

(global-yascroll-bar-mode)

Note that the argument to global-yascroll-bar-mode is redundant: A mode is always enabled if it's function is called from Emacs Lisp.

1

I solved it by running M-x customize-group RET yascroll RET and changing the Global-Yascroll-Bar-Mode setting to "on".

That added

'(global-yascroll-bar-mode t)

to my custom-set-variables section in .emacs (the value does not have to be t, it can also be 1). That works. I'm still not sure why I can't enable the mode the other way.

  • 1
    The problem is the timing of evaluation. Variables in the customize variable settings get set immediately, even if the mode they refer to hasn't been loaded yet. They just sit there doing nothing until their mode is loaded, and then they take effect. On the other hand, functions defined in modes, like (global-yascroll-bar-mode), can't be called until after the mode is loaded. That's why @lunaryorn 's answer works. – Tyler Dec 5 '14 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.