emacs - 在 Emacs 工具提示中呈现 HTML?
问题描述
我想在 Emacs 工具提示中显示带有粗体和斜体文本的 HTML。我正在尝试的解决方案是这样的:
(let ((html "regular <b>bold</b> regular <i>italic</i> regular\n")
(bufname "* render-html-tmp*"))
(with-current-buffer (get-buffer-create bufname)
(erase-buffer)
(insert html)
(shr-render-region (point-min) (point-max))
(tooltip-show (buffer-string))))
在* render-html-tmp*
缓冲区中,粗体和斜体文本正常显示,但在工具提示中,所有五个单词都是纯常规文本,没有粗体或斜体。更改 的值x-gtk-use-system-tooltips
没有效果。
同时,当我走到* render-html-tmp*
缓冲区的末尾并在那里执行(insert (buffer-string))
时,或者将缓冲区内容复制到终止环并将其拉入新缓冲区时,粗体和斜体属性确实会正确显示在插入或拉出的文本中. 所以我的基本想法应该是正确的,而我正在试图弄清楚为什么我没有在工具提示中看到这些属性。
发生了什么,以及如何使粗体和斜体文本显示在工具提示中?
解决方案
tooltip-show
覆盖传递给它的字符串的 face 属性,并用它自己的tooltip
属性替换它:
(x-show-tip (propertize text 'face 'tooltip)
(selected-frame)
params
tooltip-hide-delay
tooltip-x-offset
tooltip-y-offset))
...
正如 OP 在评论中提到的那样,定义一个修改后的直接tooltip-show
传递text
给x-show-tip
而不是执行(propertize text ...)
并从他的代码中调用它可以解决问题。
推荐阅读
- php - 我可以在视图的错误日志中隐藏数据字段吗?
- python-3.x - 如何在看起来像字典的列中获取数据?
- c++ - 如何在不使用句柄或 HWND 的情况下从内存 hdc 获取矩形(或 &rc)
- amazon-web-services - ECS fargate 中边车容器中的 XRAY 关闭
- python-3.x - 如何在特定列中使用总和对熊猫中的行进行分组
- c# - 如何在另一个应用程序同时写入的情况下读取文本文件
- typescript - 使用数组 TypeOrm 查找
- r - 如何定期从 REST API 获取数据?
- php - httpd:httpd.conf 中的语法错误
没有关闭 - javascript - 如何通过 webhook 在 PayPal API 中确认每月订阅的计费?