tags:

views:

90

answers:

1

Any hints on how to let emacs send unbinded F1..F12 keys to programs just like in regular terminal when in 'ansi-term' buffer?

A: 

It's not "unbinding" you are looking for but binding those keys to the proper escape sequences. The following will bind [f1]..[f5] to the vt100 escape sequences for those keys for term and ansi-term buffers. I am not sure what the proper sequences are for ansi, so tweak the alist accordingly.

(defun term-send-function-key ()
  (interactive)
  (let* ((char last-input-event)
         (output (cdr (assoc char term-function-key-alist))))
    (term-send-raw-string output)))

(defconst term-function-key-alist '((f1 . "\e[OP")
                                    (f2 . "\e[OQ")
                                    (f3 . "\e[OR")
                                    (f4 . "\e[OS")))

(dolist (spec term-function-key-alist)
  (define-key term-raw-map
    (read-kbd-macro (format "<%s>" (car spec)))
    'term-send-function-key))
remvee
Doesn't seems to work. It acts in exactly the same way like without the 'term-send-function-key.
wu
Please try again the (format..) statement in de dolist was clobbered.
remvee
Thanks it's working now.
wu