Emacs 文件集:如何运行其他(elisp,不是 shell)命令?

发布于 2024-11-29 11:26:14 字数 233 浏览 2 评论 0原文

有 5 个 Elisp 命令可以在 Emacs 文件集上运行,并且能够运行任何 shell 命令。那么所有其他 Emacs 命令又如何呢?仅举一个例子,如果能够在文件集上运行 Mx 就太好了。

我知道可以在 dired 中标记多个文件,然后在它们上运行任何 Emacs 命令(这是真的,还是我与 shell 命令混淆了?),但是定义一次文件集然后能够使用会非常方便它就像一个用于各种文本编辑的单个文件。

感谢您的任何建议

There are 5 Elisp commands that can be run on an Emacs fileset, plus the ability to run any shell command. What about all the other Emacs commands? Just to give one example, it would be nice to be able to run M-x occur on a fileset.

I know its possible to mark several files in dired and then run any Emacs command on them (is that true, or am I confused with shell commands?), but it would be very convenient to define a fileset once and then be able to use it like one single file for all kinds of text editing.

Thanks for any advice

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你怎么这么可爱啊 2024-12-06 11:26:14

可对文件集进行操作的命令在全局自定义变量“filesets-commands”中指定。您可以将自己的命令添加到该列表中。该变量的默认值为:

("Isearch" multi-isearch-files
  (filesets-cmd-isearch-getargs))
 ("Isearch (regexp)" multi-isearch-files-regexp
  (filesets-cmd-isearch-getargs))
 ("Query Replace" perform-replace
  (filesets-cmd-query-replace-getargs))
 ("Query Replace (regexp)" perform-replace
  (filesets-cmd-query-replace-regexp-getargs))
 ("Grep <<selection>>" "grep"
  ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
 ("Run Shell Command" filesets-cmd-shell-command
  (filesets-cmd-shell-command-getargs)))

这些值由名称、函数和要在文件集的文件上运行的参数列表(或返回参数列表的函数)的关联列表组成。因此,如果您想添加一个对文件集执行“发生”命令的命令,您可以使用“Isearch”条目作为示例来创建您自己的新条目(您可以将其添加到“filesets-commands”中)全局变量),看起来像这样:

 ("Occur (regexp)" multi-occur-files-regexp
  (filesets-cmd-occur-getargs))

您需要编写“multi-occurr-files-regexp”和“filesets-cmd-occurr-getargs”函数(您可以使用现有的“multi-isearch-files-regexp”和“filesets-cmd-isearch-getargs”作为基础,因为它们是相似的)。这同样适用于您想要添加以处理文件集的任何其他 Emacs 命令。

The commands that can operate on file sets are specified in the global custom variable "filesets-commands". You can add your own commands to that list. The default value for this variable is:

("Isearch" multi-isearch-files
  (filesets-cmd-isearch-getargs))
 ("Isearch (regexp)" multi-isearch-files-regexp
  (filesets-cmd-isearch-getargs))
 ("Query Replace" perform-replace
  (filesets-cmd-query-replace-getargs))
 ("Query Replace (regexp)" perform-replace
  (filesets-cmd-query-replace-regexp-getargs))
 ("Grep <<selection>>" "grep"
  ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
 ("Run Shell Command" filesets-cmd-shell-command
  (filesets-cmd-shell-command-getargs)))

The values consist of an association list of names, functions, and an argument list (or a function that returns one) to be run on a filesets' files. So, if you wanted to add a command that does an "occur" command on the file set, you could use the "Isearch" entry as an example to create your own new entry (that you would add to the "filesets-commands" global variable) that would look something like:

 ("Occur (regexp)" multi-occur-files-regexp
  (filesets-cmd-occur-getargs))

You would need to write the "multi-occur-files-regexp" and "filesets-cmd-occur-getargs" functions (you could use the existing "multi-isearch-files-regexp" and "filesets-cmd-isearch-getargs" functions as a basis since they would be similar). The same would apply for any additional Emacs command that you wanted to add to work on file sets.

番薯 2024-12-06 11:26:14

Dired 对文件集有多种操作。一个示例是 dired-do-search(绑定到 A),您可以在其中使用 M-, 浏览多个文件的搜索结果就像标签搜索一样。同样,您可以在标记文件中进行查询替换(使用 Q)。

最近 irreal.org 上的帖子描述了一些不错的 dired 功能。

Dired has several operations on filesets. An example is dired-do-search (bound to A), where you can navigate through search results on several files with M-, just like with tags-search. Similarly, you can query-replace in tagged files (with Q).

The recent posts on irreal.org describe some nice dired features.

弱骨蛰伏 2024-12-06 11:26:14

通过Icicles,您可以使用文件集来对一组文件和目录执行任何您想要执行的操作。您可以在完成期间从缓冲区 Completions 中的任何文件和目录名称集创建文件集。并且您可以在完成过程中使用子字符串和正则表达式匹配来在Completions中获取这样一组文件名。

这些链接可能会有所帮助:

http://www.emacswiki.org/emacs/Icicles_-_Persistent_Completions#文件集

http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements#OpenDiredOnSavedFiles

http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements#MarkedFilesAsProject

http://www.emacswiki.org/emacs/Icicles_-_Customization_and_General_Tips#icicle-filesets-as-saved-completion-sets-flag

With Icicles you can use filesets for anything you might want to do with a set of files and directories. And you can create a fileset from any set of file and directory names in buffer Completions during completion. And you can use substring and regexp matching during completion to get such a set of file names in Completions.

These links might help:

http://www.emacswiki.org/emacs/Icicles_-_Persistent_Completions#Filesets

http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements#OpenDiredOnSavedFiles

http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements#MarkedFilesAsProject

http://www.emacswiki.org/emacs/Icicles_-_Customization_and_General_Tips#icicle-filesets-as-saved-completion-sets-flag

丑丑阿 2024-12-06 11:26:14

Dired+ 有命令< code>diredp-fileset,它在 Emacs 文件集上打开 Dired。系统会提示您选择要使用的文件集。

Dired+ has command diredp-fileset, which opens Dired on an Emacs fileset. You are prompted for the fileset to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文