dotfiles/.emacs.d/lisp/init-navigation.el

134 lines
4.4 KiB
EmacsLisp
Raw Normal View History

2021-08-17 11:49:19 +00:00
;;; init-navigation.el --- Navigation Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
2022-08-13 10:29:14 +00:00
(use-package avy
2022-12-26 16:33:47 +00:00
:custom
(avy-all-windows nil)
(avy-all-windows-alt t)
(avy-timeout-seconds 0.3)
2022-08-13 10:29:14 +00:00
:config
;; https://karthinks.com/software/avy-can-do-anything/#avy-plus-embark-any-action-anywhere
(defun avy-action-embark (pt)
(unwind-protect
(save-excursion
(goto-char pt)
(embark-act))
(select-window
(cdr (ring-ref avy-ring 0))))
t)
(add-to-list 'avy-dispatch-alist '(111 . avy-action-embark))
2022-12-08 16:45:17 +00:00
(defun avy-copy-as-kill ()
(interactive)
(avy-goto-char-timer)
(let ((beg (point)))
(avy-goto-char-timer)
(copy-region-as-kill beg (point))))
(defun avy-kill-in-line ()
(interactive)
(avy-goto-char-timer)
(let ((beg (point)))
(call-interactively 'avy-goto-char-in-line)
(copy-region-as-kill beg (point))))
2022-08-13 10:29:14 +00:00
:bind
2022-09-16 11:23:59 +00:00
("C-'" . avy-goto-char-timer)
2022-12-08 16:45:17 +00:00
("C-;" . avy-goto-char-in-line)
("C-c C-'" . avy-copy-as-kill)
("C-c C-;" . avy-copy-as-kill-in-line))
2022-08-13 10:29:14 +00:00
2021-08-17 11:49:19 +00:00
(use-package smartscan
:config
(unbind-key "M-'" smartscan-map)
2022-10-12 15:41:45 +00:00
(defvar-local smartscan-exclude-modes '(cider-repl-mode
ielm-mode
vterm-mode
term-mode
ansi-term-mode
eshell-mode
shell-mode
sql-interactive-mode
magit-status-mode
2022-10-12 15:41:45 +00:00
compilation-mode
deadgrep-mode))
(defun turn-off-smartscan-mode ()
(smartscan-mode -1))
(dolist (mode smartscan-exclude-modes)
(add-hook (intern (concat (symbol-name mode) "-hook")) #'turn-off-smartscan-mode))
2021-08-17 11:49:19 +00:00
:hook
2023-05-19 11:09:57 +00:00
(elpaca-after-init . global-smartscan-mode)
:bind (:map smartscan-map
("C-M-'" . smartscan-symbol-replace)))
2021-08-17 11:49:19 +00:00
2022-06-04 12:12:26 +00:00
(use-package symbol-overlay
2022-10-17 15:38:36 +00:00
:config
(defun symbol-overlay-put-or-clear (arg)
"Toggle all overlays of symbol at point.
Or remove all highlighted symbols in the current buffer (with`ARG')."
(interactive "P")
(if arg
(symbol-overlay-remove-all)
(symbol-overlay-put)))
2022-06-04 12:12:26 +00:00
:bind
2022-10-17 15:38:36 +00:00
("C-c o" . symbol-overlay-put-or-clear)
2022-06-04 12:12:26 +00:00
("M-N" . symbol-overlay-switch-forward)
2022-10-17 15:38:36 +00:00
("M-P" . symbol-overlay-switch-backward))
2022-06-04 12:12:26 +00:00
2022-09-16 05:53:27 +00:00
(use-package gumshoe
:defer 5
:after perspective
2023-01-17 13:18:36 +00:00
:diminish global-gumshoe-mode
2022-10-21 15:40:33 +00:00
:custom
(gumshoe-show-footprints-p nil)
(gumshoe-idle-time 5)
(gumshoe-follow-distance 5)
2022-09-16 05:53:27 +00:00
:config
(global-gumshoe-persp-mode +1)
(defvar gumshoe-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "]") #'gumshoe-buf-backtrack-forward)
(define-key map (kbd "[") #'gumshoe-buf-backtrack-back)
(define-key map (kbd "}") #'gumshoe-persp-backtrack-forward)
(define-key map (kbd "{") #'gumshoe-persp-backtrack-back)
map))
(dolist (cmd '(gumshoe-buf-backtrack-forward gumshoe-buf-backtrack-back gumshoe-persp-backtrack-forward gumshoe-persp-backtrack-back))
(put cmd 'repeat-map 'gumshoe-repeat-map))
:bind
("C-c ]" . gumshoe-buf-backtrack-forward)
("C-c [" . gumshoe-buf-backtrack-back)
("C-c }" . gumshoe-persp-backtrack-forward)
("C-c {" . gumshoe-persp-backtrack-back)
("C-c '" . gumshoe-peruse-in-persp))
2022-10-21 15:54:28 +00:00
(use-package goto-chg
:config
(defvar goto-chg-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-(") #'goto-last-change)
(define-key map (kbd "C-)") #'goto-last-change-reverse)
map))
(dolist (cmd '(goto-last-change goto-last-change-reverse))
(put cmd 'repeat-map 'goto-chg-repeat-map))
:bind
("C-c C-(" . goto-last-change)
("C-c C-)" . goto-last-change-reverse))
(use-package goto-last-point
:diminish
:custom (goto-last-point-max-length 100)
2023-05-19 11:09:57 +00:00
:hook (elpaca-after-init . goto-last-point-mode)
2022-10-21 15:54:28 +00:00
:config
(defvar goto-last-point-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<") #'goto-last-point)
map))
(put 'goto-last-point 'repeat-map 'goto-last-point-repeat-map)
:bind ("C-c <" . goto-last-point))
2023-03-11 13:24:49 +00:00
(use-package link-hint
:bind
("C-c C-l" . link-hint-open-link)
("C-c C-S-l" . link-hint-copy-link))
2021-08-17 11:49:19 +00:00
(provide 'init-navigation)
;;; init-navigation.el ends here