使用 helm-do-grep 在当前文件夹中搜索
Search in current folder with helm-do-grep
我在 Emacs 中有这么小的问题。我为 Emacs 绑定 helm-do-grep
命令。真的很好用。
我想在当前文件夹中搜索一些东西。
我搜索了一些关于它们都在工作的代码,但我无法按照我想要的方式修复它们。
如果你帮我修好了我会很高兴谢谢你。
(defvar my/book-notes-directory "~/Dropbox/books")
(defun my/helm-do-grep-book-notes ()
"Search my book notes."
(interactive)
(helm-do-grep-1 (list my/book-notes-directory)))
(defun my-dir-locals-dir ()
"Return the directory local variables directory.
Code taken from `hack-dir-local-variables'."
(let ((variables-file (dir-locals-find-file (or (buffer-file-name) default-directory)))
(dir-name nil))
(cond,
((stringp variables-file)
(setq dir-name (file-name-directory variables-file)))
((consp variables-file)
(setq dir-name (nth 0 variables-file))))
dir-name))
这样的怎么样?
(defun my/helm-do-grep-current-directory-tree ()
"Recursively search current directory.
If a parent directory has a `dir-locals-file', use that as the
root instead."
(interactive)
(let ((variables-file (dir-locals-find-file
(or (buffer-file-name) default-directory))))
(helm-do-grep-1
(list
(cond
((stringp variables-file)
(file-name-directory variables-file))
((consp variables-file)
(nth 0 variables-file))
(t default-directory)))
t nil '("*"))))
顺便说一下,如果您在 http://emacs.stackexchange.com 上提问,您可能会得到更好的答案。 (而且速度也更快!)=)
我在 Emacs 中有这么小的问题。我为 Emacs 绑定 helm-do-grep
命令。真的很好用。
我想在当前文件夹中搜索一些东西。 我搜索了一些关于它们都在工作的代码,但我无法按照我想要的方式修复它们。
如果你帮我修好了我会很高兴谢谢你。
(defvar my/book-notes-directory "~/Dropbox/books")
(defun my/helm-do-grep-book-notes ()
"Search my book notes."
(interactive)
(helm-do-grep-1 (list my/book-notes-directory)))
(defun my-dir-locals-dir ()
"Return the directory local variables directory.
Code taken from `hack-dir-local-variables'."
(let ((variables-file (dir-locals-find-file (or (buffer-file-name) default-directory)))
(dir-name nil))
(cond,
((stringp variables-file)
(setq dir-name (file-name-directory variables-file)))
((consp variables-file)
(setq dir-name (nth 0 variables-file))))
dir-name))
这样的怎么样?
(defun my/helm-do-grep-current-directory-tree ()
"Recursively search current directory.
If a parent directory has a `dir-locals-file', use that as the
root instead."
(interactive)
(let ((variables-file (dir-locals-find-file
(or (buffer-file-name) default-directory))))
(helm-do-grep-1
(list
(cond
((stringp variables-file)
(file-name-directory variables-file))
((consp variables-file)
(nth 0 variables-file))
(t default-directory)))
t nil '("*"))))
顺便说一下,如果您在 http://emacs.stackexchange.com 上提问,您可能会得到更好的答案。 (而且速度也更快!)=)