简体   繁体   中英

key binding in slime emacs

I want to change the key binding Mx slime-fuzzy-complete-symbol to M-TAB in both slime-mode and slime-repl. I looked up the common lisp manual, and tried the following sentences:

(eval-after-load 'slime                                                                                                            
         `(define-key slime-prefix-map (kbd "M-TAB") 'slime-fuzzy-complete-symbol))

(add-hook 'slime-load-hook                                                                                                         
        #'(lambda ()                                                                                                               
            (define-key slime-prefix-map (kbd "M-TAB") 'slime-fuzzy-complete-symbol)))

(define-key slime-repl-mode-map (kbd "M-TAB")                                                                                        
                   'slime-fuzzy-complete-symbol)

None of them is useful. The third sentence even have an error: Symbol's value as variable is void: slime-repl-mode-map

For reference, the following the is my init.el relate to slime:

(let ((default-directory "/usr/local/share/emacs/site-lisp/"))
  (normal-top-level-add-subdirs-to-load-path))

;; Setup load-path, autoloads and your lisp system                                                                                   
;; Not needed if you install SLIME via MELPA                                                                                         
(add-to-list 'load-path "~/default-directory/slime")
(require 'slime-autoloads)
(setq inferior-lisp-program "/usr/local/opt/clozure-cl/bin/ccl64")

;; Setup slime-repl                                                                                                                  
(setq slime-contribs '(slime-scratch slime-editing-commands))
;;(setq slime-contribs '(slime-repl)) ; repl only                                                                                    
(setq slime-contribs '(slime-fancy)) ; almost everything                                                                             

;;Setup suto-complete                                                                                                                
(add-to-list 'load-path "~/default-directory/auto-complete/")
(require 'auto-complete-config)
;;(add-to-list 'ac-dictionary-directories "~/default-directory/auto-complete/ac-dict")                                               
(ac-config-default)

It will be better to follow the emacs documentation for this case:

Key binding commands

In your case with a global key bindoing should work:

(global-set-key (kbd "M-TAB") 'slime-fuzzy-complete-symbol)

I know this is an old question, but a few weeks ago I was looking for an answer to a similar one and I hope additional info may be useful for someone... Here's what I've found out:

  • using (eval-after-load 'slime) in your .emacs (dot-emacs) file is not a good idea until you have (autoload 'slime) in it - and this is OK - without that (eval-after-load "...") may wait till the end of time for loading slime

  • the previous answer is OK if global-key-binding is appropriate for you

  • if you require or prefere local binding you may define your own function and bind it locally, eg:

     (defun my-slime-mode-keybindings () "For use in `slime-mode-hook' and 'slime-repl-mode-hook." (local-set-key (kbd "<C-f1>") 'slime-describe-symbol) (local-set-key (kbd "<M-f1>") 'slime-apropos-all) (local-set-key (kbd "Cc Cp") nil) ;; when you want to remove a key/sequence (local-set-key (kbd "C-<tab>") 'ace-window) (local-set-key (kbd "M-<tab>") 'slime-fuzzy-complete-symbol) ;; your case :) ) ;; end of defun my-slime-mode-keybindings() ;; tell emacs to use your function only in required mode(s) (add-hook 'slime-mode-hook #'my-slime-mode-keybindings) (add-hook 'slime-repl-mode-hook #'my-slime-mode-keybindings) 

best regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM