summaryrefslogtreecommitdiff
path: root/m-buffer-doc.org
blob: 5e7dff172a32bb1667643316d5670e9f50d0c665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

#+TITLE: Manipulate the Contents of Emacs Buffers
#+AUTHOR: Phillip Lord

# FIXME: In Emacs≄30, we could drop most of this.
#+TEXINFO_DIR_CATEGORY: Emacs
#+TEXINFO_DIR_TITLE: * m-buffer: (m-buffer-doc).
#+TEXINFO_DIR_DESC: Manipulate the Contents of Emacs Buffers

#+INFOJS_OPT: view:info toc:nil


* Introduction

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`.

#+BEGIN_SRC elisp
  (m-buffer-match
   (current-buffer)
   "m-buffer")
#+END_SRC

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:

#+BEGIN_SRC elisp
  (m-buffer-at-point buffer)
#+END_SRC

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`.

#+BEGIN_SRC elisp
 (m-buffer-at-eolp buffer position)
 (m-buffer-at-eolp marker)
#+END_SRC



** Status

`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

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.

#+include: "m-buffer.org" :minlevel 2


* m-buffer-at

m-buffer-at.el provides a set of stateless functions which for accessing data
about buffers, without requiring changing the `current-buffer'.

#+include: "m-buffer-at.org" :minlevel 2


* m-buffer-macro

m-buffer-macro.el provides some general purpose macros for:
 
 - dealing with markers and their cleanup
 - running code at a specific location

#+include: "m-buffer-macro.org" :minlevel 2


* m-buffer-benchmark

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.

#+include: "m-buffer-benchmark.org" :minlevel 2


* Roadmap

** 0.11

Full lentic documentation using lentic-server


** 0.12

Completion of m-buffer-at with all the core buffer functions.