【问题标题】:Search in current folder with helm-do-grep使用 helm-do-grep 在当前文件夹中搜索
【发布时间】:2015-05-09 16:18:27
【问题描述】:

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

【问题讨论】:

    标签: search emacs emacs-helm


    【解决方案1】:

    这样的事情怎么样?

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 2023-04-05
      相关资源
      最近更新 更多