diff --git a/evil-commands.el b/evil-commands.el index 073ffc53..026020d8 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -797,8 +797,64 @@ Columns are counted from zero." :type line :jump t (interactive (list (read-char))) - (evil-goto-mark char noerror) - (evil-first-non-blank)) + (let ((is-global (string= "Lu" + (get-char-code-property char 'general-category)))) + (evil-goto-mark char noerror) + (unless (and evil-mark-goto-buffer-not-line + is-global) + (evil-first-non-blank)))) + +(evil-define-command evil--goto-mark-list (marks &optional line-or-buffer) + (evil-show-marks marks) + (let* ((char (read-char)) + (is-global (string= "Lu" + (get-char-code-property char 'general-category))) + (key (char-to-string char)) + (entry (tabulated-list-get-entry))) + (while (and + entry + (not (string= (aref entry 0) key))) + (next-line) + (setq entry (tabulated-list-get-entry))) + (cond ((eobp) (message "Marker '%s' is not set in this buffer" key) + (evil-list-view-quit)) + (t (evil-list-view-quit) + (switch-to-buffer (car (elt entry 3))) + (evil-goto-mark (string-to-char (elt entry 0))) + (when line-or-buffer + (unless (and evil-mark-goto-buffer-not-line + is-global) + (evil-first-non-blank))))))) + +(evil-define-command evil-goto-mark-list (marks &optional line-or-buffer) + (interactive "") + (with-timeout (0.6 + (evil--goto-mark-list marks line-or-buffer)) + (let* ((char (read-char)) + (is-global (string= "Lu" + (get-char-code-property char 'general-category)))) + (evil-goto-mark char) + (when line-or-buffer + (unless (and evil-mark-goto-buffer-not-line + is-global) + (evil-first-non-blank)))))) + +(evil-define-command evil-goto-mark-line-list (marks) + (interactive "") + (evil-goto-mark-list marks t)) + +(defun evil-goto-mark-set () + (if evil-mark-goto-buffer-not-line + 'evil-goto-mark-list + 'evil-goto-mark)) + +(defun evil-goto-mark-line-set () + (if evil-mark-goto-buffer-not-line + 'evil-goto-mark-line-list + 'evil-goto-mark-line)) + +(setq evil-goto-mark-auto (evil-goto-mark-set)) +(setq evil-goto-mark-line-auto (evil-goto-mark-line-set)) (evil-define-motion evil-jump-backward (count) "Go to older position in jump list. diff --git a/evil-maps.el b/evil-maps.el index 91ed47eb..8b71533e 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -220,8 +220,8 @@ (define-key evil-motion-state-map "g#" 'evil-search-unbounded-word-backward) (define-key evil-motion-state-map "$" 'evil-end-of-line) (define-key evil-motion-state-map "%" 'evil-jump-item) -(define-key evil-motion-state-map "`" 'evil-goto-mark) -(define-key evil-motion-state-map "'" 'evil-goto-mark-line) +(define-key evil-motion-state-map "`" evil-goto-mark-auto) +(define-key evil-motion-state-map "'" evil-goto-mark-line-auto) (define-key evil-motion-state-map "(" 'evil-backward-sentence-begin) (define-key evil-motion-state-map ")" 'evil-forward-sentence-begin) (define-key evil-motion-state-map "]]" 'evil-forward-section-begin) diff --git a/evil-vars.el b/evil-vars.el index 1936c79a..d9f5a70c 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -591,6 +591,13 @@ large accessible in insert state." :type 'boolean :group 'evil) +(defcustom evil-mark-goto-buffer-not-line t + "Behavior of goto mark with `''. +When `t', `'' jumps to last cursor position of the marked buffer +instead of jumping to the mark its line number." + :type 'boolean + :group 'evil) + (defcustom evil-complete-all-buffers t "\\ Whether completion looks for matches in all buffers.