Skip to content

Add Jump-in function #5

@galaunay

Description

@galaunay

I don't know if this project is still maintained, but I find it very useful.
I just think that a function to "jump in" (i.e. access the nearest following matching pairs) would be very nice.
The following code seem to work (not fully tested yet) :

(defun evil-args--forward-opener (&optional count)
  (let ((openers-regexp (regexp-opt evil-args-openers))
    (closers-regexp (regexp-opt evil-args-closers))
    (openers-and-closers-regexp (regexp-opt (append evil-args-openers
                            evil-args-closers)))
    (end -1)
    (count (or count 1)))
    (save-excursion
      (while (> count 0)
    ;; search forward for an opener
    (if (not (re-search-forward openers-and-closers-regexp nil t))
        ;; not found (do nothing more)
        (setq count 0)
      ;; found
      (backward-char)
      ;; if looking at a closer (stop)
      (if (looking-at-p closers-regexp)
          (setq count 0)
        ;; if looking at an opener
        (setq end (+ (point) 1))
        (forward-char)
        (setq count (- count 1)))
      )))
    (if (> end 0) (goto-char end))))




;;;###autoload
(defun evil-jump-in-args (count)
  "Move the cursor in the next enclosing matching pairs."
  (interactive "p")
  (evil-args--forward-opener count))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions