Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

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

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? And, after closing, frame layout would be restored as it was before calling C-x C-b?

I’d like see the full paths to opened files.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...