[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/m-buffer 5c46bf8102 017/115: Added function m-buffer-on
From: |
ELPA Syncer |
Subject: |
[elpa] externals/m-buffer 5c46bf8102 017/115: Added function m-buffer-on-region -- apply a function to a region. |
Date: |
Tue, 19 Jul 2022 15:58:45 -0400 (EDT) |
branch: externals/m-buffer
commit 5c46bf810250f3ef61fccff56e1522ee36aa26b6
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Added function m-buffer-on-region -- apply a function to a region.
---
m-buffer.el | 24 ++++++++++++++++++++++++
test/m-buffer-test.el | 13 +++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/m-buffer.el b/m-buffer.el
index 831d6e6b95..3ec9de5641 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -451,5 +451,29 @@ succeeds."
(error 'end-of-buffer
nil)))
+;;
+;; Apply function to things
+;;
+(defun m-buffer-on-region (fn match-data)
+ "Apply FN to MATCH-DATA.
+FN should take two args, the start and stop of each region.
+MATCH-DATA can be any list of lists with two elements (or more)."
+ (m-buffer-on-region-nth-group fn 0 match-data))
+
+(defun m-buffer-on-region-nth-group (fn n match-data)
+ "Apply FN to the Nth group of MATCH-DATA.
+FN should take two args, the start and stop of each region.
+MATCH-DATA can be any list of lists with two elements (or more)."
+ (-map
+ (lambda (x)
+ (apply fn x))
+ (m-buffer-match-nth-group n match-data)))
+
+;;
+;; Highlight things
+;;
+
+
+
(provide 'm-buffer)
;;; m-buffer.el ends here
diff --git a/test/m-buffer-test.el b/test/m-buffer-test.el
index e16cef1a8f..a6ede5da68 100644
--- a/test/m-buffer-test.el
+++ b/test/m-buffer-test.el
@@ -236,6 +236,15 @@
"\\(one\\)\\(two\\)")))))))
-
-
+(ert-deftest apply-functions ()
+ (should
+ (equal
+ '("onetwo" "onetwo" "onetwo" "onetwo" "")
+ (m-buffer-wtb-of-file
+ "nth.txt"
+ (m-buffer-on-region
+ (lambda (from to)
+ (buffer-substring-no-properties from to))
+ (m-buffer-match-line
+ (current-buffer)))))))
;;; m-buffer-test.el ends here
- [elpa] externals/m-buffer 5784538b01 034/115: v0.4 iteration., (continued)
- [elpa] externals/m-buffer 5784538b01 034/115: v0.4 iteration., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 354e1c6b2a 036/115: Change version suffix to alpha., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer dc5f6c4149 038/115: Version 0.4 release., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 72acc99a91 042/115: New function: m-buffer-delete-match, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 2803b1f9b6 048/115: Match functions now accept a :numeric arg., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer edfa6ef412 062/115: m-buffer-at added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer ce6dfb0023 006/115: Use Emacs var, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 84c7fddd48 008/115: Modifed match-data to use keyword args, except for first two args., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 25995a676e 009/115: README added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 22760408a5 013/115: Updated normalize tests to cope with extra widen argument., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 5c46bf8102 017/115: Added function m-buffer-on-region -- apply a function to a region.,
ELPA Syncer <=
- [elpa] externals/m-buffer 8210f4147d 004/115: Move dev to test., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 650235fbdb 011/115: Build URL update., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 22d6b0d640 012/115: Beginning has become begin. Widen option added. New line matching functions., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer c65b7b20c0 014/115: match-data-1 was failing on final match due to off-by-one error., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 1cc4d8cffb 015/115: Added functions: m-buffer-marker-tree-to-pos, m-buffer-match-nth-group., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 27380daef5 018/115: Functions to add overlays and properties to buffers., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 41384768bc 024/115: Merge pull request #1 from syohex/fix-typo, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer e4ec4daa87 027/115: replace-match now returns marker to the end of the replacements., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 41ca2908a3 032/115: Added documentation for four functions., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer b7c9738f31 037/115: Update readme for 0.4 release., ELPA Syncer, 2022/07/19