From b5914fa0b485a490e5be4debd8a1ea44c6571fb8 Mon Sep 17 00:00:00 2001 From: Chen Bin Date: Wed, 11 Oct 2023 22:30:43 +1100 Subject: [PATCH] support ruby 3 endless method --- evil-matchit-ruby.el | 2 +- evil-matchit-sdk.el | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/evil-matchit-ruby.el b/evil-matchit-ruby.el index 364d4f4..dc96bfc 100644 --- a/evil-matchit-ruby.el +++ b/evil-matchit-ruby.el @@ -48,7 +48,7 @@ '((("unless" "if") ("elsif" "else") "end") ("begin" ("rescue" "ensure") "end") ("case" ("when" "else") "end") - (("class" "def" "while" "do" "module" "for" "until") () "end" "ENDLESS"))) + (("class" "def" "while" "do" "module" "for" "until") () "end" "SAME-INDENT"))) ;;;###autoload (defun evilmi-ruby-get-tag () diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el index 443b7b1..2ff87c9 100644 --- a/evil-matchit-sdk.el +++ b/evil-matchit-sdk.el @@ -271,6 +271,14 @@ If IS-FORWARD is t, jump forward; or else jump backward." (goto-char dst) (evilmi-sdk-tweak-selected-region ff jump-forward)))) +;; @see https://github.com/redguardtoo/evil-matchit/issues/143 +;; need record indent info into tag-info +(defun evilmi-sdk-same-indent-p (tag-info) + (and (nth 2 tag-info) (string= (nth 2 tag-info) "SAME-INDENT"))) + +(defun evilmi-sdk-monogamy-p (tag-info) + (and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY"))) + (defun evilmi-sdk-strictly-type-p (crt orig) (or (evilmi-sdk-monogamy-p crt) (evilmi-sdk-monogamy-p orig))) @@ -283,6 +291,14 @@ If IS-FORWARD is t, jump forward; or else jump backward." (orig-type (nth 1 orig-tag-info)) (cur-type (nth 1 cur-tag-info))) + (when evilmi-debug + (message "evilmi-sdk-tags-matched-p called. level=%s orig-keyword=%s cur-keyword=%s cur-tag-info=%s orig-tag-info=%s" + level + orig-keyword + cur-keyword + cur-tag-info + orig-tag-info)) + ;; handle function exit point (when (= 1 level) ;; multiple open tags might share the same end tag @@ -403,9 +419,6 @@ Rule is looked up in HOWTOS." (line-beginning-position) (line-end-position))))) -(defun evilmi-sdk-monogamy-p (tag-info) - (and (nth 2 tag-info) (string= (nth 2 tag-info) "MONOGAMY"))) - (defun evilmi-sdk-exactly-same-type-p (crt orig) (eq (nth 0 crt) (nth 0 orig)))