diff options
| -rw-r--r-- | evil-commands.el | 13 | ||||
| -rw-r--r-- | evil-common.el | 6 | ||||
| -rw-r--r-- | evil-core.el | 2 | ||||
| -rw-r--r-- | evil-jumps.el | 29 | ||||
| -rw-r--r-- | evil-tests.el | 70 | ||||
| -rw-r--r-- | evil-vars.el | 2 |
6 files changed, 67 insertions, 55 deletions
diff --git a/evil-commands.el b/evil-commands.el index 3d7c09f..397d417 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -30,6 +30,7 @@ (require 'evil-ex) (require 'evil-types) (require 'evil-command-window) +(require 'evil-jumps) ;;; Compatibility for Emacs 23 (unless (fboundp 'window-body-width) @@ -693,6 +694,18 @@ Columns are counted from zero." (evil-goto-mark char noerror) (evil-first-non-blank)) +(evil-define-motion evil-jump-backward (count) + "Go to older position in jump list. +To go the other way, press \ +\\<evil-motion-state-map>\\[evil-jump-forward]." + (evil--jump-backward count)) + +(evil-define-motion evil-jump-forward (count) + "Go to newer position in jump list. +To go the other way, press \ +\\<evil-motion-state-map>\\[evil-jump-backward]." + (evil--jump-forward count)) + (evil-define-motion evil-jump-to-tag (arg) "Jump to tag under point. If called with a prefix argument, provide a prompt diff --git a/evil-common.el b/evil-common.el index d110ba8..b867287 100644 --- a/evil-common.el +++ b/evil-common.el @@ -1965,12 +1965,6 @@ or a marker object pointing nowhere." (marker-position (cdr entry)))))))) (put 'evil-swap-out-markers 'permanent-local-hook t) -(defun evil-jump-hook (&optional command) - "Set jump point if COMMAND has a non-nil :jump property." - (setq command (or command this-command)) - (when (evil-get-command-property command :jump) - (evil-set-jump))) - (defun evil-get-register (register &optional noerror) "Return contents of REGISTER. Signal an error if empty, unless NOERROR is non-nil. diff --git a/evil-core.el b/evil-core.el index f69c0c0..d3b5ead 100644 --- a/evil-core.el +++ b/evil-core.el @@ -138,11 +138,9 @@ (add-hook 'input-method-deactivate-hook 'evil-deactivate-input-method t t) (add-hook 'activate-mark-hook 'evil-visual-activate-hook nil t) (add-hook 'pre-command-hook 'evil-repeat-pre-hook) - (add-hook 'pre-command-hook 'evil-jump-hook nil t) (add-hook 'post-command-hook 'evil-repeat-post-hook)) (t (evil-refresh-mode-line) - (remove-hook 'pre-command-hook 'evil-jump-hook t) (remove-hook 'activate-mark-hook 'evil-visual-activate-hook t) (remove-hook 'input-method-activate-hook 'evil-activate-input-method t) (remove-hook 'input-method-deactivate-hook 'evil-deactivate-input-method t) diff --git a/evil-jumps.el b/evil-jumps.el index 9aec28f..3e66377 100644 --- a/evil-jumps.el +++ b/evil-jumps.el @@ -24,9 +24,12 @@ ;; You should have received a copy of the GNU General Public License ;; along with Evil. If not, see <http://www.gnu.org/licenses/>. -;;; Code: +(eval-when-compile (require 'cl)) + +(require 'evil-core) +(require 'evil-states) -(require 'cl-lib) +;;; Code: (defgroup evil-jumps nil "Evil jump list configuration options." @@ -74,7 +77,7 @@ (defun evil--jumps-message (format &rest args) (when evil--jumps-debug (with-current-buffer (get-buffer-create "*evil-jumps*") - (end-of-buffer) + (goto-char (point-max)) (insert (apply #'format format args) "\n")))) (defun evil--jumps-get-current (&optional window) @@ -176,10 +179,7 @@ POS defaults to point." (setf (evil-jumps-struct-idx struct) -1)) (evil--jumps-push))) -(evil-define-motion evil-jump-backward (count) - "Go to older position in jump list. -To go the other way, press \ -\\<evil-motion-state-map>\\[evil-jump-forward]." +(defun evil--jump-backward (count) (let ((count (or count 1))) (evil-motion-loop (nil count) (let* ((struct (evil--jumps-get-current)) @@ -191,10 +191,7 @@ To go the other way, press \ (evil--jumps-push)) (evil--jumps-jump-to-index (+ idx 1)))))) -(evil-define-motion evil-jump-forward (count) - "Go to newer position in jump list. -To go the other way, press \ -\\<evil-motion-state-map>\\[evil-jump-backward]." +(defun evil--jump-forward (count) (let ((count (or count 1))) (evil-motion-loop (nil count) (let* ((struct (evil--jumps-get-current)) @@ -224,6 +221,12 @@ To go the other way, press \ (remhash key evil--jumps-window-jumps))) evil--jumps-window-jumps))) +(defun evil--jump-hook (&optional command) + "Set jump point if COMMAND has a non-nil :jump property." + (setq command (or command this-command)) + (when (evil-get-command-property command :jump) + (evil-set-jump))) + (defadvice switch-to-buffer (before evil-jumps activate) (evil-set-jump)) @@ -237,17 +240,21 @@ To go the other way, press \ (lambda () (if evil-local-mode (progn + (add-hook 'pre-command-hook #'evil--jump-hook nil t) (add-hook 'next-error-hook #'evil-set-jump nil t) (add-hook 'window-configuration-change-hook #'evil--jumps-window-configuration-hook nil t)) (progn + (remove-hook 'pre-command-hook #'evil--jump-hook t) (remove-hook 'next-error-hook #'evil-set-jump t) (remove-hook 'window-configuration-change-hook #'evil--jumps-window-configuration-hook t))))) +(defvar evil-mode) (add-hook 'evil-mode-hook (lambda () (when evil-mode (eval-after-load 'savehist '(progn + (defvar savehist-additional-variables) (add-to-list 'savehist-additional-variables 'evil-jumps-history) (let ((ring (make-ring evil-jumps-max-length))) (cl-loop for jump in (reverse evil-jumps-history) diff --git a/evil-tests.el b/evil-tests.el index bf45b6c..8653966 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -8087,47 +8087,47 @@ maybe we need one line more with some text\n") (let ((evil--jumps-buffer-targets "\\*\\(new\\|scratch\\|test\\)\\*")) (ert-info ("Test jumping backward and forward in a single buffer") (evil-test-buffer - "[z] z z z z z z z z z" - ("/z" [return]) - "z [z] z z z z z z z z" - ("nnnn") - "z z z z z [z] z z z z" - ("\C-o") - "z z z z [z] z z z z z" - ("\C-o") - "z z z [z] z z z z z z" - ("\C-i\C-i") - "z z z z z [z] z z z z")) + "[z] z z z z z z z z z" + ("/z" [return]) + "z [z] z z z z z z z z" + ("nnnn") + "z z z z z [z] z z z z" + ("\C-o") + "z z z z [z] z z z z z" + ("\C-o") + "z z z [z] z z z z z z" + ("\C-i\C-i") + "z z z z z [z] z z z z")) (ert-info ("Test jumping backward and forward across buffers") (evil-test-buffer - "[z] z z z z z z z z z" - (":new" [return] "inew buffer" [escape]) - "new buffe[r]" - ("\C-o") - "[z] z z z z z z z z z" - ("\C-i") - "new buffe[r]")) + "[z] z z z z z z z z z" + (":new" [return] "inew buffer" [escape]) + "new buffe[r]" + ("\C-o") + "[z] z z z z z z z z z" + ("\C-i") + "new buffe[r]")) (ert-info ("Test jumping backward and forward with counts") (evil-test-buffer - "[z] z z z z z z z z z" - ("/z" [return] "nnnn") - "z z z z z [z] z z z z" - ("3\C-o") - "z z [z] z z z z z z z" - ("2\C-i") - "z z z z [z] z z z z z" - )) + "[z] z z z z z z z z z" + ("/z" [return] "nnnn") + "z z z z z [z] z z z z" + ("3\C-o") + "z z [z] z z z z z z z" + ("2\C-i") + "z z z z [z] z z z z z" + )) (ert-info ("Jump list branches off when new jump is set") (evil-test-buffer - "[z] z z z z z z z" - ("/z" [return] "nnnn4\C-o") ;; adds a bunch of jumps after the 2nd z - "z [z] z z z z z z" - ("/z" [return]) ;; sets a new jump, list should be reset - "z z [z] z z z z z" - ("\C-o") - "z [z] z z z z z z" - ("3\C-i") ;; even after jumping forward 3 times it can't get past the 3rd z - "z z [z] z z z z z")))) + "[z] z z z z z z z" + ("/z" [return] "nnnn4\C-o") ;; adds a bunch of jumps after the 2nd z + "z [z] z z z z z z" + ("/z" [return]) ;; sets a new jump, list should be reset + "z z [z] z z z z z" + ("\C-o") + "z [z] z z z z z z" + ("3\C-i") ;; even after jumping forward 3 times it can't get past the 3rd z + "z z [z] z z z z z")))) (provide 'evil-tests) diff --git a/evil-vars.el b/evil-vars.el index 7dc5f18..e128f1c 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1172,7 +1172,7 @@ SYMBOL is made permanent buffer local." (evil-define-local-var evil-ud-scroll-count 0 "Holds last used prefix for `evil-scroll-up' and `evil-scroll-down'. -Determines how many lines should be scrolled. +Determines how many lines should be scrolled. Default value is 0 - scroll half the screen.") (evil-define-local-var evil-state nil |
