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

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

[nongnu] elpa/evil-matchit c4be28092f 087/244: perfect support for visua


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit c4be28092f 087/244: perfect support for visual-line state v2.1
Date: Thu, 6 Jan 2022 02:58:52 -0500 (EST)

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

    perfect support for visual-line state v2.1
---
 README.org          |   7 +++---
 evil-matchit-pkg.el |   2 +-
 evil-matchit.el     |  60 +++++++++++++++++-----------------------------------
 pkg.sh              |   2 +-
 screencast.gif      | Bin 318351 -> 318349 bytes
 5 files changed, 25 insertions(+), 46 deletions(-)

diff --git a/README.org b/README.org
index db5a062599..90b71dd613 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v2.0.2)
+* evil-matchit (v2.1)
 
 Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by 
Benji Fisher ported into Emacs.
 
@@ -31,7 +31,8 @@ Tested on Emacs 23.4, 24.3, 24.4
 
 * Why use evil-matchit
 - No learning curve. Press "%" to jump. That's all!
-- Stable! Though it's dependent on evil-mode, NO evil-mode API is used
+- Stable. Usage of  Evil API is minimized
+- Perfect integration with Evil
 - Support any modern languages (html/java/c/c++/python/latex/javascript ...)
 - Powerful. If you mix jsp, freemarker, html, jquery template or any weird 
syntax into one file, it still works!
 - Extendable. Write a plugin for it takes only 5 minutes
@@ -248,7 +249,7 @@ Basically you just need:
 #+END_SRC
 
 ** Share your code to the world
-Tweak your code a little bit to make it a plugin and ask me to merge it into 
upstream.
+Convert your code to a plugin and ask me to merge it into upstream.
 
 Please check "evil-matchit-latex.el" for technical details about plugin.
 
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index 5ea93698bc..014b95979a 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "2.0.2"
+(define-package "evil-matchit" "2.1"
                 "Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
index 7f82b6f3db..3d32a41519 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
 
 ;; Author: Chen Bin <chenbin.sh@gmail.com>
 ;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 2.0.2
+;; Version: 2.1
 ;; Keywords: matchit vim evil
 ;; Package-Requires: ((evil "1.0.7"))
 ;;
@@ -85,17 +85,10 @@ If this flag is nil, then 50 means jump 50 times.")
     ch))
 
 (defun evilmi--get-char-under-cursor ()
-  "Return: (previous-character current-character position)"
+  "Return: (character position)"
   (let (ch p)
-    (cond
-     ;; evil load
-     ((eq evil-state 'visual)
-      ;; (preceding-char) (following-char) are written in C
-      (setq ch (preceding-char))
-      (setq p (- (point) 1)))
-     (t
-      (setq ch (following-char))
-      (setq p (point))))
+    (setq ch (following-char))
+    (setq p (point))
     (if evilmi-debug (message "evilmi--get-char-under-cursor called. Return: 
(%d %s)" ch p))
     (list ch p)))
 
@@ -129,23 +122,15 @@ If font-face-under-cursor is NOT nil, the quoted string 
is being processed"
   (let (rlt
         start-pos
         (arg (if is-forward 1 -1)))
-    (cond
-     ((eq evil-state 'visual)
-      (setq start-pos (if is-forward (- (point) 1)
-                        (point))))
-     (t
-      ;; normal state and other state
-      (setq start-pos (if is-forward (point) (+ 1 (point))))
-      ))
+    ;; normal state and other state
+    (setq start-pos (if is-forward (point) (+ 1 (point))))
     (setq rlt (scan-sexps start-pos arg))
     (if evilmi-debug (message "evilmi--scan-sexps called. Return: %s" rlt))
     rlt))
 
 (defun evilmi--adjust-quote-jumpto (is-forward pos)
   (let (rlt)
-    (if (eq evil-state 'visual)
-        (setq rlt (if is-forward (- pos 1) pos (+ 1 pos)))
-        (setq rlt (if is-forward pos (+ 1 pos))))
+    (setq rlt (if is-forward pos (+ 1 pos)))
     (if evilmi-debug (message "evilmi--adjust-quote-jumpto called. Return: %s" 
rlt))
     rlt))
 
@@ -172,12 +157,9 @@ If font-face-under-cursor is NOT nil, the quoted string is 
being processed"
     rlt))
 
 (defun evilmi--adjust-jumpto (is-forward rlt)
-  (cond
-   ((eq evil-state 'visual)
-    (if is-forward (setq rlt (+ rlt 1)))
-    )
-   (t
-    (if is-forward (setq rlt (- rlt 1)))))
+  ;; normal-state hack!
+  (unless (eq evil-state 'visual)
+    (if is-forward (setq rlt (- rlt 1))))
   (if evilmi-debug (message "evilmi--adjust-jumpto called. Return: %s" rlt))
   rlt)
 
@@ -192,18 +174,11 @@ If font-face-under-cursor is NOT nil, the quoted string 
is being processed"
     rlt))
 
 (defun evilmi--tweak-selected-region-finally (ff jump-forward)
-  (if (eq evil-state 'visual)
-      (cond
-       (jump-forward
-        ;; if ff is non-nil, I control the jump flow from character level,
-        ;; so hack to workaround scan-sexps is NOT necessary
-        (unless ff
-          (evil-backward-char)))
-       (t
-        (exchange-point-and-mark)
-        (evil-forward-char)
-        (exchange-point-and-mark)))
-    ))
+  ;; visual-state hack!
+  (if (and jump-forward (eq evil-state 'visual) (not ff))
+      ;; if ff is non-nil, I control the jump flow from character level,
+      ;; so hack to workaround scan-sexps is NOT necessary
+        (evil-backward-char)))
 
 (defun evilmi--simple-jump ()
   "Alternative for evil-jump-item"
@@ -459,12 +434,15 @@ If font-face-under-cursor is NOT nil, the quoted string 
is being processed"
    ))
 
 ;;;###autoload
-(defun evilmi-version() (interactive) (message "2.0.2"))
+(defun evilmi-version() (interactive) (message "2.1"))
 
 ;;;###autoload
 (define-minor-mode evil-matchit-mode
   "Buffer-local minor mode to emulate matchit.vim"
   :keymap (make-sparse-keymap)
+  ;; get correct value of `(point)` in visual-line mode
+  ;; @see 
https://bitbucket.org/lyro/evil/issues/540/get-the-char-under-cusor-in-visual-line
+  (evil-set-command-property 'evilmi-jump-items :keep-visual t)
   (if (fboundp 'evilmi-customize-keybinding)
       ;; use user's own key bindings
       (evilmi-customize-keybinding)
diff --git a/pkg.sh b/pkg.sh
index 561a6b3657..d89bba376e 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-pkg=evil-matchit-2.0.2
+pkg=evil-matchit-2.1
 mkdir $pkg
 cp README.org $pkg
 cp *.el $pkg
diff --git a/screencast.gif b/screencast.gif
index baf5b0efdf..e50def58d1 100644
Binary files a/screencast.gif and b/screencast.gif differ



reply via email to

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