• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Buffer interface library for Emacs

https://img.shields.io/badge/license-GPL_3-orange.svg http://melpa.org/packages/bui-badge.svg http://stable.melpa.org/packages/bui-badge.svg

About

BUI (Buffer User Interface) is an Emacs library that can be used to make user interfaces to display some kind of entries (like packages, buffers, functions, etc.).

The intention of BUI is to be a high-level library which is convenient to be used both by:

  • package makers, as there is no need to bother about implementing routine details and usual features (like buffer history, filtering displayed entries, etc.);
  • users, as it provides familiar and intuitive interfaces with usual keys (for moving by lines, marking, sorting, switching between buttons); and what is also important, the defined interfaces are highly configurable through various generated variables. A summary of available key bindings can be displayed by pressing h.

Usage

BUI provides means to display entries in 2 types of buffers:

  • list: it is based on tabulated-list-mode, thus it looks similar to a list of Emacs packages (M-x list-packages);
  • info: it can be used to display more verbose info, like various buttons, text and other stuff related to the displayed entry (or entries).

In short, you define how a list / info interface looks like (using bui-define-interface macro), and then you can make some user commands that will display entries (using bui-get-display-entries and similar functions).

For example, you can make a list interface to display buffers (similar to what M-x list-buffers do), like this:

(require 'bui)

(defun buffers-buffer->entry (buffer)
  (with-current-buffer buffer
    `((id   . ,buffer)
      (name . ,(buffer-name))
      (mode . ,major-mode)
      (size . ,(buffer-size))
      (file-name . ,buffer-file-name))))

(defun buffers-get-entries ()
  (mapcar 'buffers-buffer->entry (buffer-list)))

(bui-define-interface buffers list
  :buffer-name "*Buffers*"
  :get-entries-function 'buffers-get-entries
  :format '((name nil 30 t)
            (mode nil 25 t)
            (size nil 8 bui-list-sort-numerically-2 :right-align t)
            (file-name bui-list-get-file-name 30 t))
  :sort-key '(name))

(defun buffers ()
  "Display a list of buffers."
  (interactive)
  (bui-get-display-entries 'buffers 'list))

This is a simplified example just to demonstrate how bui.el can be used. For full example see examples/buffers.el. You can see how it looks like on the following screenshot. M-x buffers displays a list of buffers, then 2 buffers are marked (with m key) and โ€œdescribedโ€ in info buffer (with i key).

http://i.imgur.com/3dlBu2Y.png

bui-define-interface macro takes the following arguments:

  • ENTRY-TYPE: an arbitrary symbol to denote the entry type.
  • BUFFER-TYPE: list or info symbol.
  • Keyword arguments: used to define various interface parameters and to set default values of user variables (like titles, buffer name, etc.). The main keywords that should be specified are:
    • :get-entries-function: this function should return a list of entries to display. Each entry is a usual association list with one required id key (it is used to fill tabulated-list-entries variable).
    • :format: it specifies how the data is displayed; see docstrings of the generated ENTRY-TYPE-BUFFER-TYPE-format variables for details (in the current example: buffers-list-format and buffers-info-format).

For real-world examples you may look at aurel or guix packages.

More Repositories

1

guix.el

Emacs interface for GNU Guix package manager
Emacs Lisp
141
star
2

alect-themes

Configurable custom themes for GNU Emacs
Emacs Lisp
106
star
3

mwim.el

Move to the beginning/end of line, code or comment
Emacs Lisp
81
star
4

guix-config

My config for GuixSD
Scheme
71
star
5

stumpwm-config

My configuration files for StumpWM
Common Lisp
71
star
6

aurel

Search, vote for and download AUR packages from Emacs
Emacs Lisp
52
star
7

systemd-user-units

My systemd user units for managing X sessions
31
star
8

dim.el

Change mode-line names of major/minor modes
Emacs Lisp
25
star
9

config

My "dot" (configuration) files
Scheme
22
star
10

emacs-config

My ".emacs"
Emacs Lisp
19
star
11

shepherd-config

My Shepherd user services
Scheme
17
star
12

ducpel

Logic game for Emacs
Emacs Lisp
17
star
13

org-ref-prettify.el

Minor mode for prettifying org-ref citation links
Emacs Lisp
14
star
14

guile-daemon

Evaluate code in a running Guile process
Scheme
13
star
15

make-color.el

"Pick" a color the hard way (Emacs package)
Emacs Lisp
13
star
16

shift-number.el

Increase/decrease the number at point
Emacs Lisp
12
star
17

xdpyprobe

Check connection to X server DISPLAY
C
9
star
18

debpaste.el

Emacs client for http://paste.debian.net/
Emacs Lisp
7
star
19

build-farm.el

Interface for Hydra and Cuirass (Nix and Guix build farms)
Emacs Lisp
7
star
20

guile-xosd

Guile bindings for libxosd
C
5
star
21

emms-state.el

Display track info in the mode line
Emacs Lisp
5
star
22

pretty-sha-path.el

Prettify Guix/Nix store paths in Emacs
Emacs Lisp
5
star
23

imenus.el

Imenu for multiple buffers
Emacs Lisp
4
star
24

point-pos.el

Save and restore point positions
Emacs Lisp
4
star
25

date-at-point.el

Add 'date' thing to 'thing-at-point' function
Emacs Lisp
3
star
26

emacs-utils

(OBSOLETE) My additional functions for Emacs
Emacs Lisp
3
star
27

dvorak-layouts.el

Input methods for the dvorak system layout
Emacs Lisp
3
star
28

guile-config

My guile modules and scripts
Scheme
2
star
29

xdaemon

Run X server as a daemon
Scheme
1
star
30

guile-daemon-config

My configuration for Guile-Daemon
Scheme
1
star
31

stumpwm-logo

My attempt to make the logo for StumpWM
1
star
32

shell-config

My shell configuration and scripts
Shell
1
star
33

my-guix

my guix configuration file(s) <https://www.gnu.org/software/guix/>
Scheme
1
star
34

pathify.el

Symlink your scripts into a PATH directory
Emacs Lisp
1
star