Emacs使用大型XML文件

时间:2022-10-27 22:47:10

Often I need to read big XML files (> 100 MB) which have a fairly simple structure. I would like to use emacs, but it does not support big files very well. I am thinking maybe I can use a java application which can do SAX or StAX parsing for me and provide me with all necessary operations (e.g. search). What is the "right way" to communicate between emacs and an external java application?

我经常需要阅读具有相当简单结构的大XML文件(> 100 MB)。我想使用emacs,但它不能很好地支持大文件。我想也许我可以使用一个可以为我做SAX或StAX解析的java应用程序,并为我提供所有必要的操作(例如搜索)。在emacs和外部Java应用程序之间进行通信的“正确方法”是什么?

2 个解决方案

#1


I don't think there is a single "right way", but here are some ideas:

我不认为有一个“正确的方法”,但这里有一些想法:

  • make your Java app present the XML document as a bunch of threaded articles in groups; have it speak NNTP and use Gnus, or come up with your own protocol and write a Gnus backend for it (see the Web-browsing backends for inspiration)
  • 使您的Java应用程序将XML文档作为一组线程文章呈现在组中;让它说NNTP并使用Gnus,或者提出自己的协议并为它编写一个Gnus后端(请参阅Web浏览后端获取灵感)

  • think of the XML document as a Lisp program (S-expressions, XML elements, what is the difference?) and write a Swank backend that communicates with SLIME in Emacs, then use SLIME commands to make queries
  • 把XML文档想象成一个Lisp程序(S表达式,XML元素,有什么区别?)并编写一个与Emacs中的SLIME通信的Swank后端,然后使用SLIME命令进行查询

  • write a FUSE driver so you can mount your XML document as a file system and use Dired to explore it.
  • 编写一个FUSE驱动程序,以便将XML文档作为文件系统挂载,并使用Dired来探索它。

#2


You can try disable font-lock-mode for that particular buffer. I have opened much bigger files than that using emacs. I noticed slow down only when lines in the file are bigger than my screen and they start to wrap. Letting them go out of the screen and disabling font-lock accelerates performence.

您可以尝试禁用该特定缓冲区的font-lock-mode。我打开了比使用emacs更大的文件。我注意到只有当文件中的行大于我的屏幕并且它们开始换行时才会减速。让它们离开屏幕并禁用字体锁可以加速性能。

#1


I don't think there is a single "right way", but here are some ideas:

我不认为有一个“正确的方法”,但这里有一些想法:

  • make your Java app present the XML document as a bunch of threaded articles in groups; have it speak NNTP and use Gnus, or come up with your own protocol and write a Gnus backend for it (see the Web-browsing backends for inspiration)
  • 使您的Java应用程序将XML文档作为一组线程文章呈现在组中;让它说NNTP并使用Gnus,或者提出自己的协议并为它编写一个Gnus后端(请参阅Web浏览后端获取灵感)

  • think of the XML document as a Lisp program (S-expressions, XML elements, what is the difference?) and write a Swank backend that communicates with SLIME in Emacs, then use SLIME commands to make queries
  • 把XML文档想象成一个Lisp程序(S表达式,XML元素,有什么区别?)并编写一个与Emacs中的SLIME通信的Swank后端,然后使用SLIME命令进行查询

  • write a FUSE driver so you can mount your XML document as a file system and use Dired to explore it.
  • 编写一个FUSE驱动程序,以便将XML文档作为文件系统挂载,并使用Dired来探索它。

#2


You can try disable font-lock-mode for that particular buffer. I have opened much bigger files than that using emacs. I noticed slow down only when lines in the file are bigger than my screen and they start to wrap. Letting them go out of the screen and disabling font-lock accelerates performence.

您可以尝试禁用该特定缓冲区的font-lock-mode。我打开了比使用emacs更大的文件。我注意到只有当文件中的行大于我的屏幕并且它们开始换行时才会减速。让它们离开屏幕并禁用字体锁可以加速性能。