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

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

[nongnu] elpa/evil-matchit e831d42aa5 085/244: relax regex for python ma


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit e831d42aa5 085/244: relax regex for python matching
Date: Thu, 6 Jan 2022 02:58:52 -0500 (EST)

branch: elpa/evil-matchit
commit e831d42aa53b2be8172036e735869ea621393f0c
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    relax regex for python matching
---
 evil-matchit-python.el | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/evil-matchit-python.el b/evil-matchit-python.el
index 4b9b7161f7..36a6991d5f 100644
--- a/evil-matchit-python.el
+++ b/evil-matchit-python.el
@@ -61,18 +61,17 @@
         )
 
     ;; extract keyword from current line
-    (if (string-match "^[ \t]*\\([a-z]+\\) *.*:$" cur-line)
+    (if (string-match "^[ \t]*\\([a-z]+\\) *.*:\s*\\(#.*\\)?$" cur-line)
         (setq keyword (match-string 1 cur-line))
       )
 
     (cond
      ((string= keyword "else")
-      (setq regexp "^[ \t]*\\(if\\) *.*:$")
+      (setq regexp "^[ \t]*\\(if\\) *.*:\s*\\(#.*\\)?$")
       )
      ((or (string= keyword "finally") (string= keyword "except"))
-       (setq regexp "^[ \t]*\\(try\\) *.*:$")
-       )
-     )
+       (setq regexp "^[ \t]*\\(try\\) *.*:\s*\\(#.*\\)?$")
+       ))
 
     (when regexp
       (save-excursion
@@ -111,13 +110,13 @@
         )
     (cond
      ((string= keyword "try")
-      (setq regexp "^[ \t]*\\(except\\) *.*:$")
+      (setq regexp "^[ \t]*\\(except\\) *.*:\s*\\(#.*\\)?$")
       )
      ((string= keyword "except")
-      (setq regexp "^[ \t]*\\(except\\|finally\\) *.*:$")
+      (setq regexp "^[ \t]*\\(except\\|finally\\) *.*:\s*\\(#.*\\)?$")
       )
      ( (or (string= keyword "elif") (string= keyword "if"))
-       (setq regexp "^[ \t]*\\(elif\\|else\\) *.*:$")
+       (setq regexp "^[ \t]*\\(elif\\|else\\) *.*:\s*\\(#.*\\)?$")
        )
      )
 
@@ -150,7 +149,7 @@
 ;;;###autoload
 (defun evilmi-python-get-tag ()
   (let (rlt
-        (regexp "^[ \t]*\\([a-z]+\\) *.*:$")
+        (regexp "^[ \t]*\\([a-z]+\\) *.*:\s*\\(#.*\\)?$")
         (cur-line (buffer-substring-no-properties
                    (line-beginning-position)
                    (line-end-position)))



reply via email to

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