How to make *Buffer List* appear below the other windows?

前端 未结 1 1078
谎友^
谎友^ 2020-12-20 04:41

So, instead of creating a split window under (or to the right of) the currently active window, it would appear below all the existed ones with a half of the frame height? An

相关标签:
1条回答
  • 2020-12-20 05:28

    See also my previous answer to your related issue: https://stackoverflow.com/a/21544307/2112489

    See also a related answer by @phils, which includes a nice halve-other-window-height function: https://stackoverflow.com/a/4988206/2112489

    See also the built-in stock functions display-buffer-below-selected or display-buffer-at-bottom, which are available in a recent version of Emacs Trunk -- I'm not sure when each function was first introduced. They are in window.el.

    The doc-string of the function split-window states in relevant part:  SIZE defaults to half of WINDOW's size. That is the second optional argument -- i.e., split-window (&optional window size side pixelwise)

    Don't be shy about modifying these things -- you can make it do whatever you want. If want to select the window automatically after it is displayed, then you can add this to the bottom of the lawlist-display-buffer-below function:  (select-window (get-buffer-window (buffer-name buffer))) -- leaving, of course, two closing parenthesis to the right -- i.e., one closing parentheis for the let binding and one closing parenthesis for the defun.

    (defun lawlist-list-buffers-below (&optional arg)
      "Display a list of existing buffers.
    The list is displayed in a buffer named \"*Buffer List*\".
    See `buffer-menu' for a description of the Buffer Menu.
        By default, all buffers are listed except those whose names start
    with a space (which are for internal use).  With prefix argument
    ARG, show only buffers that are visiting files."
      (interactive "P")
      (lawlist-display-buffer-below (list-buffers-noselect arg) nil))
    
    (defun lawlist-display-buffer-below (buffer alist)
     (let (
        (window
          (cond
            ((get-buffer-window buffer (selected-frame)))
            ((window-in-direction 'below))
            (t
              (split-window (selected-window) nil 'below)))))
      (window--display-buffer buffer window 'window alist display-buffer-mark-dedicated)))
    
    0 讨论(0)
提交回复
热议问题