首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在save-restriction中"buffer's restrictions“是什么意思?

在save-restriction中"buffer's restrictions“是什么意思?
EN

Stack Overflow用户
提问于 2012-07-22 05:33:07
回答 2查看 265关注 0票数 5

当我在Emacs中搜索"save-restriction“的描述时,它有一个关于”缓冲区的限制“的句子--我在下面包含了完整的描述。这个术语是什么意思?考虑到这一点,保存限制是如何工作的,什么时候应该使用它?

代码语言:javascript
复制
(save-restriction &rest BODY) 

Execute BODY, saving and restoring current buffer's restrictions.
The buffer's restrictions make parts of the beginning and end invisible. 
(They are set up with `narrow-to-region' and eliminated with `widen'.)
This special form, `save-restriction', saves the current buffer's restrictions
when it is entered, and restores them when it is exited.
So any `narrow-to-region' within BODY lasts only until the end of the form.
The old restrictions settings are restored
even in case of abnormal exit (throw or error).

The value returned is the value of the last form in BODY.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-22 05:37:42

save-restriction用于在隐藏当前缓冲区之前保存当前缓冲区,以便能够恢复它。

‘’save restriction‘存储所有的'buffer’数据结构,特别是point-min,point-max,point-max-marker等。例如,在窄函数修改缓冲区的可见性之前,它会记住旧的配置,以便能够使用widen()恢复它。

票数 3
EN

Stack Overflow用户

发布于 2012-07-22 06:24:54

除非您的代码的目的是修改限制、当前缓冲区、点或窗口配置,否则您应该使用适当的保存方法来记住状态并自动为您恢复状态。

  • save-current-buffer保存当前缓冲区,这样你就可以切换到另一个缓冲区,而不必记得切换。back.
  • save-excursion保存当前缓冲区及其当前点和标记,所以你可以移动点,而不必记住恢复it.
  • save-restriction保存限制,以便你可以缩小或widen它,而不必记住恢复it.
  • save-window-excursion保存帧上所有窗口的完整配置,除了当前缓冲区中的点的值。

(附注:当我上次使用save-window-excursion时,还没有window-configuration-p方法。)

票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11596010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档