How to prevent the "Symbol's function definition is void: error" when running emacs in the console?

10

1

To disable the scrollbar in emacs I added (toggle-scroll-bar -1) to the my .emacs file and it works great when I run emacs outside of console mode. However when I run emacs in the terminal I get the error Symbol's function definition is void: toggle-scroll-bar

I'm running Emacs 23.3.1

heres the trace when I run --debug-init

    1 Debugger entered--Lisp error: (void-function scroll-bar-mode)                
    2   (scroll-bar-mode -1)                                                       
    3   eval-buffer(#<buffer  *load*> nil "/Users/neil/.emacs.d/init.el" nil t)  ;$
    4   load-with-code-conversion("/Users/neil/.emacs.d/init.el" "/Users/neil/.ema$
    5   load("/Users/neil/.emacs.d/init" t t)                                      
    6   #[nil "^H\205\264^@   \306=\203^Q^@\307^H\310Q\2027^@ \311=\2033^@\312\307$
    7   command-line()                                                             
    8   normal-top-level()

bneil

Posted 2011-07-21T18:46:42.497

Reputation: 1 277

Emacs probably gave you a Warnings buffer telling you to run emacs with the --debug-init option to get a complete error backtrace. Try that and add that information to the question. Along with the Emacs version M-x emacs-version. That chunk of code works just fine with Emacs 23.2. – Trey Jackson – 2011-07-21T21:48:37.240

@Trey Jackson, I added the details you requested, I seem to be running Emacs 23.1, so I'll try upgrading. Thank you for your suggestions. – bneil – 2011-07-22T16:23:40.903

Very odd. Ok, next test is running Emacs w/out your .emacs, emacs -nw -q, and then in the scratch buffer, type (scroll-bar-mode -1)C-j and see if you get an error. That function is distributed with Emacs in the scroll-bar.el package, so I'm guessing your .emacs has something odd, or the Emacs wasn't installed properly. – Trey Jackson – 2011-07-22T16:25:59.887

I get this error upon doing that

Debugger entered--Lisp error: (void-function scroll-bar-mode) (scroll-bar-mode -1) eval((scroll-bar-mode -1)) eval-last-sexp-1(t) eval-last-sexp(t) eval-print-last-sexp() call-interactively(eval-print-last-sexp nil nil) – bneil – 2011-07-22T16:30:42.270

Here is my .emacs file http://pastebin.com/4mYE91Ne too

– bneil – 2011-07-22T16:34:51.737

Ok, now how about M-x find-library simple RET - that should take you to where Emacs is installed, then C-x C-d to open a dired, and in that directory there should be a scroll-bar.elc. Though the directions might fail if the Emacs wasn't installed with source lisp code... – Trey Jackson – 2011-07-22T16:46:53.507

@TreyJackson let us continue this discussion in chat

– bneil – 2011-07-22T16:53:12.203

Answers

13

FWIW. The emacs manual discourage the use of window-system as a predicate.

Do not use window-system and initial-window-system as predicates or boolean flag variables, if you want to write code that works differently on text terminals and graphic displays. That is because window-system is not a good indicator of Emacs capabilities on a given display type. Instead, use display-graphic-p or any of the other display-*-p predicates described in Display Feature Testing.

http://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Systems.html

I use this to turn off the scrollbar and toolbar when in a graphical display.

(if (display-graphic-p)
    (progn
      (tool-bar-mode -1)
      (scroll-bar-mode -1)))

neatonk

Posted 2011-07-21T18:46:42.497

Reputation: 146

5

While I think @neatonk's answer is best and covers all the bases, to specifically disable the scroll bar you can put the following in your ~/.emacs

(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))

donovan.lampa

Posted 2011-07-21T18:46:42.497

Reputation: 193

-2

My guess is when you open emacs -nw emacs doesn't even bother to load scroll-bar.el. thats why it is having trouble to find the function toggle-scroll-bar.
may be instead if you put
(scroll-bar-mode -1)
probably work.

kindahero

Posted 2011-07-21T18:46:42.497

Reputation: 1 088

1(toggle-scroll-bar -1) works just fine in emacs -nw for Emacs 23.2... – Trey Jackson – 2011-07-21T21:45:51.250