开发者

emacs buffer bind to key

I don't know why but currently emacs opens only one copy of w3m. If w3m is already open then retyping the command to open w3m takes me to the already opened buffer. I would like to configu开发者_JAVA百科re ansi-term similarly i.e. typing C-x C-a (command open ansi-term) should take me to already opened ansi-term instead of opening a new buffer altogether.

How can I achieve this in emacs?


You could write a wrapper function around ansi-term that checks to see if there already is an existing terminal buffer, and recycles that buffer if it exists:

(defun green-ansi-term ()
  "Show an existing buffer called \"*ansi-term*\" if one exists, otherwise
call function ansi-term interactively."
  (interactive)
  (let ((existing-buffer (get-buffer "*ansi-term*")))
    (if existing-buffer
        (switch-to-buffer existing-buffer)
      (call-interactively 'ansi-term))))
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜