help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom keyboard layout? howto redefine keys?


From: harven
Subject: Re: custom keyboard layout? howto redefine keys?
Date: Fri, 10 Apr 2009 18:39:21 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

nic.d.m.1@googlemail.com writes:

> Thank you very much! I "mixed" your solutions and it worked:
>
> (global-set-key "b" (lambda () (interactive) (ucs-insert "61")))
> (global-set-key "a" (lambda () (interactive) (ucs-insert "62")))
>
> Any idea *why* this works? I don't understand it. What is the meaning
> of  "interactive" here?

you could have used instead:

(defun my-command ()
   (interactive)
   (ucs-insert "61"))

(global-set-key "b" 'my-command)

Interactive means that the function my-command is actually a command,
that is something called interactively using  M-x my-command.
Now you will probably never use that command directly, so there is no
need to give it a name.

Hence the lambda which defines an anonymous function, that is a function
without a name, and the interactive which convert it to a command.
It's a bit paradoxical, but global-set-key wants a command, not
a function, as its argument.

> By the way: Is there a possibility to reload the .emacs file without
> restarting emacs?
>
> I tried: M-x load-file .emacs but it doesn't work.

with current buffer being .emacs, do
M-x eval-buffer


reply via email to

[Prev in Thread] Current Thread [Next in Thread]