emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/m-buffer 72acc99a91 042/115: New function: m-buffer-del


From: ELPA Syncer
Subject: [elpa] externals/m-buffer 72acc99a91 042/115: New function: m-buffer-delete-match
Date: Tue, 19 Jul 2022 15:58:47 -0400 (EDT)

branch: externals/m-buffer
commit 72acc99a917d5321b93b8a74a4842544704d7488
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    New function: m-buffer-delete-match
---
 README.md   |  4 ++++
 m-buffer.el | 17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index cef4effe67..2cb04f03a8 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,10 @@ with the FSF.
  - Testing is now via Cask
 
 
+#### New Functions
+
+ - m-buffer-delete-match
+
 ### 0.3
 
  - Various functions for colourising/adding faces
diff --git a/m-buffer.el b/m-buffer.el
index 9dab4f8ff1..7c65629492 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -297,6 +297,9 @@ See also `m-buffer-nil-markers'"
   (m-buffer-marker-to-pos markers t))
 
 (defun m-buffer-marker-tree-to-pos (marker-tree &optional postnil)
+  "Transforms a tree of markers to equivalent positions.
+MARKER-TREE is the tree.
+POSTNIL sets markers to till afterwards."
   (-tree-map
    (lambda (marker)
      (prog1
@@ -326,7 +329,7 @@ See also `m-buffer-nil-markers'"
   "Given a list of MATCH-DATA, replace with REPLACEMENT.
 SUBEXP should be a number indicating the regexp group to replace.
 Returns markers to the start and end of the replacement. These
-markers are part of MATCH-DATA, and will be niled if they are."
+markers are part of MATCH-DATA, so niling them will percolate backward."
   (-map
    (lambda (match)
      (with-current-buffer
@@ -337,9 +340,16 @@ markers are part of MATCH-DATA, and will be niled if they 
are."
           replacement nil nil nil
           (or subexp 0)))))
    match-data)
-  ;; we have match-data 
+  ;; we have match-data
   (m-buffer-match-nth-group (or subexp 0) match-data))
 
+(defun m-buffer-delete-match (match-data &optional subexp)
+  "Given a list of MATCH-DATA, delete the matches.
+SUBEXP should be a number indicating the regexp group to delete.
+Returns markers to the start and end of the replacement. These
+markers are part of MATCH_DATA, so niling them will percolate backward."
+  (m-buffer-replace-match match-data "" subexp))
+
 (defun m-buffer-match-string (match-data &optional subexp)
   "Given a list of MATCH-DATA return the string matches optionally
 of group SUBEXP."
@@ -385,6 +395,9 @@ MATCH is of form BUFFER-OR-WINDOW MATCH-OPTIONS. See
    :post-match 'm-buffer-post-match-forward-line))
 
 (defun m-buffer-match-line (&rest match)
+  "Returns 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-match
    match :regexp "^.*$"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]