Add better-jumper
Replaces evil's jumplist; makes its functionality available for non evil users.
This commit is contained in:
parent
b189254050
commit
a4c5396558
11 changed files with 55 additions and 25 deletions
|
@ -141,7 +141,43 @@ savehist file."
|
|||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
;;; Packages
|
||||
|
||||
(def-package! better-jumper
|
||||
:after-call (pre-command-hook)
|
||||
:init
|
||||
(global-set-key [remap evil-jump-forward] #'better-jumper-jump-forward)
|
||||
(global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward)
|
||||
:config
|
||||
(add-hook 'better-jumper-post-jump-hook #'recenter)
|
||||
|
||||
(defun doom*set-jump (orig-fn &rest args)
|
||||
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
|
||||
(better-jumper-set-jump (if (markerp (car args)) (car args)))
|
||||
(let ((evil--jumps-jumping t)
|
||||
(better-jumper--jumping t))
|
||||
(apply orig-fn args)))
|
||||
|
||||
(defun doom*set-jump-maybe (orig-fn &rest args)
|
||||
"Set a jump point if ORIG-FN returns non-nil."
|
||||
(let ((origin (point-marker))
|
||||
(result
|
||||
(let* ((evil--jumps-jumping t)
|
||||
(better-jumper--jumping t))
|
||||
(apply orig-fn args))))
|
||||
(unless result
|
||||
(with-current-buffer (marker-buffer origin)
|
||||
(better-jumper-set-jump
|
||||
(if (markerp (car args))
|
||||
(car args)
|
||||
origin))))
|
||||
result))
|
||||
|
||||
(defun doom|set-jump ()
|
||||
"Run `better-jumper-set-jump' but return nil, for short-circuiting hooks."
|
||||
(better-jumper-set-jump)
|
||||
nil))
|
||||
|
||||
|
||||
(def-package! smartparens
|
||||
;; Auto-close delimiters and blocks as you type. It's more powerful than that,
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
(package! ace-link)
|
||||
(package! ace-window)
|
||||
(package! avy)
|
||||
(package! better-jumper
|
||||
:recipe (:fetcher github :repo "gilbertw1/better-jumper"))
|
||||
(package! command-log-mode)
|
||||
(package! dtrt-indent)
|
||||
(package! helpful)
|
||||
|
|
|
@ -143,7 +143,9 @@ be negative.")
|
|||
(define-key helm-ag-edit-map [remap quit-window] #'helm-ag--edit-abort)
|
||||
(set-popup-rule! "^\\*helm-ag-edit" :size 0.35 :ttl 0 :quit nil)
|
||||
;; Recenter after jumping to match
|
||||
(advice-add #'helm-ag--find-file-action :after-while #'doom*recenter))
|
||||
(advice-add #'helm-ag--find-file-action :after-while #'doom*recenter)
|
||||
;; And record position before jumping
|
||||
(advice-add #'helm-ag--find-file-action :around #'doom*set-jump-maybe))
|
||||
|
||||
|
||||
;; `helm-bookmark'
|
||||
|
|
|
@ -161,6 +161,9 @@ immediately runs it on the current candidate (ending the ivy session)."
|
|||
|
||||
(add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode nil #'eq)
|
||||
|
||||
;; Record in jumplist when opening files via counsel-{ag,rg,pt,git-grep}
|
||||
(add-hook 'counsel-grep-post-action-hook #'better-jumper-set-jump)
|
||||
|
||||
;; Factories
|
||||
(defun +ivy-action-reloading (cmd)
|
||||
(lambda (x)
|
||||
|
|
|
@ -191,13 +191,6 @@ more information on modifiers."
|
|||
(or (and (>= char ?2) (<= char ?9))
|
||||
(funcall orig-fn char)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +evil*set-jump (orig-fn &rest args)
|
||||
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
|
||||
(evil-set-jump (if (markerp (car args)) (car args)))
|
||||
(let ((evil--jumps-jumping t))
|
||||
(apply orig-fn args)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +evil*fix-dabbrev-in-minibuffer ()
|
||||
"Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See
|
||||
|
|
|
@ -109,11 +109,6 @@ line with a linewise comment.")
|
|||
(advice-add #'evil-window-split :override #'+evil*window-split)
|
||||
(advice-add #'evil-window-vsplit :override #'+evil*window-vsplit)
|
||||
|
||||
;; Integrate evil's jump-list into some navigational commands
|
||||
(advice-add #'counsel-git-grep-action :around #'+evil*set-jump)
|
||||
(advice-add #'helm-ag--find-file-action :around #'+evil*set-jump)
|
||||
(advice-add #'xref-push-marker-stack :around #'+evil*set-jump)
|
||||
|
||||
;; In evil, registers 2-9 are buffer-local. In vim, they're global, so...
|
||||
(advice-add #'evil-global-marker-p :around #'+evil*make-numbered-markers-global)
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
;; `imenu-anywhere'
|
||||
(setq imenu-anywhere-delimiter ": ")
|
||||
|
||||
(add-hook 'imenu-after-jump-hook #'better-jumper-set-jump)
|
||||
|
||||
|
||||
(after! imenu-list
|
||||
(setq imenu-list-idle-update-delay 0.5)
|
||||
|
|
|
@ -226,8 +226,7 @@ This is ignored by ccls.")
|
|||
;; Use rtags-imenu instead of imenu/counsel-imenu
|
||||
(define-key! (c-mode-map c++-mode-map) [remap imenu] #'+cc/imenu)
|
||||
|
||||
(when (featurep 'evil)
|
||||
(add-hook 'rtags-jump-hook #'evil-set-jump))
|
||||
(add-hook 'rtags-jump-hook #'better-jumper-set-jump)
|
||||
(add-hook 'rtags-after-find-file-hook #'recenter))
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
(add-hook 'org-load-hook #'+org|setup-evil-keybinds)
|
||||
(add-hook 'evil-org-mode-hook #'evil-normalize-keymaps)
|
||||
:config
|
||||
(add-hook 'org-open-at-point-functions #'evil-set-jump)
|
||||
;; change `evil-org-key-theme' instead
|
||||
(advice-add #'evil-org-set-key-theme :override #'ignore)
|
||||
(def-package! evil-org-agenda
|
||||
|
@ -475,6 +474,7 @@ conditions where a window's buffer hasn't changed at the time this hook is run."
|
|||
(+org|setup-hacks)
|
||||
(+org|setup-custom-links)
|
||||
|
||||
(add-hook 'org-open-at-point-functions #'doom|set-jump)
|
||||
|
||||
;; Cross-module configuration
|
||||
(set-popup-rules!
|
||||
|
|
|
@ -128,7 +128,7 @@ Otherwise, these properties are available to be set:
|
|||
#'switch-to-buffer)
|
||||
(marker-buffer result))
|
||||
(goto-char result)
|
||||
(recenter)
|
||||
(better-jumper-set-jump)
|
||||
result)))
|
||||
|
||||
|
||||
|
|
|
@ -74,12 +74,6 @@ If the argument is interactive (satisfies `commandp'), it is called with
|
|||
`call-interactively' (with no arguments). Otherwise, it is called with one
|
||||
argument: the identifier at point.")
|
||||
|
||||
;; Recenter buffer after certain jumps
|
||||
(add-hook!
|
||||
'(imenu-after-jump-hook evil-jumps-post-jump-hook
|
||||
counsel-grep-post-action-hook dumb-jump-after-jump-hook)
|
||||
#'recenter)
|
||||
|
||||
|
||||
;;
|
||||
;;; dumb-jump
|
||||
|
@ -92,7 +86,8 @@ argument: the identifier at point.")
|
|||
dumb-jump-selector
|
||||
(cond ((featurep! :completion ivy) 'ivy)
|
||||
((featurep! :completion helm) 'helm)
|
||||
('popup))))
|
||||
('popup)))
|
||||
(add-hook 'dumb-jump-after-jump-hook #'better-jumper-set-jump))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -102,6 +97,9 @@ argument: the identifier at point.")
|
|||
;; set these up ourselves in other modules.
|
||||
(setq-default xref-backend-functions '(t))
|
||||
|
||||
;; Use `better-jumper' instead of xref's marker stack
|
||||
(advice-add #'xref-push-marker-stack :around #'doom*set-jump)
|
||||
|
||||
;; ...however, it breaks `projectile-find-tag', unless we put it back.
|
||||
(defun +lookup*projectile-find-tag (orig-fn)
|
||||
(let ((xref-backend-functions '(etags--xref-backend t)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue