I frequently work with R and ess, and want to bind a shortcut to a function that clears the R console:
(use-package ess-site :ensure ess :bind (:map inferior-ess-mode-map ("C-c c" . clear-shell) ) )
However, the keybinding is not set when I start emacs. I have to launch an inferior-ess-mode, then go to my config file and evaluate the code above for it to bind the function to "C-c c".
How can this be fixed?
It also does not work if I use something that is not bound to anything, like
C-c s. Also, there is no difference if I use :bind*. Only after I manually execute the code above it works. Same thing happens if I use another mode map, like ess-mode-map.
Also, the same thing happens with other modes and functions, like this for matlab:
(use-package matlab-mode :ensure t :config (load-library "matlab-load") (custom-set-variables '(matlab-shell-command-switches '("-nodesktop -nosplash"))) (add-hook 'matlab-mode-hook 'auto-complete-mode) (setq auto-mode-alist (cons '("\\.m$" . matlab-mode) auto-mode-alist)) (matlab-cedet-setup) :bind* (:map matlab-mode-map ("C-c C-c" . matlab-shell-save-and-go)) )
C-c C-c only works after manually evaluating the code while the matlab shell is already running. Before that it's bound to the function that it's bound to by default in that mode.