Skip to content

Commit

Permalink
support ruby 3 endless method
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Bin committed Oct 11, 2023
1 parent fe4cc52 commit b5914fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion evil-matchit-ruby.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
19 changes: 16 additions & 3 deletions evil-matchit-sdk.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand All @@ -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
Expand Down Expand Up @@ -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)))

Expand Down

0 comments on commit b5914fa

Please sign in to comment.