[ESS] Custom key bindings for SAS

Daniel Muenz dmuenz at sdac.harvard.edu
Wed Jul 1 00:09:16 CEST 2009


Perfect!  Thanks very much, Rodney, that's exactly what I was looking for.

- Daniel


                                                                                                                    
  From:       Rodney Sparapani <rsparapa at mcw.edu>                                                                   
                                                                                                                    
  To:         ESS <ess-help at stat.math.ethz.ch>                                                                      
                                                                                                                    
  Cc:         Daniel Muenz <dmuenz at sdac.harvard.edu>                                                                
                                                                                                                    
  Date:       06/30/2009 03:22 PM                                                                                   
                                                                                                                    
  Subject:    Re: [ESS] Custom key bindings for SAS                                                                 
                                                                                                                    




Daniel Muenz wrote:
> Hi, thanks for your suggestion.  I've already tried the (setq
> ess-sas-global-unix-keys t) command though and it does not do exactly
what
> I want.  For example, I want the F3 key to not only submit the SAS
program,
> but then also to take me automatically to the *shell* buffer.  Something
> like this:
>
>       (global-set-key [f3] '(lambda ()
>           (interactive)
>           (ess-sas-submit)
>           (ess-sas-goto-shell))
>
> But I only want this to apply when the current buffer is a .sas, .log,
> or .lst file or the *shell*.
>
I don't know why you want this in a lambda clause, but here it is:

(global-set-key [f1] '(lambda ()
(interactive)
(let* ( (name (buffer-name))
(tail (car (reverse (split-string name "[./]")))) )
(if (or (string= name "*shell*")
(string= tail "sas")
(string= tail "log")
(string= tail "lst")) (progn
(ess-sas-submit)
(ess-sas-goto-shell))))))

You could fool it by opening a file named "sas", but nobody's perfect.
> Also, every time I hit a SAS-related key, I want a message echoed to the
> minibuffer area which describes what all the key presses do, .e.g,
>
>       (defun my-ess-sas-message ()
>           (interactive)
>           (message "F3: submit   F4: .sas   F5: .log   F6: .lst   F8:
> shell"))
>
> So this message should be echoed each time I hit F3, F4, F5, F6, or F8.
As
> an example:
>
>       (global-set-key [f4] '(lambda ()
>           (interactive)
>           (ess-sas-goto-sas)
>           (my-ess-sas-message)))
>
> Regarding my other question about the annoying dialog, sorry if this is
in
> fact the wrong forum for that, but I mentioned it here because I've only
> seen it appear when using ESS.
>
It's just my charming personality :o) But seriously, it is not unique
to ESS. Any time you have a *shell* buffer you get that question. For
example try (with no ESS usage at all and exit):

emacs -f shell &

--
Rodney Sparapani      Center for Patient Care & Outcomes Research (PCOR)
Sr. Biostatistician              http://www.mcw.edu/pcor
4 wheels good, 2 wheels better!  Medical College of Wisconsin (MCW)
WWLD?:  What Would Lombardi Do?  Milwaukee, WI, USA



More information about the ESS-help mailing list