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

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

[elpa] externals/expreg 9e6a3289e6 1/2: Make paragraph expander more fle


From: ELPA Syncer
Subject: [elpa] externals/expreg 9e6a3289e6 1/2: Make paragraph expander more flexible (bug#65591)
Date: Wed, 30 Aug 2023 03:57:56 -0400 (EDT)

branch: externals/expreg
commit 9e6a3289e638fcc9acf30c34063b2dc1fc546293
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Make paragraph expander more flexible (bug#65591)
    
    * expreg.el (expreg-functions): Rename expreg--paragraph
    (expreg--paragraph): Rename to expreg--paragraph-defun, and allow
    defun and paragraph expansion to coexist.
---
 expreg.el | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/expreg.el b/expreg.el
index eaec3d53f9..5a0fb8cada 100644
--- a/expreg.el
+++ b/expreg.el
@@ -90,7 +90,7 @@
 
 (defvar-local expreg-functions
     '( expreg--subword expreg--word expreg--list expreg--string
-       expreg--treesit expreg--comment expreg--paragraph)
+       expreg--treesit expreg--comment expreg--paragraph-defun)
   "A list of expansion functions.
 
 Each function is called with no arguments and should return a
@@ -611,16 +611,13 @@ current string/comment and get lists inside."
       (setq beg (point))
       `((sentence . ,(cons beg end))))))
 
-(defun expreg--paragraph ()
+(defun expreg--paragraph-defun ()
   "Return a list of regions containing paragraphs or defuns."
   (condition-case nil
       (let ((orig (point))
             beg end result)
-        (cond
-         ;; Using defun.
-         ((or (derived-mode-p 'prog-mode)
-              beginning-of-defun-function)
 
+        (when beginning-of-defun-function
           (when (beginning-of-defun)
             (setq beg (point))
             (end-of-defun)
@@ -630,16 +627,14 @@ current string/comment and get lists inside."
             (unless (eq orig end)
               (push `(paragraph-defun . ,(cons beg end)) result))))
 
-         ;; Use paragraph.
-         ((or (derived-mode-p 'text-mode)
-              (eq major-mode 'fundamental-mode))
-
+        (when (or (derived-mode-p 'text-mode)
+                  (eq major-mode 'fundamental-mode))
           (backward-paragraph)
           (skip-syntax-forward "-")
           (setq beg (point))
           (forward-paragraph)
           (setq end (point))
-          (push `(paragraph . ,(cons beg end)) result)))
+          (push `(paragraph . ,(cons beg end)) result))
 
         result)
     (scan-error nil)))



reply via email to

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