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

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

[nongnu] elpa/evil-matchit 23a0576255 213/244: fixed: can not jump tag f


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit 23a0576255 213/244: fixed: can not jump tag from prompt line in shell-mode sometimes
Date: Thu, 6 Jan 2022 02:59:02 -0500 (EST)

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

    fixed: can not jump tag from prompt line in shell-mode sometimes
---
 evil-matchit-terminal.el | 33 +++++++++++++++++++++++----------
 evil-matchit.el          |  4 ++--
 pkg.sh                   |  2 +-
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/evil-matchit-terminal.el b/evil-matchit-terminal.el
index 210e4c0d4d..c30f0027fc 100644
--- a/evil-matchit-terminal.el
+++ b/evil-matchit-terminal.el
@@ -37,30 +37,43 @@
 (require 'evil-matchit-sdk)
 
 (defvar evilmi-terminal-primary-prompt "^\\$ "
-  "The primary prompt of terminal")
+  "The primary prompt of terminal.")
 
 (defvar evilmi-terminal-ps1-line-number 1
   "The line containing PS1.")
 
+(defun evilmi-prompt-line-p (&optional position)
+  "If line at POSITION has prompt at the beginning."
+  (let* (rlt)
+    ;; user can't move the cursor to the first column in prompt line
+    (save-excursion
+      (goto-char (or position (point)))
+      (goto-char (line-beginning-position))
+      (setq rlt (> (current-column) 1)))
+
+    ;; another round if we can't decide fromc cusor movement
+    (unless rlt
+      (setq rlt (string-match-p evilmi-terminal-primary-prompt
+                                (evilmi-sdk-curline))))
+    rlt))
+
 ;;;###autoload
 (defun evilmi-terminal-get-tag ()
   "Get tag at point."
-  (let* ((curline (evilmi-sdk-curline))
-         (prompt evilmi-terminal-primary-prompt)
-         line1
-         line2)
+  (let* (nl1 nl2)
     (cond
-     ((string-match prompt curline)
+     ((evilmi-prompt-line-p)
       ;; open tag
       (list (line-beginning-position) 0))
      (t
       (save-excursion
         (forward-line)
-        (setq line1 (evilmi-sdk-curline))
+        (setq nl1 (evilmi-prompt-line-p))
         (forward-line)
-        (setq line2 (evilmi-sdk-curline)))
-      (when (and line1 line2 (or (string-match prompt line1)
-                                 (string-match prompt line2)))
+        (setq nl2 (evilmi-prompt-line-p)))
+      ;; if either of next two lines are prompt line
+      ;; current line is closed tag
+      (when (or nl1 nl2)
         (list (line-end-position) 1))))))
 
 ;;;###autoload
diff --git a/evil-matchit.el b/evil-matchit.el
index fbef487155..2035d7d27a 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
 ;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 2.3.8
+;; Version: 2.3.9
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.2.0") (emacs "24.4"))
 ;;
@@ -310,7 +310,7 @@ If IS-INNER is t, the region is inner text object."
 (defun evilmi-version()
   "Print version."
   (interactive)
-  (message "2.3.8"))
+  (message "2.3.9"))
 
 (defvar evil-matchit-mode-map (make-sparse-keymap)
   "Keymap used by the minor mode.")
diff --git a/pkg.sh b/pkg.sh
index 8df15e6264..553e29fbfe 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 name=evil-matchit
-version=2.3.8
+version=2.3.9
 pkg=$name-$version
 mkdir $pkg
 cp README.org $pkg



reply via email to

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