blob: 77d5bb80a4cef8fc80568e12964a85e1e74c2724 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
;;; init-navigation.el --- Navigation Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defvar-local goto-char--last-char nil)
(use-package emacs
:config
(defun goto-char-forward (arg char)
"Move forward to char in line.
If a C-u prefix argument is given, it is not restricted to the current line.
If a numeric prefix argument N is given, move forward N instances of char."
(interactive "P\ncGo to char: ")
(setq goto-char--last-char char)
(goto-char--move-forward arg))
(defun goto-char-forward-repeat-last (arg)
"Move forward in line to char last used in a goto-char command.
If a C-u prefix argument is given, it is not restricted to the current line.
If a numeric prefix argument N is given, move forward N instances of the last
used char."
(interactive "P")
(goto-char--move-forward arg))
(defun goto-char-backward (arg char)
"Move forward to char in line.
If a C-u prefix argument is given, it is not restricted to the current line.
If a numeric prefix argument N is given, move back N instances of char."
(interactive "P\ncGo to char (backward):")
(setq goto-char--last-char char)
(goto-char--move-backward arg))
(defun goto-char-backward-repeat-last (arg)
"Move backward in line to char last qused in a goto-char command.
If a C-u prefix argument is given, it is not restricted to the current line.
If a numeric prefix argument N is given, move back N instances of the last used
char."
(interactive "P")
(goto-char--move-backward arg))
(defun goto-char--move-forward (arg)
(when goto-char--last-char
(let ((count (if (consp arg)
2 ;; C-u -> 2 (i.e. first match on any line)
(if (equal (char-after) goto-char--last-char)
(1+ (or arg 1)) ;; skip over the char after the cursor, if needed
arg)))
(end-position (unless (consp arg)
(line-end-position))))
(when (search-forward (string goto-char--last-char) end-position t count)
(backward-char)))))
(defun goto-char--move-backward (arg)
(when goto-char--last-char
(let ((count (unless (consp arg)
arg))
(start-position (unless (consp arg)
(line-beginning-position))))
(search-backward (string goto-char--last-char) start-position t count))))
:bind
("C-'" . goto-char-forward)
("C-;" . goto-char-backward)
("C-@" . goto-char-forward-repeat-last)
("C-:" . goto-char-backward-repeat-last))
(use-package smartscan
:config
(global-smartscan-mode t)
:hook
(cider-repl-mode . (lambda () (smartscan-mode -1)))
(ielm-mode . (lambda () (smartscan-mode -1)))
(vterm-mode . (lambda () (smartscan-mode -1)))
(eshell-mode . (lambda () (smartscan-mode -1))))
(use-package affe
:after (consult orderless)
:config
(setq affe-grep-command (replace-regexp-in-string "\\." "-Suu ." affe-grep-command))
;; Configure Orderless
(defun affe-orderless-regexp-compiler (input _type _ignorecase)
(setq input (orderless-pattern-compiler input))
(cons input (lambda (str) (orderless--highlight input str))))
(setq affe-regexp-compiler #'affe-orderless-regexp-compiler)
;; Manual preview key for `affe-grep'
(consult-customize affe-grep :preview-key (kbd "M-."))
(defun my/affe-grep-symbol-at-point (&optional dir initial)
(interactive
(list prefix-arg (when-let ((s (symbol-at-point)))
(symbol-name s))))
(affe-grep dir initial))
(defun my/affe-find-symbol-at-point (&optional dir initial)
(interactive
(list prefix-arg (when-let ((s (symbol-at-point)))
(symbol-name s))))
(affe-find dir initial))
:bind
("C-#" . affe-grep)
("C-c z" . affe-find)
("C-c Z" . my/affe-find-symbol-at-point)
("C-~" . my/affe-grep-symbol-at-point))
(use-package rg
:bind
("C-c C-M-r" . rg-menu)
("C-c C-M-R" . rg))
(provide 'init-navigation)
;;; init-navigation.el ends here
|