1

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 configure 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?

user229044
  • 232,980
  • 40
  • 330
  • 338
Kabira K
  • 1,916
  • 2
  • 22
  • 38

1 Answers1

3

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))))
Sean
  • 29,130
  • 4
  • 80
  • 105