关于elisp的亮点区域

Wan*_*Qin 0 emacs elisp

看看这个简单的程序:

(defun test ()
  (interactive)
  (push-mark)
  (setq mark-active t)
  (search-forward "a" nil nil 1))
Run Code Online (Sandbox Code Playgroud)

它将光标移动到最近的'a',并突出显示路径.当然,这很明显.

但它的行为有所不同,具体取决于执行此过程后您的下一个输入是什么,例如,您输入一个字符,如'b'或\ Cg,突出显示消失,但如果您输入\ Cf或\ Ce,则突出显示保持不变.所以这是我的问题:是什么让这些输入表现不同?

JB.*_*JB. 6

Emacs手册:

在文本中的某个位置设置标记也会激活它.当标记处于活动状态时,Emacs通过使用区域面突出显示其中的文本来指示区域的范围(请参阅面部自定义).在某些非动作命令(包括更改缓冲区中文本的任何命令)之后,Emacs会自动停用该标记; 这会关闭突出显示.您也可以通过键入Cg随时显式停用标记(请参阅退出).


Dre*_*rew 5

除了JB所说的,你可以通过在命令结束时这样做来阻止他所引用的标记的自动停用:

(setq deactivate-mark  nil)
Run Code Online (Sandbox Code Playgroud)

这是doc字符串.注意最后一句话(这就是JB所说的).

deactivate-mark is a variable defined in `C source code'.
Its value is nil

Documentation:
If an editing command sets this to t, deactivate the mark afterward.
The command loop sets this to nil before each command,
and tests the value when the command returns.
Buffer modification stores t in this variable.
Run Code Online (Sandbox Code Playgroud)