views:

425

answers:

2

I use emacs via Putty and since Putty doesn't send certain key combinations to the remote console I generally need to re-bind them to other key combinations.

After installing the amazing Zen-Coding mode I had some trouble with the preview it generated; I couldn't get it to insert the output it was previewing. I got around this with the following keybindings:

(global-set-key "\M-\r" 'zencoding-expand-line)
(global-set-key "\M-]" 'zencoding-preview-accept)

However, what I'd like to do is be able to hit M-RET again when the preview is open and have it insert the output.

My emacs-lisp-fu is extremely weak, however.

Is there a way I can test whether the preview is open and capture/bind another M-RET keypress?

+1  A: 

You can modify the key that does preview accept in this function at line 585 or so, like this:

(defvar zencoding-preview-keymap
  (let ((map (make-sparse-keymap)))
    (define-key map "\M-\r" 'zencoding-preview-accept)
    (define-key map [(control ?g)] 'zencoding-preview-abort)
    map))
justinhj
A: 

You can also use the buffer specific key bindings instead of the global ones.

Don