在Emacs中定义新的工具提示 [英] Defining new tooltips in Emacs
问题描述
我想添加自定义工具提示到emacs。
更具体来说,每当我用鼠标悬停一个符号(函数/变量)名称
时,我希望看到一个带有符号定义的工具提示。
我知道我可以用cscope这样的工具找到这种信息,但我不知道如何
将cscope的输出附加到工具提示。
有没有人有一个部分(如何将回调链接到一般的emacs中的工具提示)或
a完整(我如何实际链接cscope的输出到工具提示)解决方案?
谢谢,
Nir
您的Emacs安装应包括 Elisp参考手册(如果没有,现在下载 - 你要去在开发模式时需要它)。要访问它,请转到信息(C-h i),并查找标记为Elisp的节点,有时在单独的Emacs菜单中。键入 i
索引和工具提示
以查找有关工具提示的信息。您应该找到节点 32.19.4具有特殊意义的属性,它告诉你, help-echo
属性的内容是一个字符串,它是一个工具提示内容,或一个函数可以动态构建工具提示。浏览关于该节点的手册,以了解有关文本属性的更多信息以及如何设置它们。
以下是一个简单的示例:
(insert(propertizefoo\\\
'help-echoTooltip!))
将其输入到您的 * scratch *
缓冲区中,然后按 Cj
运行代码。然后将鼠标指向foo,您应该会看到工具提示。
I would like to add custom tooltips to emacs. More specifically, whenever I hover on a symbol (function/variable) name with my mouse of I would like to see a tooltip with the symbol's definition. I know that I can find this kind of info with a tool like cscope but I have no idea how to attach the output of cscope to a tooltip. does anyone have a partial (how to link a callback to a tooltip in emacs in general) or a full (how do I actually link the output of cscope to a tooltip) solution to this?
Thanks, Nir
Your Emacs installation should include the Elisp reference manual (if not, download it now - you're going to need it when developing your mode). To access it, go to Info (C-h i) and look for a node labeled "Elisp", sometimes in a separate "Emacs" menu. Type i
for index and tooltip
to look for information on tooltips. You should find node 32.19.4 Properties with Special Meanings, which tells you that the content of the help-echo
property is a string that is the tooltip content, or a function that can construct the tooltip dynamically. Explore the manual around that node to find out more about text properties and how to set them.
Here's a simple example:
(insert (propertize "foo\n" 'help-echo "Tooltip!"))
Type this into your *scratch*
buffer and press C-j
to run the code. Then point your mouse at the word "foo" and you should see the tooltip.
这篇关于在Emacs中定义新的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!