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

查看:21
本文介绍了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.

我目前正在编写代码,我不想在处理第 41 行及以上的代码时意外修改代码的前 40 行.

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天全站免登陆