[slime-devel] Re: changing slime-keys

Pascal J.Bourguignon pjb at informatimago.com
Wed Jun 30 16:59:44 UTC 2004


Luke Gorrie writes:
> Pascal J.Bourguignon <pjb at informatimago.com> writes:
> 
> > What function should I call when I change slime-keys to have them
> > taken into account immediately?
> 
> (load "slime") and reopen your Lisp buffer(s) should do it.
> 
> Or `M-x slime-init-keymaps' might be sufficient.

That was my first try, but it does not work.

(defun pjb-slime-eval-last-expression ()
  "Evaluate the expression preceding point."
  (interactive)
  (setf *pjb-slime-buffer* (current-buffer))
  (pjb-slime-interactive-eval (slime-last-expression))
  );;pjb-slime-eval-last-expression


(defun equiv (&rest args)
  (if (null args)
    t
    (let ((val (not (pop args))))
      (while (and args (eq val (not (car args)))) (pop args))
      (not args))));;equiv


(defvar *pjb-slime-keys-dynamic* nil)
(defun pjb-slime-substitute-command (key command &rest keys)
  (unless  *pjb-slime-keys-dynamic*
    (setf slime-keys (copy-seq slime-keys)
          *pjb-slime-keys-dynamic* t))
  (let ((prefixedp (cadr (member :prefixed keys)))
        (skeys slime-keys))
    (while skeys
      (when (and (string= key (first (car skeys)))
                 (equiv prefixedp (cadr (member :prefixed (car skeys)))))
        (setf (second (car skeys)) command
              skeys nil))
      (pop skeys)))
  (slime-init-keymaps));;pjb-slime-substitute-command


(pjb-slime-substitute-command "\M-." 'slime-edit-definition-other-window)
(pjb-slime-substitute-command "\C-e" 'pjb-slime-eval-last-expression :prefixed t)

slime-keys is correctly changed:

(show (assoc "" slime-keys))
;; --> ("" pjb-slime-eval-last-expression :prefixed t :sldb t :inferior t)

but C-c C-e is still bound to slime-eval-last-expression, in current
slime-mode buffers (or new ones, if I kill and re-open a .lisp file
for example).

When I (trace slime-init-keymaps  slime-init-keymaps
slime-define-key), slime-define-key is called as expected thought:
 
| 2 -> slime-define-key: key="" command=pjb-slime-eval-last-expression --rest--42917=(:allow-other-keys t :prefixed t :sldb t :inferior t)
| 2 <- slime-define-key: pjb-slime-eval-last-expression


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein




More information about the slime-devel mailing list