> Apparently that line does not stand alone. My .emacs looks > like this (just one line): > (define-key map [C-return] 'completion-at-point) > > When I load emacs, I get: > Symbol's value as variable is void: map > > I would probably have to copy the entire > (defvar nxml-mode-map ... map) expression.
No - see below. > Assuming that it worked, if my .emacs is loaded just > once at startup, wouldn't my key binding be overwritten each time > nXML mode is loaded? No - if a variable (e.g. `nxml-mode-map') already has a value then the defvar becomes a no-op when loaded. This means that you can use, say, `setq' to give a variable a value in your .emacs and not have that value overridden by later loading some library that defvars the same variable. > No doubt there is a way around that, but that > is too much digging around in the manual for me right now. If the keymap variable in question is bound (defined) from the outset, from emacs -Q, then you can put just this in your .emacs: (define-key nxml-mode-map [C-return] 'completion-at-point) More likely, however, the keymap is not bound at the outset, but only when its library is loaded (IOW, the library is not preloaded). In this case, `nxml-mode-map' is not bound until library nxml-mode.el is loaded. So you need to tell Emacs to define the key after loading the library that defines the keymap. Here is one way to do that: (eval-after-load "nxml-mode" '(define-key nxml-mode-map [C-return] 'completion-at-point)) However, when it comes to major modes, which is the case here, you need only put the key definition on the mode hook. This is recommended - better than using `eval-after-load'. (add-hook 'nxml-mode-hook (lambda () (define-key nxml-mode-map [C-return] 'completion-at-point))) See (emacs) `Hooks' and http://www.emacswiki.org/emacs/ModeHooks. But see this first: (emacs) `Init Rebinding'. It discusses exactly the question you raise. The Emacs manual is your friend: `C-h r', then `i' to find indexed topics or `C-s' to search the full text. If you read about a few basics such as these (binding keys, using libraries and major modes) then you will help yourself a lot when it comes to other questions that come up.