On Wed, Jan 21, 2026, at 9:50 AM, Steve Gutreuter via ESS-help wrote:
> (use-package ess
> :bind (:map ess-r-mode-map
> ("C-|" . " %>% ")
> :map inferior-ess-r-mode-map
> ("C-|" . " %>% ")))
> (use-package ess
> :bind (:map ess-r-mode-map
> ("C-=" . " <- ")
> :map inferior-ess-r-mode-map
> ("C-=" . " <- ")))
I think the `:bind` directive indicates the following code will be evaluated
*before* the package is loaded. Which will generate the error you describe,
since the keymaps aren't defined at that point.
I use the following (on Linux, but this should be OS-independent I hope):
```
(use-package ess
:config
...
(define-key ess-r-mode-map "_" #'ess-insert-assign)
(define-key inferior-ess-r-mode-map "_" #'ess-insert-assign)
(define-key ess-r-mode-map (kbd "C-c >") #'tws-ess-insert-then)
(define-key inferior-ess-r-mode-map (kbd "C-c >") #'tws-ess-insert-then)
(define-key ess-r-mode-map (kbd "C-c ;") #'tws-ess-insert-pipe)
(define-key inferior-ess-r-mode-map (kbd "C-c ;") #'tws-ess-insert-pipe)
...
)
```
Note that the function `ess-insert-assign` is provided with ESS to insert the
`<-` symbol. It works as a toggle, so if you type the character twice it
switches back. Which is convenient if you bind it to something you might
occasionally want to actually insert as-is (in my case, the underscore).
I use the following for magrittr and regular pipes. Using `just-one-space`
instead of a hard-coded " " usually produces the desired spacing around these.
```
(defun tws-ess-insert-then ()
(interactive)
(just-one-space 1)
(insert "%>%")
(just-one-space 1))
(defun tws-ess-insert-pipe ()
(interactive)
(just-one-space 1)
(insert "|>")
(just-one-space 1))
```
- tyler
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help