Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
emacs.d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
Liu Miao
emacs.d
Commits
0e1a093c
Commit
0e1a093c
authored
2 years ago
by
Liu Miao
Browse files
Options
Downloads
Patches
Plain Diff
add search functions
parent
8d382b98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lisp/completion.el
+33
-30
33 additions, 30 deletions
lisp/completion.el
lisp/keybinds.el
+4
-1
4 additions, 1 deletion
lisp/keybinds.el
with
37 additions
and
31 deletions
lisp/completion.el
+
33
−
30
View file @
0e1a093c
...
...
@@ -72,36 +72,6 @@
:bind
(
:map
vertico-map
(
"DEL"
.
vertico-directory-delete-char
))
:config
(
cl-defun
vetico/search-files
(
&key
query
path
all-files
(
recursive
t
)
prompt
args
)
"Conduct a file search using ripgrep.
:query STRING
The initial input to search for.
:path PATH
Set the base directory to search out of. Default to the current project's root.
:recursive BOOL
Wheather or not to search files recursively from the base directory."
(
declare
(
indent
defun
))
(
unless
(
executable-find
"rg"
)
(
user-error
"Couldn't find ripgrep in your PATH"
))
(
require
'consult
)
())
(
defun
vertico/search-project
(
&optional
arg
)
"Conduct a text search in the current project root.
If prefix ARG is set, include ignored/hidden files."
(
interactive
"P"
)
(
let*
((
projectile-project-root
nil
)
(
disabled-command-function
nil
)
(
current-prefix-arg
(
unless
(
eq
arg
'other
)
arg
))
(
default-directory
(
if
(
eq
arg
'other
)
(
if-let
(
projects
(
projectile-relevant-known-projects
))
(
completing-read
"Search project: "
projects
nil
t
)
(
user-error
"There are no known projects"
))
default-directory
)))
()))
;; Bind directory delete
(
add-hook
'minibuffer-setup-hook
#'
vertico-repeat-save
))
(
use-package
consult
...
...
@@ -137,6 +107,39 @@ If prefix ARG is set, include ignored/hidden files."
consult-bookmark
consult-recent-file
consult--source-recent-file
consult--source-project-recent-file
))
(
defun
completion/search--dir
(
&optional
dir
initial
)
"Search directory.
DIR for the search directory.
INITIAL for the initial input."
(
require
'consult
)
(
let
()
(
cond
((
executable-find
"rg"
)
(
consult-ripgrep
dir
initial
))
((
executable-find
"grep"
)
(
consult-grep
dir
initial
))
(
t
(
user-error
"Couldn't find ripgrep or grep in PATH"
)))))
(
defun
completion/search-project
()
"Search current project."
(
interactive
)
(
completion/search--dir
nil
nil
))
(
defun
completion/search-project-at
()
"Search current project at point."
(
interactive
)
(
completion/search--dir
nil
(
thing-at-point
'symbol
)))
(
defun
completion/search-current-dir
()
"Search current directory."
(
interactive
)
(
completion/search--dir
default-directory
nil
))
(
defun
completion/search-current-dir-at
()
"Search current directory at point."
(
interactive
)
(
completion/search--dir
default-directory
(
thing-at-point
'symbol
)))
(
use-package
corfu
:ensure
t
;; Optional customizations
...
...
This diff is collapsed.
Click to expand it.
lisp/keybinds.el
+
4
−
1
View file @
0e1a093c
...
...
@@ -116,8 +116,11 @@
"pp"
'projectile-switch-project
;; Searching
"si"
#'
imenu
"sp"
#'
consult-ripgrep
"sp"
#'
completion/search-project
"sP"
#'
completion/search-project-at
"ss"
#'
consult-line
"sd"
#'
completion/search-current-dir
"sD"
#'
completion/search-current-dir-at
;; Flycheck
"en"
'flycheck-next-error
"ep"
'flycheck-previous-error
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment