我在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))
答案 0 :(得分:2)
这样的事情怎么样?
(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,你可能会得到更好的答案。 (而且速度也快!)=)