Skip to content

Commit cc1e751

Browse files
committed
On goto, show marks with delay in *evil-marks* buffer
This commit adds functionality to the previous commit (i.e. mark-goto-buffer-not-line), and shows marks in the *evil-marks* window after a delay (similiar to which-key). It is especially handy to remind of which mark is associated with which buffer.
1 parent 71039fe commit cc1e751

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

evil-commands.el

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,58 @@ Columns are counted from zero."
804804
is-global)
805805
(evil-first-non-blank))))
806806

807+
(evil-define-command evil--goto-mark-list (marks &optional line-or-buffer)
808+
(evil-show-marks marks)
809+
(let* ((char (read-char))
810+
(is-global (string= "Lu"
811+
(get-char-code-property char 'general-category)))
812+
(key (char-to-string char))
813+
(entry (tabulated-list-get-entry)))
814+
(while (and
815+
entry
816+
(not (string= (aref entry 0) key)))
817+
(next-line)
818+
(setq entry (tabulated-list-get-entry)))
819+
(cond ((eobp) (message "Marker '%s' is not set in this buffer" key)
820+
(evil-list-view-quit))
821+
(t (evil-list-view-quit)
822+
(switch-to-buffer (car (elt entry 3)))
823+
(evil-goto-mark (string-to-char (elt entry 0)))
824+
(when line-or-buffer
825+
(unless (and evil-mark-goto-buffer-not-line
826+
is-global)
827+
(evil-first-non-blank)))))))
828+
829+
(evil-define-command evil-goto-mark-list (marks &optional line-or-buffer)
830+
(interactive "<a>")
831+
(with-timeout (0.6
832+
(evil--goto-mark-list marks line-or-buffer))
833+
(let* ((char (read-char))
834+
(is-global (string= "Lu"
835+
(get-char-code-property char 'general-category))))
836+
(evil-goto-mark char)
837+
(when line-or-buffer
838+
(unless (and evil-mark-goto-buffer-not-line
839+
is-global)
840+
(evil-first-non-blank))))))
841+
842+
(evil-define-command evil-goto-mark-line-list (marks)
843+
(interactive "<a>")
844+
(evil-goto-mark-list marks t))
845+
846+
(defun evil-goto-mark-set ()
847+
(if evil-mark-goto-buffer-not-line
848+
'evil-goto-mark-list
849+
'evil-goto-mark))
850+
851+
(defun evil-goto-mark-line-set ()
852+
(if evil-mark-goto-buffer-not-line
853+
'evil-goto-mark-line-list
854+
'evil-goto-mark-line))
855+
856+
(setq evil-goto-mark-auto (evil-goto-mark-set))
857+
(setq evil-goto-mark-line-auto (evil-goto-mark-line-set))
858+
807859
(evil-define-motion evil-jump-backward (count)
808860
"Go to older position in jump list.
809861
To go the other way, press \

evil-maps.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@
220220
(define-key evil-motion-state-map "g#" 'evil-search-unbounded-word-backward)
221221
(define-key evil-motion-state-map "$" 'evil-end-of-line)
222222
(define-key evil-motion-state-map "%" 'evil-jump-item)
223-
(define-key evil-motion-state-map "`" 'evil-goto-mark)
224-
(define-key evil-motion-state-map "'" 'evil-goto-mark-line)
223+
(define-key evil-motion-state-map "`" evil-goto-mark-auto)
224+
(define-key evil-motion-state-map "'" evil-goto-mark-line-auto)
225225
(define-key evil-motion-state-map "(" 'evil-backward-sentence-begin)
226226
(define-key evil-motion-state-map ")" 'evil-forward-sentence-begin)
227227
(define-key evil-motion-state-map "]]" 'evil-forward-section-begin)

0 commit comments

Comments
 (0)