Emacs特定区域只读 [英] Emacs specific region read only

查看:149
本文介绍了Emacs特定区域只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用emacs时,如何在文本文件中制作特定区域。我知道ctrl + X + Q
使整个文件是只读的。

How does one make a specific region in a text file read only when using emacs. I know ctrl+X+Q to make the whole file a read only.

我正在编写代码,我不想意外修改我的代码的前40行在线41和以上工作。

I am currently writing a code and I do not want to modify by accident the first 40 lines of my code while working on lines 41 and upwards.

推荐答案

使用文本属性:

(defun set-region-read-only (begin end)
  (interactive "r")
  (add-text-properties begin end '(read-only t)))

相关文档:

文本属性

更改属性

特殊属性(如只读)

这篇关于Emacs特定区域只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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