Stefan, Thank you so much for your answer! I have corrected my code and now my keys are set ! But now my main menu is not displayed anymore and the hook cannot be added too. (defcustom rct-mode-hook nil "Normal hook run when entering rct mode and many related modes." :type 'hook :options '(font-lock-mode t) :group 'rct) Actualy I don't know if it's usefull to add the property :options. I get an error: Debugger entered--Lisp error: (void-function add-hooks) (define-derived-mode rct-mode special-mode "rct:main" (add-hooks 'rct-mode-hook) ) (defun main() (main-menu) (rct-mode) ) Thank you, Pascal 2012/9/12 Stefan Monnier > > can you please help me with the following LISP code? > > Looks fine. > > > (define-derived-mode rct-mode special-mode "rct:main" > > "Major mode for remote connections > > \\{rct-main-mode-map}." > > (setq debug-on-error t) > > Don't use `setq' in a major-mode since the change will affect > all buffers. Better use (set (make-local-variable 'debug-on-error) t). > > > (use-local-map rct-mode-map) > > (run-hooks 'rct-mode-hook) > > Don't do that, it's done by `define-derived-mode already. > > > (main-menu)) > > This shouldn't be in the major-mode function, but in another function > (which will probably call the major-mode function). > > > (switch-to-buffer rct-mode-buffer-name) > > You should probably call pop-to-buffer here instead. > > > Stefan >