Skip to content

Commit

Permalink
consult, imenu: Declare some navigation commands to be non-repeatable (
Browse files Browse the repository at this point in the history
…#653)

It does not make sense to repeat these commands via evil-repeat. (It
also doesn't work) We typically use evil-repeat for commands that
change the buffer contents.
  • Loading branch information
leungbk authored Jul 12, 2022
1 parent 91e5550 commit e1eed25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions modes/consult/evil-collection-consult.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@

(defun evil-collection-consult-set-bindings ()
"Set the bindings."
(evil-set-command-property 'consult-outline :jump t)
(evil-set-command-property 'consult-mark :jump t)
(evil-set-command-property 'consult-global-mark :jump t)
(evil-set-command-property 'consult-imenu :jump t)
(evil-set-command-property 'consult-org-heading :jump t)
(evil-set-command-property 'consult-line :jump t))
(dolist (cmd '(consult-outline
consult-mark
consult-global-mark
consult-imenu
consult-org-heading
consult-line))
(evil-declare-not-repeat cmd)
(evil-set-command-property cmd :jump t)))

(defun evil-collection-consult--evil-mark-ring ()
"Return alist of char & marker for evil markers in current buffer."
Expand All @@ -78,14 +80,14 @@ as defined in `evil-collection-consult--evil-mark-ring'."
(let* ((candidates)
(current-buf (current-buffer)))
(save-excursion
(dolist (marker (or markers (evil-collection-consult--evil-mark-ring)))
(let ((pos (marker-position (cdr marker)))
(buf (marker-buffer (cdr marker))))
(pcase-dolist (`(,char . ,marker) (or markers (evil-collection-consult--evil-mark-ring)))
(let ((pos (marker-position marker))
(buf (marker-buffer marker)))
(when (and (eq buf current-buf)
(consult--in-range-p pos))
(goto-char pos)
(push (consult--location-candidate
(format "%s: %s" (char-to-string (car marker)) (consult--line-with-cursor (cdr marker))) (cdr marker)
(format "%s: %s" (char-to-string char) (consult--line-with-cursor marker)) marker
(line-number-at-pos pos consult-line-numbers-widen))
candidates)))))
(nreverse (delete-dups candidates))))
Expand Down
1 change: 1 addition & 0 deletions modes/imenu/evil-collection-imenu.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
;;;###autoload
(defun evil-collection-imenu-setup ()
"Set up Evil integration for `imenu'."
(evil-declare-not-repeat 'imenu)
(evil-add-command-properties 'imenu :jump t))

(provide 'evil-collection-imenu)
Expand Down

0 comments on commit e1eed25

Please sign in to comment.