[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/m-buffer e648a9d6ca 084/115: m-buffer-apply-snoc replac
From: |
ELPA Syncer |
Subject: |
[elpa] externals/m-buffer e648a9d6ca 084/115: m-buffer-apply-snoc replaced. |
Date: |
Tue, 19 Jul 2022 15:58:51 -0400 (EDT) |
branch: externals/m-buffer
commit e648a9d6cad72ea4ec4977a063b55a24d859a93b
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
m-buffer-apply-snoc replaced.
This function has now been replaced with m-buffer-apply-join which is a
somewhat better name. The implementation of the function now includes
some error checking which makes it an error to define the same keyword
argument in two places.
---
m-buffer.el | 50 ++++++++++++++++++++++++++++++++++----------------
test/m-buffer-test.el | 6 ++++++
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/m-buffer.el b/m-buffer.el
index cdbc4d75f0..099c762f5c 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -623,17 +623,35 @@ Remove all properties from return."
;; Emacs comes with a set of in-built regexps most of which we use here.
-;; We define `m-buffer-apply-snoc' first. The reason for this function is that
+;; We define `m-buffer-apply-join' first. The reason for this function is that
;; we want to take a list of match arguments and add to with, for instance, a
;; regular expression. We need to add these at the end because most of our
;; functions contain some positional arguments.
;; #+begin_src emacs-lisp
-(defun m-buffer-apply-snoc (fn list &rest element)
- "Apply FN to LIST and all ELEMENT."
- (apply
- fn (append list element)))
+(defun m-buffer-apply-join (fn match &rest more-match)
+ (let*
+ ((args
+ (-take-while
+ (lambda (x) (not (keywordp x)))
+ match))
+ (pargs
+ (-drop-while
+ (lambda (x) (not (keywordp x)))
+ match))
+ (more-keywords
+ (-map
+ 'car
+ (-partition 2 more-match))))
+ (when
+ (-first
+ (lambda (keyword)
+ (plist-member pargs keyword))
+ more-keywords)
+ (error
+ "Match arg contradicts a defined argument."))
+ (apply fn (append args more-match pargs))))
;; #+end_src
;; For the following code, we use Emacs core regexps where possible.
@@ -643,7 +661,7 @@ Remove all properties from return."
"Return a list of match data to all pages in MATCH.
MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc 'm-buffer-match
+ (m-buffer-apply-join 'm-buffer-match
match :regexp page-delimiter))
;; #+end_src
@@ -655,7 +673,7 @@ MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match data to `paragraph-separate' in MATCH.
MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for futher details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match match :regexp paragraph-separate
:post-match 'm-buffer-post-match-forward-line))
@@ -667,7 +685,7 @@ MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match data to all lines.
MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS.
See `m-buffer-match for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match
match :regexp m-buffer--line-regexp
:post-match 'm-buffer-post-match-forward-char))
@@ -676,7 +694,7 @@ See `m-buffer-match for further details."
"Return a list of match data to all line start.
MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match-begin
match :regexp "^"
:post-match 'm-buffer-post-match-forward-char))
@@ -685,7 +703,7 @@ MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match to line end.
MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match-begin
match :regexp "$"
:post-match 'm-buffer-post-match-forward-char))
@@ -700,7 +718,7 @@ MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a match to the first line of MATCH.
This matches more efficiently than matching all lines and taking
the car. See `m-buffer-match' for further details of MATCH."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match match
:regexp m-buffer--line-regexp
:post-match (lambda () nil)))
@@ -715,7 +733,7 @@ the car. See `m-buffer-match' for further details of
MATCH."
"Return a list of match to sentence end.
MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match-begin
match :regexp (sentence-end)))
@@ -723,7 +741,7 @@ MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match to all words.
MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match
match :regexp "\\\w+"))
@@ -731,7 +749,7 @@ MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match to all empty lines.
MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match
match :regexp "^$"
:post-match 'm-buffer-post-match-forward-line))
@@ -740,7 +758,7 @@ MATCH is of the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
"Return a list of match to all non-empty lines.
MATCH is fo the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
`m-buffer-match' for further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match
match :regexp "^.+$"))
@@ -749,7 +767,7 @@ MATCH is fo the form BUFFER-OR-WINDOW MATCH-OPTIONS. See
Note empty lines are not included. MATCH is of form
BUFFER-OR-WINDOW MATCH-OPTIONS. See `m-buffer-match' for
further details."
- (m-buffer-apply-snoc
+ (m-buffer-apply-join
'm-buffer-match
match :regexp "^\\s-+$"))
diff --git a/test/m-buffer-test.el b/test/m-buffer-test.el
index fcb3d66960..f81763fdef 100644
--- a/test/m-buffer-test.el
+++ b/test/m-buffer-test.el
@@ -401,4 +401,10 @@ should not have moved."
"one")
(point)))))
+(ert-deftest match-error ()
+ "Should error because we try to override existing args."
+ (should-error
+ (m-buffer-match-word
+ (current-buffer) :regexp "notword")))
+
;;; m-buffer-test.el ends here
- [elpa] externals/m-buffer 970b87f18d 093/115: Port tests to new travis infrastructure., (continued)
- [elpa] externals/m-buffer 970b87f18d 093/115: Port tests to new travis infrastructure., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 57c3d829d3 094/115: Oops., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 22660c5385 096/115: New function - m-buffer-at-string, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 883e6192e9 097/115: Benchmark extension changed., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer cf99d4209a 102/115: New function `m-buffer-match-multi', ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer b402420640 108/115: Remove CSS which is provided by lentic, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 7ce1c15e0b 110/115: Update documentation entry point, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 6eb1d2535a 112/115: v0.15 Release, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 042fe80d95 057/115: Checkdoc before 0.6 release., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer c637ea3bf2 077/115: Prepare for next iteration., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer e648a9d6ca 084/115: m-buffer-apply-snoc replaced.,
ELPA Syncer <=
- [elpa] externals/m-buffer d9682aa359 086/115: Prepare for 0.11 release., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 49a0c187a1 026/115: Name changes: markers to marker, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 45ad6de33d 041/115: Documentaion update for cask move., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 69750033c2 043/115: m-buffer-replace-matches has more arguments., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer a3078a58ed 055/115: exact-subtract no longer crashes on last non-match, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 55eb7c058f 059/115: Prepare for next iteration., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer c2ea6f72b9 060/115: m-buffer-first-line added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 63a46e6732 063/115: m-buffer-in-match-p added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3df675024f 064/115: New functions added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 69cf1fb326 066/115: Documentation updates., ELPA Syncer, 2022/07/19