该函数ibuffer-update
使用buffer-list
,它包括所有帧。ibuffer-update
从使用修改buffer-list
为(frame-parameter (selected-frame) 'buffer-list)
接近您正在寻求的行为。基于相同概念的 ibuffer 过滤器也应该是可能的。
在我看来,每帧缓冲区列表(frame-parameter (selected-frame) 'buffer-list)
并不是将缓冲区与帧相关联的最佳方法,因为它太容易被修改。我见过的最好的方法是 Al Parker 的 frame-bufs: https ://github.com/alpaker/Frame-Bufs 这已更新为与当前版本的 Emacs 一起使用,但是,我使用的是稍微修改过的版本适合我自己的需要。
因此,我知道回答您的问题的最简单方法是使用 Al Parker 的帧缓冲区组合,并使用frame-bufs-buffer-list
inside ibuffer-update
。这给了你两全其美。这是一个示例,它将为您提供一个漂亮的 ibuffer,其中只有与给定帧关联的缓冲区——所有其他缓冲区都不会显示。[仅供参考:帧缓冲区也按模式或文件名排序。]
(require 'ibuffer)
(defalias 'ibuffer-update 'lawlist-ibuffer-update)
(defun lawlist-ibuffer-update (arg &optional silent)
"Regenerate the list of all buffers.
Prefix arg non-nil means to toggle whether buffers that match
`ibuffer-maybe-show-predicates' should be displayed.
If optional arg SILENT is non-nil, do not display progress messages."
(interactive "P")
(if arg
(setq ibuffer-display-maybe-show-predicates
(not ibuffer-display-maybe-show-predicates)))
(ibuffer-forward-line 0)
;; (let* ((bufs (buffer-list))
(let* ((bufs (frame-parameter (selected-frame) 'frame-bufs-buffer-list))
(blist (ibuffer-filter-buffers
(current-buffer)
(if (and
(cadr bufs)
(eq ibuffer-always-show-last-buffer
:nomini)
(minibufferp (cadr bufs)))
(cl-caddr bufs)
(cadr bufs))
(ibuffer-current-buffers-with-marks bufs)
ibuffer-display-maybe-show-predicates)))
(and (null blist)
(featurep 'ibuf-ext)
ibuffer-filtering-qualifiers
(message "No buffers! (note: filtering in effect)"))
(unless silent
(message "Updating buffer list..."))
(ibuffer-redisplay-engine blist arg)
(unless silent
(message "Updating buffer list...done")))
(if (eq ibuffer-shrink-to-minimum-size 'onewindow)
(ibuffer-shrink-to-fit t)
(when ibuffer-shrink-to-minimum-size
(ibuffer-shrink-to-fit)))
(ibuffer-forward-line 0)
;; I tried to update this automatically from the mode-line-process format,
;; but changing nil-ness of header-line-format while computing
;; mode-line-format is asking a bit too much it seems. --Stef
(setq header-line-format
(and ibuffer-use-header-line
ibuffer-filtering-qualifiers
ibuffer-header-line-format)))