branch: externals/expreg
commit 0a8a85fc23cc7e1f0a83244315acca5373bb81bc
Author: Yuan Fu <caso...@gmail.com>
Commit: Yuan Fu <caso...@gmail.com>

    * expreg.el (expreg--sentence): New expander function.
---
 expreg.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/expreg.el b/expreg.el
index 9cc50da867..2a021504f4 100644
--- a/expreg.el
+++ b/expreg.el
@@ -38,6 +38,10 @@
 ;;     (region A)|(region B)
 ;;
 ;; Expreg also recognizes subwords if ‘subword-mode’ is on.
+;;
+;; By default, the sentence expander ‘expreg--sentence’ is not
+;; enabled. I suggest enabling it (by adding it to ‘expreg-functions’)
+;; in text modes only.
 
 ;;; TODO
 ;;
@@ -595,6 +599,16 @@ current string/comment and get lists inside."
       (push `(comment . ,(cons beg end)) result))
     result))
 
+(defun expreg--sentence ()
+  "Return a list of regions containing surrounding sentences."
+  (ignore-errors
+    (let (beg end)
+      (forward-sentence)
+      (setq end (point))
+      (backward-sentence)
+      (setq beg (point))
+      `((sentence . ,(cons beg end))))))
+
 (defun expreg--paragraph ()
   "Return a list of regions containing paragraphs or defuns."
   (condition-case nil

Reply via email to