加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

从Windows上的Emacs中的“grep-find”运行时,ack不起作用

发布时间:2020-12-14 04:01:39 所属栏目:Windows 来源:网络整理
导读:我正在尝试使用 ack-grep作为Windows上Emacs中grep查找的替代品,但是ack-grep立即(成功)退出而不打印任何匹配项.我已经尝试了几乎所有可能的命令行参数组合到ack-grep,但似乎没有任何效果. M-x grep-find 输入“ack html”以搜索包含“html”的文件. Ack立刻
我正在尝试使用 ack-grep作为Windows上Emacs中grep查找的替代品,但是ack-grep立即(成功)退出而不打印任何匹配项.我已经尝试了几乎所有可能的命令行参数组合到ack-grep,但似乎没有任何效果.

M-x grep-find

输入“ack html”以搜索包含“html”的文件. Ack立刻退出,什么都不打印:

-*- mode: grep; default-directory: "c:/" -*-
Grep started at Tue Feb 23 23:50:52

ack html

Grep finished (matches found) at Tue Feb 23 23:50:52

在cmd.exe中执行相同的命令“ack html”工作正常(显示包含字符串“html”的许多各种文件).

有任何想法吗?

解决方法

当在Windows下的Emacs下运行ack时,我发现它有时会混淆它是应该搜索文件还是从STDIN读取.这是我用来调用ack的函数(使用M-x ack).你可以把它放在.emacs中.

(defvar ack-command "ack --nogroup --nocolor ")
(defvar ack-history nil)
(defvar ack-host-defaults-alist nil)
(defun ack ()
  "Like grep,but using ack-command as the default"
  (interactive)
  ; Make sure grep has been initialized
  (if (>= emacs-major-version 22)
      (require 'grep)
    (require 'compile))
  ; Close STDIN to keep ack from going into filter mode
  (let ((null-device (format "< %s" null-device))
        (grep-command ack-command)
        (grep-history ack-history)
        (grep-host-defaults-alist ack-host-defaults-alist))
    (call-interactively 'grep)
    (setq ack-history             grep-history
          ack-host-defaults-alist grep-host-defaults-alist)))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读