m-buffer provides functions for accessing and manipulating the contents of an Emacs buffer. While Emacs already provides these features, m-buffer provides a higher-level interaction. It achieves this in several ways: many of the functions are list-orientated, so avoiding the need for iteration; it avoids the use of global emacs state whenever it can be avoided, so avoiding side-effects; and it provides a large library of functions supporting common operations.
Core usage of buffer m-buffer is simple. For example, the following code returns a list of all matches to the regexp “m-buffer” in the `current-buffer`.
(m-buffer-match
(current-buffer)
"m-buffer")
m-buffer is also expanding. Other parts of m-buffer provide stateless interaction with the existing buffer; for example, we can use the following to fetch the point of any buffer:
(m-buffer-at-point buffer)
These functions can help greatly when writing code which operates on two or more buffers. It is also possible to check whether the status of a location – either a buffer and position or a marker. For example, these calls are equivalent to `eolp`.
(m-buffer-at-eolp buffer position)
(m-buffer-at-eolp marker)
`m-buffer’ is a work in progress, but much of it is now stable and the interface should change only in forward-compatible ways for 1.0 release. The individual files have statements about their stability.
m-buffer.el provides list-orientated search both for any regexp and standard regexps, as well as the ability to do things with these matches: replace, add overlays or text-properties or, most generically of all, call any function on matches.
m-buffer-at.el provides a set of stateless functions which for accessing data about buffers, without requiring changing the `current-buffer’.
m-buffer-macro.el provides some general purpose macros for:
- dealing with markers and their cleanup
- running code at a specific location
m-buffer-benchmark.el provides no functions, but is a set of benchmarks to give some idea of how much overhead various m-buffer functions entail.
Full lentic documentation using lentic-server
Completion of m-buffer-at with all the core buffer functions.