[ESS] How to assign function key

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu Feb 4 11:57:19 CET 2016


>>>>> Patrick Connolly <p_connolly using slingshot.co.nz>
>>>>>     on Thu, 4 Feb 2016 09:40:08 +1300 writes:

> On Wed, 03-Feb-2016 at 11:30AM +0100, Martin Maechler wrote:
> |> >>>>> Vitalie Spinu <spinuvit using gmail.com>
> |> >>>>>     on Wed, 3 Feb 2016 10:21:03 +0100 writes:
> |> 
> |>     >> (global-set-key [f7] 'comint-kill-output) 
> |>   or 
> |>     >> (define-key ess-mode-map [f7] 'ess-comint-kill-output)
> |> 
> |>     >> They would understand why I get a message that F7 is null
> |>     >> or undefined.
> |> 
> |>     > Works for me. Is it F7 or f7 that caused your problem?
> |> 
> |> also works for me; even when running emacs as  'emacs -nw'.
> |> So something must be strange in your emacs setup.

> So there's nothing wrong with my syntax, just something else
> incompatible?  Is one method preferable to the other?

> |> Maybe you do this in the *scratch* buffer  (using  C-x C-e )
> |> and send that plus possibly the relevant message(s) from the *Messages*
> |> buffer.

> Defining f7 as (global-set-key [f7] 'comint-kill-output) and pressing
> the F7 key while in the *R* buffer, the Message buffer lists:

> Symbol's function definition is void: comint-kill-output

> That same message appears at the bottom of the Emacs window.

> Defining f7 as (define-key ess-mode-map [f7] 'ess-comint-kill-output)
> and pressing the F7 key while in the *R* buffer, the Message buffer
> lists nothing though "<f7> is undefined" appears at the bottom of the
> window.

I think there are two (or more?) simultanous problems and we have not yet 
separated them:

1) 'comint-kill-output  is not defined in today's emacs, and it seems
   			is *also* not defined in your initialization
   at the time where you call  (global-set-key [f7] 'comint-kill-output)

   but the (global-set-key [f7] ...)  syntax is otherwise correct

2) (I guess) for unfortunate emacs-design reasons the *preferred*
        (define-key ess-mode-map ... ...)
   syntax may have to be different from the one for global-set-key,
   and so [f7] seems invalid in the (define-key .) case, but
        valid in the global-set-key one.
	
3) I use ESS/Emacs default  where C-c C-o is bound to  comint-delete-output
   which works fine.
   So I wonder why you want to maintain yourself two different versions of this.
   But that may have been very conscious.
   


> I didn't follow how to use C-x C-e in the *scratch* buffer so I can't
> provide that output.  My bad.

*paste* the lisp expressions into *scratch*  go to the end of
 such an expression and C-x C-e ... If you are inside *scratch*
 the modeline shows you that you are in lisp interaction mode,
 and emacs has a menu  [Lisp-interaction]
 That shows ((more easily than my very old-times learned C-x
 C-e)) that C-j is "Evaluate and Print"

So, for instance if you have this in *scratch*

(+ 1 1)

go to the end of that line and press C-j
you get

(+ 1 1)
2

---
now do the same thing with your key setting statements.

Alternatively (and more quickly, actually): Navigate to them in
your ~/.emacs file and
use C-x C-e (at their "end of function call" / "end of expression")
and the result is displayed in the mini buffer (and saved in
*Messages*).

Martin




More information about the ESS-help mailing list