开发者

Let emacs send F<n> keys to programs in 'ansi-term'

Any hints on how to let emacs send unbinded F1..F12 keys to programs just like in regular t开发者_开发问答erminal when in 'ansi-term' buffer?


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))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜