m-buffer is a package which provides a high-level convienience API for interacting, searching and changing the contents of an Emacs buffer. It abstracts away from Emacs’ use of global state, and provides list-orientated operations removing the need for explicit looping.
Hence, we can replace:
(while (re-search-forward "foo" nil t) (replace-match "bar"))
(m-buffer-replace-match (m-buffer-match (current-buffer) "foo") "bar")
m-buffer also protects global state, so the first form actually needs to be something closer to:
(save-excursion (goto-char (point-min)) (save-match-data (while (re-search-forward "foo" nil t) (replace-match "bar"))))
There have been a few changes since the 0.10 release (Lord 2015)*. The interface has been improved slightly (in a backward compatible way). In addition some error-checking has been added to pick up what I think was counter-intuitive behaviour. So, previously:
(m-buffer-match-page (current-buffer) **:regexp**"this")
would return all matches to “this” rather than pages.
The biggest change, however, has been the full use of lenticular source documentation (Lord 2015b)*, which provides a richer explanation of the code base. At the moment, I think that this is very usable, although I am aware that it is less clean than, for example, the documentation for dash, but it still is a nice demonstration of how lenticular text can work.
原文出处: Phillip Lord
原文时间: 2015-04-16 00:45
整理时间: 2015-04-16 13:35
本文由 Hick 整理，转载请保留以上信息;
The articles on this site come from Internet, thanks to all the original authors.
If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .