From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Open multiple separate terminal buffers with multi-term in Emacs. Date: Wed, 2 Jun 2021 22:05:26 +0800 Message-ID: References: <87k0ncd9kd.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1060"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 02 16:06:14 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1loRVd-000AS5-JH for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 02 Jun 2021 16:06:13 +0200 Original-Received: from localhost ([::1]:42684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRVc-00079a-ID for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 02 Jun 2021 10:06:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRVC-000785-SE for help-gnu-emacs@gnu.org; Wed, 02 Jun 2021 10:05:46 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:35659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loRV8-0002vL-1E for help-gnu-emacs@gnu.org; Wed, 02 Jun 2021 10:05:46 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id f12so2772520ljp.2 for ; Wed, 02 Jun 2021 07:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7mwbBdKbJQNlQXD7o920Ag+0TUdMJNAlJ3RPQT6bYkc=; b=g3LOovZ0YG4QsL7NSirGssg9oxaV3Bxq3xHbY98OcvT96oZTOn0NGUuTImOJyogvkH waSJNod/aYhdk+b3hL/bgPU2Sm+cLr5C0dfI59hpFjVYHS310v0IEXopVIP/O53k+Um8 ANEKGVp7xsIrSmGkV7uKt/fOfV/V7s3Ki+Z/vNoS6PPGOnslzRrNOF/1Vlw/0jQcTCd5 DFWGLmhop7LpMFp8jsD3u2TeIa3ZvUVSS91krLDmsieW/6zN4+v9KcVge1Qpjozoro6h cOT82+5qqpG8sIelT6i3+ed0alG1LGO/CZ+kF0TjUBiBFE6sIb0/uheqmT4BO9C8eB+4 r6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7mwbBdKbJQNlQXD7o920Ag+0TUdMJNAlJ3RPQT6bYkc=; b=AGBxXIuYtYV8eZVBi9Z7y8lPLZx4peiDNSKYCiaML5EaAktHM27fZuDULvfWMlBlpN U/wl0cAuDBT+Vs8pBv0H6MerW0i31Ija49CgnALr7EFzqVK0GQHXBreiPet1Z3kuQxkk cUp16ICv9FlUucUPQt3nDlOlq4zKH40Cs2eXwkztsnDsHVM1cKvsfkuzL8IW3YQ4O2Rk lMiTKVtin0M7qyF+roRCMzaaTPIfv/PkiiAwvmllIoFONOhCDa1hUjojEgXCLDBFJ+wl STJO30CiT3WEcFv4P5DL+A3siMB9+sNLyi0il5e8x1djeZHNwkiQYINnjTLKjRGfZTEg XBGw== X-Gm-Message-State: AOAM5338+GID7P+PDEuIdBoY5RIKNxJNkVE+UF9miDEZdBkaLJ4GBaca nUeWL0RvMr31IFWVJyNFGub07bFWFS2IkbwV+vk= X-Google-Smtp-Source: ABdhPJx3uJ13jJZYyXbRGaNp1ny6RgU8HMmE8OPUEVcIxi2a35+LHdbq1sUbXW12TEypbaDr9hwlAIkiat7qCJBV08U= X-Received: by 2002:a2e:a0c7:: with SMTP id f7mr25722052ljm.13.1622642738226; Wed, 02 Jun 2021 07:05:38 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130500 Archived-At: On Wed, Jun 2, 2021 at 9:09 PM Hongyi Zhao wrote: > > On Wed, Jun 2, 2021 at 3:12 PM Joost Kremers wrote: > > > > > > On Wed, Jun 02 2021, Hongyi Zhao wrote: > > > According to the tricks mentioned here, > > > , > > > 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 ) > > 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 : ;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 Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering NO. 552 North Gangtie Road, Xingtai, China