Re: [ESS] Trouble assigning to keys in Emacs Modified for MacOS 30.2

2026-01-21 Thread Tyler Smith via ESS-help
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


Re: [ESS] Trouble assigning to keys in Emacs Modified for MacOS 30.2

2026-01-21 Thread Steve Gutreuter via ESS-help
Thanks!  That looks very effective for assignment, but does not provide a smart 
key for R pipe operators.  Any suggestions for that?

Steve Gutreuter
[email protected]



> On 2026-01-21 10:20:41, at 10:20, Sparapani, Rodney via ESS-help 
>  wrote:
> 
> Hi Steve:
> 
> You might want to look at the code in the package ess-smart-equals.
> That is what I use.  Thanks
> 
> --
> 
> Rodney Sparapani, Associate Professor of Biostatistics
> 
> Director, Wisconsin Chapter of the American Statistical Association
> 
> CTSI BERD Director, Division of Biostatistics, Data Science Institute
> 
> Medical College of Wisconsin, Milwaukee Campus
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help


[[alternative HTML version deleted]]

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[ESS] Trouble assigning to keys in Emacs Modified for MacOS 30.2

2026-01-21 Thread Sparapani, Rodney via ESS-help
Hi Steve:

You might want to look at the code in the package ess-smart-equals.
That is what I use.  Thanks

--

Rodney Sparapani, Associate Professor of Biostatistics

Director, Wisconsin Chapter of the American Statistical Association

CTSI BERD Director, Division of Biostatistics, Data Science Institute

Medical College of Wisconsin, Milwaukee Campus



[[alternative HTML version deleted]]

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[ESS] Trouble assigning to keys in Emacs Modified for MacOS 30.2

2026-01-21 Thread Steve Gutreuter via ESS-help
I am running Vincent Goutet’s Emacs Modified for MacOS 26.2 under MacOS 26.2 
and have hit a problem which I have not encountered running Emacs/ESS under 
Linux distros or Windows.  I am trying to assign the R operators <- and %>% to 
keys using variations of the following code in my .emacs:

;;; Pipe operator (magrittr %>% or |>) defined and bound to Cntl-|
;;; https://emacs.stackexchange.com/questions/8041/how-to-implement-the-piping-
;;; operator-in-ess-mode
;; (defun then_R_operator ()
;;  "R  |> pipe operator"
;;  (interactive)
;;  (insert " %> %")
;;  (reindent-then-newline-and-indent))
;; (define-key inferior-ess-r-mode-map (kbd "C-|") 'then_R_operator)
(use-package ess
  :bind (:map ess-r-mode-map
 ("C-|" . " %>% ")
 :map inferior-ess-r-mode-map
 ("C-|" . " %>% ")))
;;; Produces compile error:
;;;-
;;; Bind <- to C-=
;; (defun R-left-assign ()
;;   "R - <- left assignment operator"
;;  (interactive)
;;  (insert " <- "))
;; (define-key inferior-ess-r-mode-map (kbd "C-=") 'R-left-assign)
(use-package ess
  :bind (:map ess-r-mode-map
 ("C-=" . " <- ")
 :map inferior-ess-r-mode-map
 ("C-=" . " <- ")))
;;; Produces compile error:

Everything I have tried fails with byte-compilation like ""Error (use-package): 
ess/:catch: Symbol’s value as variable is void: ess-r-mode-map”.  So it seems 
that inferior-ess-r-mode-map and ess-r-mode-map might not defined in the 
implementation of ESS imbedded in Emacs Modified for MacOS.  I must confess 
that I lack any skill with Emacs Lisp,

Is there a successful way to assign R operators to keys for Emacs Modified for 
MacOS.

Thanks!!!

Steve Gutreuter
[email protected]




[[alternative HTML version deleted]]

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help