all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: Joost Kremers <joostkremers@fastmail.fm>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Open multiple separate terminal buffers with multi-term in Emacs.
Date: Wed, 2 Jun 2021 22:05:26 +0800	[thread overview]
Message-ID: <CAGP6PO+gKaRAZT0PCMPqjwWy6mFmP+XQUQ2bGRfa-v=VByoEuA@mail.gmail.com> (raw)
In-Reply-To: <CAGP6PO+PaWqpL1=98zLY-VxCT_hsjhh-1Wj+ddJuw_FmkJRhyg@mail.gmail.com>

On Wed, Jun 2, 2021 at 9:09 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Wed, Jun 2, 2021 at 3:12 PM Joost Kremers <joostkremers@fastmail.fm> wrote:
> >
> >
> > On Wed, Jun 02 2021, Hongyi Zhao wrote:
> > > According to the tricks mentioned here,
> > > <https://iloveemacs.wordpress.com/2014/09/10/emacs-as-an-advanced-terminal-multiplexer/comment-page-1/>,
> > > I installed the following packages from melpa: multi-term,
> > > ace-jump-mode, key-chord, and yasnippet. Then I add the following
> > > configuration into my ~/.emacs.d/init.el:
> >
> > If all you want is to use multiple terminals, you don't need all those packages.
> > Only multi-term is useful for your purpose. (It's possible to do what you want
> > without any extra packages, but multi-term makes it easier.)
> >
> > So before you install ace-jump-mode, key-chord and yasnippet, I strongly suggest
> > you read about what those packages do and consider whether you really want/need
> > them.
> >
> > Now, about your question:
> >
> > > Now, I can open two new terminals by pressing:
> > >
> > > C-c T
> > > C-x 2
> >
> > This doesn't actually open two terminals. It opens one terminal and then splits
> > the window in two windows. Both windows show the *same* buffer, however.
> >
> > The description of the multi-term package (see <https://melpa.org/#/multi-term>)
> > says that you can create a new term buffer with `M-x multi-term`, which you have
> > bound to `C-c T`. So press it once to create one terminal, press it again to
> > create a second one. If you want to see both terminals at once, open one
> > terminal, split the window (C-x 2 or C-x 3) and then open a new terminal in the
> > second window.
>
> I want to see all the opened terminals at once, i.e., tiling them in
> the Emacs window. How can I write a function that takes as an argument
> the number of buffers to open to automate this process?

To be more specific, I find the following code snippet from
<https://stackoverflow.com/questions/2785950/more-than-one-emacs-terminal>:

;Here's a super lightweight little function that you can call to
automatically rename the term you're on, and then start a new term:
(defun new-ansi-term ()
  (interactive)
  (if (string= "*ansi-term*" (buffer-name))
      (rename-uniquely))
  (ansi-term "/bin/bash"))

;Then to bind that within ansi-term, I found this works:

(defvar ansi-term-after-hook nil)
(add-hook 'ansi-term-after-hook
          '(lambda ()
             (define-key term-raw-map (kbd "C-t") 'new-ansi-term)))
(defadvice ansi-term (after ansi-term-after-advice (org))
  (run-hooks 'ansi-term-after-hook))
(ad-activate 'ansi-term)


The above code can open multiple new terminals, but they are located
in different windows, and I don't know how to adjust it to let all
terminals opened using a tiling layout.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



  reply	other threads:[~2021-06-02 14:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  1:38 Open multiple separate terminal buffers with multi-term in Emacs Hongyi Zhao
2021-06-02  3:53 ` Jean Louis
2021-06-02  9:28   ` Hongyi Zhao
2021-06-02  9:35     ` Hongyi Zhao
2021-06-02  6:57 ` Joost Kremers
2021-06-02  9:56   ` Hongyi Zhao
2021-06-02 10:04     ` Joost Kremers
2021-06-02 11:07       ` Jean Louis
2021-06-02 13:09   ` Hongyi Zhao
2021-06-02 14:05     ` Hongyi Zhao [this message]
2021-11-15  7:37 ` Thien-Thi Nguyen
2021-11-15  7:44   ` Hongyi Zhao
2021-11-15  9:12     ` Thien-Thi Nguyen
2021-11-15 11:25       ` Hongyi Zhao
2021-11-15 12:12         ` Thien-Thi Nguyen
2021-11-15 23:35           ` Hongyi Zhao
2021-11-16  0:24             ` Hongyi Zhao
2021-11-17  3:26               ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-17  4:31                 ` Hongyi Zhao
2021-11-17 14:27                   ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-18  2:33                     ` Hongyi Zhao
2021-11-20  3:13           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-11-26 20:56             ` Samuel Banya
2021-11-27  3:22               ` Hongyi Zhao
2021-11-27 21:45                 ` Samuel Banya
2021-11-27 21:52                   ` Samuel Banya
2021-11-28  2:59                     ` Hongyi Zhao
2021-11-27 23:04                       ` Samuel Banya
2021-11-28  4:38                     ` Emanuel Berg via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGP6PO+gKaRAZT0PCMPqjwWy6mFmP+XQUQ2bGRfa-v=VByoEuA@mail.gmail.com' \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=joostkremers@fastmail.fm \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.