branch: elpa/evil-emacs-cursor-model-mode
commit 903246ba8a6d2b2ac69091e93d823a47464b0178
Author: maxfriis <[email protected]>
Commit: GitHub <[email protected]>

    Fixed inconsistency in how "f" and "t" worked
    
    I liked how "f" on the char-after moved the point one char forward rather 
than looking for the next instance of the char. "t" still ignored the 
char-after since that makes sense in evil-mode. Unfortunately nothing happens 
if you "t" on the char after now, because the char-after is the next char with 
this cursor model. Evil already has this behavior on "T" where nothing happens 
if you "T" to the char-before.
---
 evil-emacs-cursor-model-mode.el | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/evil-emacs-cursor-model-mode.el b/evil-emacs-cursor-model-mode.el
index 85835370db..009957fb41 100644
--- a/evil-emacs-cursor-model-mode.el
+++ b/evil-emacs-cursor-model-mode.el
@@ -13,7 +13,7 @@
 ;; Maintainer: Peter Friis Jensen <[email protected]>
 ;; URL: https://github.com/maxfriis/evil-emacs-cursor-model-mode
 ;; Created: 2025-11-15
-;; Version: 0.1.1
+;; Version: 0.1.2
 ;; Keywords: convenience, files
 ;; Package-Requires: ((emacs "29.1") (evil "1.15.0"))
 
@@ -21,7 +21,7 @@
 ;;; Commentary:
 ;; ============================================================================
 ;; Emacs' cursor between characters model for cursor positioning in
-;; `evil-mode' instead of Vim's normal-state cursor on top of characters model.
+;; `evil-mode' instead of Vim's normal-state cursor on top of character model.
 ;; ============================================================================
 ;;; TODO:
 ;; ============================================================================
@@ -97,10 +97,10 @@ Maybe fewer layers are better for your Emacs pinky?"
 ;; Motions.
 (keymap-set evil-emacs-cursor-model-mode-map
             "<remap> <evil-find-char-to>"
-            #'evil-find-char)
+            #'evil-emacs-cursor-model-find-before-char)
 (keymap-set evil-emacs-cursor-model-mode-map
             "<remap> <evil-find-char>"
-            #'evil-emacs-cursor-model-find-char-after)
+            #'evil-emacs-cursor-model-find-after-char)
 (keymap-set evil-emacs-cursor-model-mode-map
             "<remap> <evil-forward-word-end>"
             #'evil-emacs-cursor-model-forward-after-word-end)
@@ -143,7 +143,21 @@ Maybe fewer layers are better for your Emacs pinky?"
 ;; ============================================================================
 ;;; Evil commands implementing Emacs' cursor model
 ;; ============================================================================
-(evil-define-motion evil-emacs-cursor-model-find-char-after (count char)
+(evil-define-motion evil-emacs-cursor-model-find-before-char (count char)
+  "Move point immediately before the next COUNT'th occurrence of CHAR.
+Movement is restricted to the current line unless `evil-cross-lines' is 
non-nil."
+  :type inclusive
+  (interactive "<c><C>")
+  (unless count (setq count 1))
+  (if (< count 0)
+      (evil-find-char-backward-to (- count) char)
+    ;; else
+    (when (= (char-after) char)
+      (cl-decf count))
+    (evil-find-char count char))
+  (setq evil-last-find (list #'evil-emacs-cursor-model-find-before-char char 
(> count 0))))
+
+(evil-define-motion evil-emacs-cursor-model-find-after-char (count char)
   "Move point immediately after the next COUNT'th occurrence of CHAR.
 Movement is restricted to the current line unless `evil-cross-lines' is 
non-nil."
   :type inclusive
@@ -156,7 +170,7 @@ Movement is restricted to the current line unless 
`evil-cross-lines' is non-nil.
       (cl-decf count))
     (evil-find-char count char)
     (forward-char))
-  (setq evil-last-find (list #'evil-emacs-cursor-model-find-char-after char (> 
count 0))))
+  (setq evil-last-find (list #'evil-emacs-cursor-model-find-after-char char (> 
count 0))))
 
 (defun evil-emacs-cursor-model-forward-after-end (thing &optional count)
   "Move forward to end of THING.

Reply via email to