Emacs 24를 사용한다고 가정합니다. 이전 버전에서는이 답변을 테스트하지 않았으며 전용 창의 개념이 Emacs에 언제 추가되었는지 알 수 없습니다. 나는 2011 년부터 어떤 날짜를 사용했는지 언급 했으므로 Emacs 23 (적어도)에도 기능이 있다고 가정합니다.
윈도우를 버퍼 전용 으로 지정하여 Emacs가 지정된 윈도우에서 새 버퍼를 열지 못하게 할 수 있습니다 .
가장 간단한 경우, 전용하려는 창을 선택하여 현재 전용 버퍼를 표시 한 다음 수행하여이를 수행 할 수 M-: (set-window-dedicated-p (selected-window) t)
있습니다. 이렇게하면 버퍼를 표시 할 창을 결정할 때 Emacs가 수정 된 창을 고려하지 않습니다. 헌신을 제거하려면 동일한 표현식을 평가하여 두 번째 인수를로 바꾸십시오 nil
.
Emacs가 주어진 버퍼를 표시하는 윈도우를 분할하려고 시도하는 것을 방지 할 수 있습니다. 버퍼-로컬 변수 window-size-fixed를 0이 아닌 값으로 설정하십시오.
가장 간단한 경우에는 창을 선택하고을 수행하여이 작업을 수행 할 수 있습니다 M-: (setq window-size-fixed t)
. 버퍼를 표시하는 창의 높이 또는 너비 만 수정하려면 동일한 표현식을 평가 'height
하거나 'width
두 번째 인수로 전달하십시오. 제한을 제거하려면 두 번째 인수를로 바꾸십시오 nil
.
일반적인 경우, 문제를 해결하기에 충분히 흥미로운 문제를 발견 했습니다.이 경로는로드 경로에 들어가서 (require)
사용할 수 있습니다.
;;; dedicate-windows-manually.el --- Manually (un)dedicate windows
;; Copyright (C) 2013 Aaron Miller
;; <me@aaron-miller.me>
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA
;;; Commentary:
;; Introduction
;; ============
;; The functions here defined allow you to manually dedicate and
;; undedicate windows, that is, prevent `set-window-buffer' from
;; considering them when selecting a window in which to display a
;; given buffer.
;; Windows dedicated in this fashion will also be protected from
;; splitting by setting `window-size-fixed'.
;; Installation
;; ============
;; Place this file in your load path; then, place the following
;; command somewhere in your initialization file:
;; (require 'dedicate-windows-manually)
;; Now you can use M-x dedicate-window to dedicate the selected window
;; to its currently displayed buffer, M-x undedicate-window to release
;; a dedication so applied, and M-x dedicate-window-toggle to switch
;; between the states.
;; These functions will operate only on manually dedicated or
;; undedicated windows; that is, M-x dedicate-window will not dedicate
;; a window which is already dedicated (i.e. "(window-dedicated-p
;; window) -> t", and M-x undedicate-window will not undedicate a
;; window which was not dedicated by way of M-x dedicate-window.
;; If you find yourself frequently doing M-x dedicate-window-toggle,
;; you might wish to place something like this in your init file:
;; (global-set-key (kbd "C-x 4 C-d") 'dedicate-window-toggle)
;; Bugs:
;; * Changing the lighter string while you have windows dedicated is
;; probably not a good idea.
;; * I should certainly find a better way to change the mode line.
;;; Code:
(defcustom dedicated-window-lighter-string " [D]"
"A string, propertized with `dedicated-window-lighter-face', prepended
to the mode line of manually dedicated windows.")
(defvar dedicated-windows-by-hand nil
"A list of windows known to have been manually dedicated. Windows not
in this list will not be undedicated by `undedicate-window'.")
(defun dedicate-window-was-by-hand-p (window)
(let ((result nil))
(loop for w in dedicated-windows-by-hand
collect (if (eq w window) (setq result t)))
result))
(defun dedicate-window (&optional window flag)
"Dedicate a window to its buffer, and prevent it from being split.
Optional argument WINDOW, if non-nil, should specify a window. Otherwise,
or when called interactively, the currently selected window is used.
Optional argument FLAG, if non-nil, will be passed verbatim to
`set-window-dedicated-p'."
(interactive nil)
(if (eq nil window) (setq window (selected-window)))
(if (eq nil flag) (setq flag t))
(if (window-dedicated-p window)
(message "Window is already dedicated.")
(progn
(add-to-list 'dedicated-windows-by-hand window)
(setq mode-line-format
(append `(,dedicated-window-lighter-string) mode-line-format))
(setq window-size-fixed t)
(set-window-dedicated-p window flag))))
(defun undedicate-window (&optional window)
"Un-dedicate a window from its buffer.
Optional argument WINDOW, if non-nil, should specify a window listed in
`dedicated-windows-by-hand'. Otherwise, or when called interactively,
the currently selected window is used.
If WINDOW is not in `dedicated-windows-by-hand', a complaint will be
issued and nothing will be done."
(interactive nil)
(if (eq nil window) (setq window (selected-window)))
(if (not (window-dedicated-p window))
(message "Window is not dedicated.")
(if (not (dedicate-window-was-by-hand-p window))
(message "Window is not dedicated by hand.")
(progn
(setq dedicated-windows-by-hand
(remove window dedicated-windows-by-hand))
(setq mode-line-format
(remove dedicated-window-lighter-string mode-line-format))
(setq window-size-fixed nil)
(set-window-dedicated-p window nil)))))
(defun dedicate-window-toggle (&optional window)
"Toggle a window's manual buffer dedication state.
Optional argument WINDOW, if non-nil, should specify a window. Otherwise,
or when called interactively, the value of `selected-window' is used."
(interactive nil)
(if (eq nil window) (setq window (selected-window)))
(if (window-dedicated-p window)
(undedicate-window window)
(dedicate-window window)))
(provide 'dedicate-windows-manually)
;;; dedicate-windows-manually.el ends here