2

我在 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))
4

1 回答 1

4

这样的事情怎么样?

(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上提问,您可能会得到更好的答案。(而且更快!)=)

于 2015-06-12T19:35:14.333 回答