如何使用“隐藏区域”?封装在elisp中 [英] How to use "hide-region" package in elisp

查看:94
本文介绍了如何使用“隐藏区域”?封装在elisp中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个众所周知的软件包hide-region 链接到软件包(hide-region) .el)
我想将文件中某个点a的隐藏区域隐藏应用到点b [一个区域]。我怎样才能做到这一点?我需要定义什么?当我手动突出显示一些文本时,它可以工作,但是我需要在代码中进行处理并为其乞求。一个区域和该区域的末端,并将其应用于结果区域。

There is this well-known package hide-region Link to the package (hide-region.el) I want to apply hide-region-hide from a certain "point a" to "point b" [a region] in my file. How can I do this? What I need to define? It works when I highlight manually some text, but I need to do it in my code and give it the beg. of a region and end of region and apply it to the resulted region.

推荐答案

该程序包的编写方式有些差,并且不允许您将其作为参数传递给函数。您可能可以通过以下方式解决此问题:

The package is somewhat poorly written, and does not allow you to pass it a region as arguments to the function. You can probably work around this by something like

(save-excursion
  (let (deactivate-mark) ; see save-excursion docs for why
    (set-mark point-a)  ; beginning of region you want to hide
    (goto-char point-b) ; end of region you want to hide
    (hide-region-hide) ) )

如果 hide会更好-region-hide 将区域作为非交互式调用时的参数。维护人员可能会乐于接受此补丁。另请参阅设置标记的文档,该文档特别建议不要像我上面所做的那样使用它。此外,也许您还想查看 save-excursion 的文档。

It would be better if hide-region-hide took the region as arguments when called noninteractively, though. Perhaps the maintainer would be happy to accept a patch for this. See also the documentation for set-mark which specifically advises against using it like I have done above. Furthermore, perhaps you also want to look at the documentation for save-excursion.

这篇关于如何使用“隐藏区域”?封装在elisp中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆