@@ -58,47 +58,70 @@ non-nil."
58
58
consult--source-project-buffer
59
59
consult--source-project-recent-file)))
60
60
61
-
62
- (defun spacemacs/compleseus-search (use-initial-input initial-directory )
63
- (let* ((initial-input (if use-initial-input
64
- (rxt-quote-pcre
65
- (if (region-active-p )
66
- (buffer-substring-no-properties
67
- (region-beginning ) (region-end ))
68
- (or (thing-at-point 'symbol t ) " " )))
69
- " " ))
61
+ (defun spacemacs/initial-search-input (&optional force-input )
62
+ " Get initial input from region for consult search functions. If region is not
63
+ active and `force-input' is not nil, `thing-at-point' will be returned."
64
+ (if (region-active-p )
65
+ (buffer-substring-no-properties
66
+ (region-beginning ) (region-end ))
67
+ (if force-input (thing-at-point 'symbol t ) " " ))
68
+ )
69
+
70
+ (defun spacemacs/compleseus-search (force-initial-input initial-directory )
71
+ (let* ((initial-input (rxt-quote-pcre
72
+ (spacemacs/initial-search-input force-initial-input)))
70
73
(default-directory
71
- (or initial-directory (read-directory-name " Start from directory: " ))))
74
+ (or initial-directory (read-directory-name " Start from directory: " ))))
72
75
(consult-ripgrep default-directory initial-input)))
73
76
74
77
(defun spacemacs/consult-line ()
75
78
(interactive )
76
79
(consult-line
77
- (if (region-active-p )
78
- (buffer-substring-no-properties
79
- (region-beginning ) (region-end ))
80
- (thing-at-point 'symbol t ))))
80
+ (spacemacs/initial-search-input)))
81
+
82
+ (defun spacemacs/consult-line-symbol ()
83
+ (interactive )
84
+ (consult-line
85
+ (spacemacs/initial-search-input t )))
81
86
82
87
(defun spacemacs/consult-line-multi ()
83
88
(interactive )
84
89
(consult-line-multi
85
90
nil
86
- (if (region-active-p )
87
- (buffer-substring-no-properties
88
- (region-beginning ) (region-end ))
89
- (thing-at-point 'symbol t ))))
91
+ (spacemacs/initial-search-input)))
92
+
93
+ (defun spacemacs/consult-line-multi-symbol ()
94
+ (interactive )
95
+ (consult-line-multi
96
+ nil
97
+ (spacemacs/initial-search-input t )))
90
98
91
99
(defun spacemacs/compleseus-search-auto ()
100
+ " Choose folder to search."
101
+ (interactive )
102
+ (spacemacs/compleseus-search nil nil ))
103
+
104
+ (defun spacemacs/compleseus-search-auto-symbol ()
92
105
" Choose folder to search."
93
106
(interactive )
94
107
(spacemacs/compleseus-search t nil ))
95
108
96
109
(defun spacemacs/compleseus-search-dir ()
110
+ " Search current folder."
111
+ (interactive )
112
+ (spacemacs/compleseus-search nil default-directory))
113
+
114
+ (defun spacemacs/compleseus-search-dir-symbol ()
97
115
" Search current folder."
98
116
(interactive )
99
117
(spacemacs/compleseus-search t default-directory))
100
118
101
119
(defun spacemacs/compleseus-search-projectile ()
120
+ " Search in current project."
121
+ (interactive )
122
+ (spacemacs/compleseus-search nil (projectile-project-root)))
123
+
124
+ (defun spacemacs/compleseus-search-projectile-symbol ()
102
125
" Search in current project."
103
126
(interactive )
104
127
(spacemacs/compleseus-search t (projectile-project-root)))
@@ -108,11 +131,6 @@ non-nil."
108
131
(interactive )
109
132
(spacemacs/compleseus-search-projectile))
110
133
111
- (defun spacemacs/compleseus-search-projectile-auto ()
112
- " Search in current project."
113
- (interactive )
114
- (spacemacs/compleseus-search nil (projectile-project-root)))
115
-
116
134
(defun spacemacs/compleseus-search-from (input )
117
135
" Embark action to start ripgrep search from candidate's directory."
118
136
(interactive " s" )
0 commit comments