How do I make this Emacs frame keep its buffer and not get resized?

前端 未结 4 1918
天涯浪人
天涯浪人 2020-12-03 02:59

My Emacs frame looks like this:

+---------------------------+
|             |             |
|             |             |
|             |      B      |
|             


        
相关标签:
4条回答
  • 2020-12-03 03:31

    If you don't want to be annoyed by window stealing and resizing, put the following lines in your .emacs for a definitive solution that works even with libraries like gud that tries to open a new frame when they can't steal your windows :

    (see this answer for info on the following advice)

    (defadvice pop-to-buffer (before cancel-other-window first)
      (ad-set-arg 1 nil))
    
    (ad-activate 'pop-to-buffer)
    
    ;; Toggle window dedication
    (defun toggle-window-dedicated ()
      "Toggle whether the current active window is dedicated or not"
      (interactive)
      (message
       (if (let (window (get-buffer-window (current-buffer)))
             (set-window-dedicated-p window 
                                     (not (window-dedicated-p window))))
           "Window '%s' is dedicated"
         "Window '%s' is normal")
       (current-buffer)))
    
    ;; Press [pause] key in each window you want to "freeze"
    (global-set-key [pause] 'toggle-window-dedicated)
    

    and customize pop-up-windows variable to nil.

    you could also use StickyWindows instead of window-dedicated feature.

    0 讨论(0)
  • 2020-12-03 03:32

    This one also works fine (for emacs 24) https://lists.gnu.org/archive/html/help-gnu-emacs/2007-05/msg00975.html

    (define-minor-mode sticky-buffer-mode
      "Make the current window always display this buffer."
      nil " sticky" nil
      (set-window-dedicated-p (selected-window) sticky-buffer-mode))
    
    0 讨论(0)
  • 2020-12-03 03:34

    One possibility is to dedicate the window to its buffer, using set-window-dedicated-p. This will not prevent the window from being resized manually, only protect it from being clobbered by display-buffer. For example,

    (add-hook 'shell-mode-hook
          (lambda ()
            (interactive)
            (set-window-dedicated-p (selected-window) 1)))
    

    Replace shell-mode-hook as necessary.

    0 讨论(0)
  • 2020-12-03 03:45

    You could use winner-mode to be able to undo the changes to be the window sizes.

    You could also explicitly save and restore the window configuration in registers.

    0 讨论(0)
提交回复
热议问题