From: keyboard on
In my .emacs, there are lines:

;; slime hooks
(defun slime-smart-quit ()
(interactive)
(when (slime-connected-p)
(if (equal (slime-machine-instance) "my.workstation")
(slime-quit-lisp)
(slime-disconnect)))
(slime-kill-all-buffers))

(add-hook 'kill-emacs-hook 'slime-smart-quit)

(add-hook 'slime-mode-hook
(lambda ()
(unless (slime-connected-p)
(save-excursion (slime)))))

When I quit emacs without starting slime, I got an error:

Symbol's function definition is void: slime-connected-p

How to overcome this problem?

Thanks.
From: Tim X on
keyboard <xiewensheng(a)gmail.com> writes:

> In my .emacs, there are lines:
>
> ;; slime hooks
> (defun slime-smart-quit ()
> (interactive)
> (when (slime-connected-p)
> (if (equal (slime-machine-instance) "my.workstation")
> (slime-quit-lisp)
> (slime-disconnect)))
> (slime-kill-all-buffers))
>
> (add-hook 'kill-emacs-hook 'slime-smart-quit)
>
> (add-hook 'slime-mode-hook
> (lambda ()
> (unless (slime-connected-p)
> (save-excursion (slime)))))
>
> When I quit emacs without starting slime, I got an error:
>
> Symbol's function definition is void: slime-connected-p
>
> How to overcome this problem?
>

There are two ways I can think of.

The first thing you could do is ensure the slime code is loaded when you
first start emacs. While this would appear easy, it has a few
disadvantages, most noteably, you will be loading libraries you may not
need and will likely slow down your startup for no real benefit.

An alternative would be to define a variable, set it to nil by default.
Add some code to your slime-mode-hook that sets the variable to t and
then in your 'smart' quit function, test this variable before calling
any of the slime routines.

Finally, and probably the easiest would be to modify your quit function
to test and see if either slime is loaded or the funciton of interest is
bound. Look at featurep and/or fboundp

Tim



--
tcross (at) rapttech dot com dot au
From: Helmut Eller on
* keyboard [2010-06-13 09:06+0200] writes:

> When I quit emacs without starting slime, I got an error:
>
> Symbol's function definition is void: slime-connected-p
>
> How to overcome this problem?

(when (and (fboundp 'slime-connected-p) (slime-connected-p))
...)

Helmut
From: keyboard on
Thanks.

Works like:

(defun slime-smart-quit ()
(interactive)
(when (and (fboundp 'slime-connected-p)(slime-connected-p))
(if (equal (slime-machine-instance) "my.workstation")
(slime-quit-lisp)
(slime-disconnect))
(slime-kill-all-buffers)))