이전 emacs에서 "M-x 셸"은 현재 창에서 셸 버퍼를 새로 도입했습니다.다른 창에서 M-x 셸 오픈 셸
하지만 최근에 이맥스를 GNU Emacs 26.0.50.2로 업데이트합니다. "M-x shell"은 다른 창에 쉘 버퍼를 새로 추가했습니다. 나는 Google을 검색하고 대답을 찾을 수 없었다. 누구든지이 동작을 방지하는 방법을 알고 있습니다.
이전 emacs에서 "M-x 셸"은 현재 창에서 셸 버퍼를 새로 도입했습니다.다른 창에서 M-x 셸 오픈 셸
하지만 최근에 이맥스를 GNU Emacs 26.0.50.2로 업데이트합니다. "M-x shell"은 다른 창에 쉘 버퍼를 새로 추가했습니다. 나는 Google을 검색하고 대답을 찾을 수 없었다. 누구든지이 동작을 방지하는 방법을 알고 있습니다.
이유 shell
는 (pop-to-buffer buffer)
(switch-to-buffer buffer)
대신 사용한다는 것이다. 기능을 조언하는 방법을 모르겠으므로 적절한 대답을 드릴 수는 없습니다. 그러나 원하는 경우에만 shell
을 원한다면 설정에 전체 기능을 추가 할 수 있습니다.
다른 사람이이 기능을 조언으로 바꿀 수도 있습니다. 나는 그 해결책에 관심이있을 것이다.
(defun shell (&optional buffer)
"Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*').
Interactively, a prefix arg means to prompt for BUFFER.
If `default-directory' is a remote file name, it is also prompted
to change if called with a prefix arg.
If BUFFER exists but shell process is not running, make new shell.
If BUFFER exists and shell process is running, just switch to BUFFER.
Program used comes from variable `explicit-shell-file-name',
or (if that is nil) from the ESHELL environment variable,
or (if that is nil) from `shell-file-name'.
If a file `~/.emacs_SHELLNAME' exists, or `~/.emacs.d/init_SHELLNAME.sh',
it is given as initial input (but this may be lost, due to a timing
error, if the shell discards input when it starts up).
The buffer is put in Shell mode, giving commands for sending input
and controlling the subjobs of the shell. See `shell-mode'.
See also the variable `shell-prompt-pattern'.
To specify a coding system for converting non-ASCII characters
in the input and output to the shell, use \\[universal-coding-system-argument]
before \\[shell]. You can also specify this with \\[set-buffer-process-coding-system]
in the shell buffer, after you start the shell.
The default comes from `process-coding-system-alist' and
`default-process-coding-system'.
The shell file name (sans directories) is used to make a symbol name
such as `explicit-csh-args'. If that symbol is a variable,
its value is used as a list of arguments when invoking the shell.
Otherwise, one argument `-i' is passed to the shell.
\(Type \\[describe-mode] in the shell buffer for a list of commands.)"
(interactive
(list
(and current-prefix-arg
(prog1
(read-buffer "Shell buffer: "
;; If the current buffer is an inactive
;; shell buffer, use it as the default.
(if (and (eq major-mode 'shell-mode)
(null (get-buffer-process (current-buffer))))
(buffer-name)
(generate-new-buffer-name "*shell*")))
(if (file-remote-p default-directory)
;; It must be possible to declare a local default-directory.
;; FIXME: This can't be right: it changes the default-directory
;; of the current-buffer rather than of the *shell* buffer.
(setq default-directory
(expand-file-name
(read-directory-name
"Default directory: " default-directory default-directory
t nil))))))))
(setq buffer (if (or buffer (not (derived-mode-p 'shell-mode))
(comint-check-proc (current-buffer)))
(get-buffer-create (or buffer "*shell*"))
;; If the current buffer is a dead shell buffer, use it.
(current-buffer)))
;; On remote hosts, the local `shell-file-name' might be useless.
(if (and (called-interactively-p 'any)
(file-remote-p default-directory)
(null explicit-shell-file-name)
(null (getenv "ESHELL")))
(with-current-buffer buffer
(set (make-local-variable 'explicit-shell-file-name)
(file-remote-p
(expand-file-name
(read-file-name
"Remote shell path: " default-directory shell-file-name
t shell-file-name))
'localname))))
;; The buffer's window must be correctly set when we call comint (so
;; that comint sets the COLUMNS env var properly).
(switch-to-buffer buffer)
(unless (comint-check-proc buffer)
(let* ((prog (or explicit-shell-file-name
(getenv "ESHELL") shell-file-name))
(name (file-name-nondirectory prog))
(startfile (concat "~/.emacs_" name))
(xargs-name (intern-soft (concat "explicit-" name "-args"))))
(unless (file-exists-p startfile)
(setq startfile (concat user-emacs-directory "init_" name ".sh")))
(apply 'make-comint-in-buffer "shell" buffer prog
(if (file-exists-p startfile) startfile)
(if (and xargs-name (boundp xargs-name))
(symbol-value xargs-name)
'("-i")))
(shell-mode)))
buffer)
감사합니다. 기능을 업데이트하려고합니다. – yuandaxing
이 답변은 OP가 이전과 같은 동작을하지 않는 이유를 설명하지 않습니다. Emacs 명령'shell'은 항상'pop-to-buffer'를 사용하여 적어도 Emacs 20으로 돌아갑니다. – Drew
사실, 최근의 Emacs 버전에서는'shell'은'pop-to-buffer-same-window'를 사용합니다. – Drew
는 쉘 버퍼의 이름을 사용자 정의하지 않는 한,이 모두를해야 다음이 필요합니다
(add-to-list 'display-buffer-alist
`(,(regexp-quote "*shell") display-buffer-same-window))
, 당신이 조언을 사용할 수 있습니다, 어떤 이름을 모든 쉘 버퍼를 처리하기 위해 :
(defun shell-same-window-advice (orig-fn &optional buffer)
"Advice to make `shell' reuse the current window.
Intended as :around advice."
(let* ((buffer-regexp
(regexp-quote
(cond ((bufferp buffer) (buffer-name buffer))
((stringp buffer) buffer)
(:else "*shell*"))))
(display-buffer-alist
(cons `(,buffer-regexp display-buffer-same-window)
display-buffer-alist)))
(funcall orig-fn buffer)))
(advice-add 'shell :around #'shell-same-window-advice)
당신의 이맥스 파일에서이 줄을 추가
(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist)
이렇게 수정되었습니다. 저는 Mac에서 eMacs 25.2 (9.0)을 사용하고 있으며, 다른 프레임에서 껍데기가 열리거나, 새로운 프레임이있을 때 정말 짜증이났습니다. This is the source 나는이 대답을 어디서 얻었 는가.
저 또한 나를 위해 일했습니다. 감사! –
변수'pop-up-windows'를'nil'으로 설정하십시오. 그게 문제를 해결합니까? – Drew