I am trying to define keymapping about %>% for ess R mode.
Code 1 is my init.el based on How to implement the piping operator %>% in ESS mode?. After evaluation of the code, I get the key binding Code 2. I don't know why such a situation happen and RET does not work well. How do I fix it?
Code 1
(defun then_R_operator ()
(interactive)
(just-one-space 1)
(insert "%>%"))
(define-key ess-mode-map (kbd "C-%") 'then_R_operator)
(define-key inferior-ess-mode-map (kbd "C-%") 'then_R_operator)
Code 2
key binding
--- -------
RET then_R_operator
C-% then_R_operator
Update
I also try a different method as follows. But, I got the same result.
(define-key ess-mode-map (kbd "C-M") "%>%")
(define-key inferior-ess-mode-map (kbd "C-M") "%>%")
C-%, and it's getting treated as RET instead – Tyler May 03 '21 at 13:53C-M, it sends the same symbol asRET. Your original version works as expected for me withC-%. Maybe you hadC-Mbound somewhere as well, that would have caused the problem. – Tyler May 03 '21 at 14:42C-Mis Rstudio's keybinding. I didn't think this cause the problem. – hrkshr May 03 '21 at 15:04