[英]How do I display a prompt when the cursor enters an overlay in emacs?
我正在写一个小型模式,可以免除写作建议。 我正在使用叠加来突出错误。 当点进入叠加层时,我想显示更多细节(现在有message
,但可能在单独的缓冲区中。)
help-echo
几乎就是我想要的,但是我在终端中使用Gnu Emacs,而help-echo
用于鼠标指针,而不是点。
point-entered
也几乎是我想要的,但point-entered
对叠加没有任何影响,只有文本属性。
叠加首先看起来很吸引人,因为当我重新分析缓冲区时很容易将它们删除(我正在re-builder
这里的内容。)我应该继续使用叠加但是使用点运动挂钩找到叠加层,提取提示,并显示它们? 我应该使用文本属性而不是叠加层吗?
您可能想尝试使用cursor-sensor-mode
(这是Emacs-25中的新功能),它允许您对cursor-sensor-functions
文本属性(包括通过叠加)进行操作。
它的目的是取代point-entered
性和反应的光标,而不是中移动的移动point
(两个密切相关的,但不同的:一个给定的命令可以在内部移动点很多次,但光标只会移动一次,在显示更新结束时)。
有些想法,请查看自动完成模式 。
它弹出菜单,人们可以滚动浏览。 这可能不是你想要的 - 听起来你不想要菜单 - 但是查看代码可能会很有趣。
另请参阅tooltip-show方法,tooltip.el的一部分。
tooltip-show is a compiled Lisp function in `tooltip.el'.
(tooltip-show TEXT &optional USE-ECHO-AREA)
Show a tooltip window displaying TEXT.
Text larger than `x-max-tooltip-size' is clipped.
If the alist in `tooltip-frame-parameters' includes `left' and `top'
parameters, they determine the x and y position where the tooltip
is displayed. Otherwise, the tooltip pops at offsets specified by
`tooltip-x-offset' and `tooltip-y-offset' from the current mouse
position.
Optional second arg USE-ECHO-AREA non-nil means to show tooltip
in echo area.
一般来说,对鼠标移动做出反应并不是一个好的设计,因为鼠标很可能会因为很多原因而通过你的区域。
我建议你在例如右侧菜单按钮上实现它。
当涉及到覆盖与文本属性时 - 一个区别是在执行buffer-substring
时保留了文本属性,这可能不是你想要的。 另一个是文本属性在继承的缓冲区之间共享(即使这是一个很少使用的功能)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.