简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
本篇目的:为Emacs改造目前最快的搜索文本的工具:ripgrep。
# rg -g '*.{java,cpp}' native_tagSocketFd /home
(defun rg-grep ()
(interactive)
;;读取字符串
(setq arg (read-string ": "))
;;调用rg命令搜索
(shell-command (concat "rg -g '*.{java,cpp}' " arg " /home"))
)
(defun ripgrep-regexp (regexp &optional args)
(interactive
(list (read-from-minibuffer "Ripgrep search for: " (thing-at-point 'symbol))))
(compilation-start
(mapconcat 'identity
(append
;;可以过滤搜索的文件格式.
'("rg" "-g '*.{java,cpp,c,h,aidl,hal,rc,bp,mk,cc}' --color=always" "--no-heading" "--line-number" "--with-filename" "--ignore-case" )
;;搜索的字段,可以是正则表达式
(list (shell-quote-argument regexp))
;;搜索的默认路径
'("/home")
) " ")
'ripgrep-search-mode)
)
(defun ripgrep-regexp (regexp directory &optional args)
(interactive
(list (read-from-minibuffer "Ripgrep search for: " (thing-at-point 'symbol))
(read-directory-name "Directory: ")
))
(setq default-directory directory)
(compilation-start
(mapconcat 'identity
(append
;;可以过滤搜索的文件格式.
'("rg" "-g '*.{java,cpp,c,h,aidl,hal,rc,bp,mk,cc}' --color=always" "--no-heading" "--line-number" "--with-filename" "--ignore-case" )
;;搜索的字段,可以是正则表达式
(list (shell-quote-argument regexp))
;;搜索的默认路径
;;'("/home")
'(".")
) " ")
'ripgrep-search-mode)
)
;;v5.0 输入搜索字段,默认cd到/home目录,解决输入 '("/home") 时,显示全路径,导致过长的问题。
(defun ripgrep-regexp (regexp &optional args)
(interactive
(list (read-from-minibuffer "Ripgrep search for: " (thing-at-point 'symbol))
))
;;其实就是cd到指定的目录后,在当前目录开始搜索.
(setq default-directory "/home")
(compilation-start
(mapconcat 'identity
(append
;;可以过滤搜索的文件格式.
'("rg" "-g '*.{java,cpp,c,h,aidl,hal,rc,bp,mk,cc}' --color=always" "--no-heading" "--line-number" "--with-filename" "--ignore-case" )
;;搜索的字段,可以是正则表达式
(list (shell-quote-argument regexp))
;;搜索的默认路径
;;'("/home")
'(".")
) " ")
'ripgrep-search-mode)
)