4

shell-modeEmacs では/は好きではありませeshell-modezsh

xterm外部サブプロセスとして使用したいと考えています。

(global-set-key (kbd "M-<f2>")
                (lambda () (interactive)
                  (start-process "XTerm" nil "xterm")))

そして今、xterm の PWD は Emacs と同期されdefault-directory、タームは完全な機能を備えたものになりました。しかし、問題が 1 つあります。サブルーチンの起動時間は常に期待外れです。

したがって、xterm を 1 回だけ起動し、Emacs でXTerm実行中というサブプロセスが見つかった場合は、1) サブプロセスに切り替え、2) xterm で実行されているシェルの PWD をdefault-directoryEmacs に設定します。

そうすることは可能ですか?

どちらも不可能な場合、 でtmuxこの目標を達成できますか?

4

2 に答える 2

2

これが私のセットアップです:

(defvar terminal-process)
(defun terminal ()
  "Switch to terminal. Launch if nonexistant."
  (interactive)
  (if (get-buffer "*terminal*")
      (switch-to-buffer "*terminal*")
    (term "/bin/bash"))
  (setq terminal-process (get-buffer-process "*terminal*")))

(global-set-key "\C-t" 'terminal)

起動時間について詳しく教えてください。私のは約0.3秒です。

diredUPD私のカスタマイズからの小さなスニペット

私はdiredセットアップでこれを持っています:

(add-hook
 'dired-mode-hook
 (lambda()
   (define-key dired-mode-map (kbd "`")
     (lambda()(interactive)
       (let ((current-dir (dired-current-directory)))
         (term-send-string
          (terminal)
          (format "cd %s\n" current-dir)))))))

どこにterminalある:

(defun terminal ()
  "Switch to terminal. Launch if nonexistant."
  (interactive)
  (if (get-buffer "*terminal*")
      (switch-to-buffer "*terminal*")
    (term "/bin/bash"))
  (setq terminal-process (get-buffer-process "*terminal*")))

これが行うことは、dired バッファと同じディレクトリのターミナルを開き、既存のものを再利用する*terminal*か、存在しない場合は新しいものを作成することです。

あなたの質問への答えを要約すると:

はい、可能です。それはで行われます:

(term-send-string
 (terminal)
 (format "cd %s\n" default-directory))
于 2013-07-23T14:58:44.313 に答える
0

xterm が難しい要件ではなく、何らかの方法で emacs から zsh を起動することだけが必要な場合は、AnsiTerm、または私の好みのMultiTermを見てください。それらは emacs に端末エミュレーター (xterm など) を実装しているため、バッファー内で任意の端末アプリケーション (zsh など) を実行できます。私が MultiTerm を気に入っているのは、デフォルトの IMO が優れているからです。

次に、ディレクトリを変更できます

(defun term-send-cd (&optional dir)
  (interactive "DDirectory: ")
  (let ((dir (if dir (expand-file-name dir) "")))
    (term-send-raw-string (format "cd '%s'\n" dir))))
于 2013-07-26T15:18:58.540 に答える