简体   繁体   English

在不使用Cygwin的Windows上进行Emacs递归搜索/替换

[英]Emacs recursive search/replace on Windows without Cygwin

To answer "where did I also use this identifier?" 要回答“我还在哪里使用此标识符?” -questions, I run on macOS and the linuxes 问题,我在macOS和linuxes上运行

dired-maybe-insert-subdir
dired-mark-files-regexp

followed by either of: 其次是:

dired-do-find-regexp
dired-do-find-regexp-and-replace

On Windows I can get by using Emacs as my IDE without Cygwin, except for dired recursive search/replace. 在Windows上,可以使用Emacs作为我的IDE, 而无需 Cygwin, 除了递归的递归搜索/替换。

Does Projectile offer commands that will search/replace an identifier recursively without requiring Cygwin? Projectile是否提供不需要Cygwin 就能递归搜索/替换标识符的命令?

Does any other package make recursive search/replace possible on Windows without Cygwin? 是否有任何其他软件包使Windows上的递归查找/替换可能不Cygwin的?

I'm not concerned about the speed, because even after installing Cygwin, the recursive invocation of Cygwin's grep from within Emacs is painfully slow. 我并不担心速度,因为即使安装了Cygwin之后,从Emacs内部对Cygwin的grep的递归调用仍然非常缓慢。

Update: 更新:

Recursive search/replace seems to be available in both Helm and Projectile . 递归搜索/替换似乎在HelmProjectile中都可用。

If true, then my question is: 如果为真,那么我的问题是:

  1. Is the feature available on Windows without Cygwin? 在没有Cygwin的Windows上可以使用该功能吗?
  2. The list of require s in my .emacs is already excessive. 我的.emacs中的require列表已经过多。 What is a light package that will do recursive search/replace (without Cygwin on Windows)? 什么是轻量级软件包,可以进行递归搜索/替换(在Windows上没有Cygwin)?

Clarification: 澄清:

OK. 好。 Success. 成功。 [Thanks to Drew] With a .emacs containing nothing but (require 'dired+) , I can search-and-replace in marked files using M-+ Q on Windows without having Cygwin installed. [感谢Drew]使用.emacs除了(require 'dired+) ,什么都没有,我可以在Windows上使用M-+ Q在已标记文件中搜索和替换, 无需安装Cygwin。 I'm guessing that this will also work on linux/macOS, although perhaps not quite as quickly as delegating to grep . 我猜测这也可以在linux / macOS上运行,尽管可能不如委托给grep那样快。 (The "Act on ALL files [] in and UNDER this dir?" confirmation message will start to get tedious, but that's a separate question.) (“此目录下的所有文件都在[]下起作用?”确认消息将开始变得乏味,但这是一个单独的问题。)

For the present question one issue needs clarification. 对于当前问题,需要澄清一个问题。 dired+ augments the built-in dired family of commands. dired+扩展了内置的dired命令系列。 Is there a way for it to take over ordinary dired-do-find-regexp-and-replace ? 有没有办法接管普通的dired-do-find-regexp-and-replace That's because with the one-liner .emacs , and with a few marked files in a directory listing, I get 那是因为有了.emacs ,并且在目录列表中有一些标记文件,我得到了

File not found - GREP
File not found - -I
...
File not found - NUL
File not found - ;

indicating that grep is still being invoked. 表示仍在调用grep How can tell dired+ "I'm on Windows and I won't install Cygwin; please take over A and Q ?" 怎么能告诉dired+ “我在Windows上,并且我不会安装Cygwin;请接管AQ ?” (mapped by default dired-do-find-regexp and the aforementioned command). (默认情况下,映射为dired-do-find-regexp和上述命令)。

Editorial : dired+ seems a bit overwhelming, but if it solves this one problem (eliminate the need for Cygwin on Windows), it will be well-worth figuring out how to move from the usual dired commands to dired+ . 社论dired+似乎有点让人不知所措,但是如果它解决了这个问题(消除了Windows上对Cygwin的需要),那么就很有价值地弄清楚如何从通常的dired命令转到dired+

I think you're looking for a way to search files and get a list of those that match a regexp. 我认为您正在寻找一种搜索文件并获取与正则表达式匹配的列表的方法。 If tags-query-replace works for you on MS Windows (without Cygwin), and I think it should, then you can use command diredp-do-query-replace-regexp-recursive , bound to M-+ Q by default, available from Dired+ . 如果tags-query-replace在MS Windows(没有Cygwin)上为您工作,并且我认为应该可以,那么您可以使用diredp-do-query-replace-regexp-recursive ,默认情况下绑定到M-+ Q ,可用来自Dired +

That acts on all marked files in the current Dired buffer, and on all marked files in all of the buffer's marked subdirs, and so on, recursively. 该操作递归地作用于当前Dired缓冲区中的所有标记文件,以及所有缓冲区的标记子目录中的所有标记文件,依此类推。

With a non-negative prefix arg it acts on all files in the current buffer and all files in all subdirs, and so on, recursively. 使用非负前缀arg时,它将递归地作用于当前缓冲区中的所有文件以及所有子目录中的所有文件,依此类推。 (That is, any marks are ignored, and the effect is as if everything were marked.) (也就是说,所有标记都将被忽略,其效果就像所有标记都一样。)


If, instead of finding files that match a regexp, you want to search through files then you can use command diredp-do-isearch-regexp-recursive , bound to M-+ Ms a CM- by default, also available from Dired+. 如果不是要查找与正则表达式匹配的文件,而是要搜索文件,则可以使用diredp-do-isearch-regexp-recursive命令, diredp-do-isearch-regexp-recursive命令diredp-do-isearch-regexp-recursive绑定到M-+ Ms a CM- ,也可从Dired +获得。 The files to access are defined similarly (all Dired+ dired[p]-do...-recursive commands act similarly wrt which files are identified to act on). 要访问的文件的定义类似(所有Dired + dired[p]-do...-recursive命令的作用与确定要对其执行操作的文件类似)。 That definitely does not require any Cygwin etc. commands - it's just Isearch. 那绝对不需要任何Cygwin等命令-只是Isearch。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM