5.3 Mode Line Buffer List Menu Customization

The pop-up buffer list menu can be customized two ways:

  1. Customizing the variable anju-buffer-list-filter-functions, a list of filter functions that are run each time the pop-up menu is raised when left-clicking the mode line buffer name.
  2. Customizing the variable anju-mode-line-buffer-list-function, which gives a user complete control on what is displayed in the pop-up menu.

anju-buffer-list-filter-functions

This variable is an alist used by the function anju-buffer-list-menu-items to populate the list of buffers used in the pop up menu anju-popup-buffer-menu.

This alist is filled using the following key, value pair types:

key

a buffer list filter function

value

integer used as the maximum count of buffers to use from the filter function

The buffer list filter function is of the form (filter-fn (buffers &optional count)) where buffers is a list of buffers (usually buffer-list) and count is the maximum count of buffers to use.

The order of the buffer list presumes the most recently used buffers are at the front of the list.

Anju provides the following buffer filters:

anju-buffer-list-plain-filter

buffers whose name is not marked as special (a name wrapped in ‘*’).

anju-buffer-list-compilation-filter

buffers whose major mode is compilation-mode.

anju-buffer-list-grep-filter

buffers whose major mode is grep-mode.

anju-buffer-list-xref-filter

buffers whose major mode is xref--xref-buffer-mode.

anju-buffer-list-eshell-filter

buffers whose major mode is eshell-mode.

anju-buffer-list-shell-filter

buffers whose major mode is shell-mode.

anju-buffer-list-info-filter

buffers whose major mode is Info-mode.

anju-buffer-list-help-filter

buffers whose major mode is help-mode.

Users can customize anju-buffer-list-filter-functions to re-compose or add their own filters to define the resulting buffer list returned by anju-buffer-list-menu-items. It is recommended that the customize-variable command be used to accomplish this.

anju-mode-line-buffer-list-function

Function that populates the mode line buffer name popup menu.

Assign this variable to a function that returns a value that conforms to the MENU parameter of the command popup-menu.

This setting allows for customization of the buffer list (or any other menu content) when the mode line buffer name (identifier) is clicked (typically with mouse-1).

Users who wish define their own menu should override this value with their own function. It is recommended that such users look at the source to anju-buffer-list-menu-items as a start to defining their own menu function.