Emacs 光标动画(或:果冻光标)

大致效果:

cursor

只支持 macOS(别的系统需要有人写动画绘制部分的原生实现,见 lolipop.m),同时需要 Emacs 31 的 master branch commit 48b80a(用到了从 window structure 获取原生光标信息的新函数)。

如何安装:

克隆仓库后运行 make,会构建出 lolipop-mode.ellolipop-core.dylib 两个产物,把它们放到 Emacs 的 load-path 下,(require 'lolipop-mode) 之后启用 lolipop-mode 即可。

因为论坛对 GIF 的 10 MB 的上传限制,压缩的有点狠(画幅压缩,动画 30 帧)。高清版可以在这里看。

15 个赞

有点意思, 长得跟supermeatboy一样

2 个赞

mark,Emacs 31 发布之后我试试移植到 Windows

看了一下,还真有点像(

又是个厉害的老哥👍 有没有可能进emacs master?

如果你说的是光标动画的话,那得等 Linux 这些 Libre 的平台有人实现了光标动画才有可能

而且我估计如果最后进入 Emacs 的话肯定不是以 shared module 的形式

目前对我来说 shared module 已经完全够用了,而且调用动态库里的函数跟 C subr 的函数没有本质区别(

如果是这样能进 emacs-plus 也不错,使用起来会方便很多,可以考虑下。

emacs-plus 应该不会收录 Emacs 扩展吧,这是一个包,要说的话比较类似 pdf mode

我不确定 emacs-plus 收不收(

或者你的意思可能是把 Emacs master branch 里的那个这个包需要的函数放到 emacs-plus 里,这样用 Emacs 30 的人也能用这个包?

emacs-plus 里也是打 patch 的。

有两种方式:

  1. emacs-plus 编译时可以加patch。
  2. 如果能单独做成包,可以上elpa或者melpa。和pdf-tools,vterm 类似。

不知道目前情况更适合哪种。从灵活度上讲也许是2?当然如果能支持全平台上emacs master还是最好的,不过这是后话了。

lolipop 现在就是一个包,只不过出于某些原因暂时没有放到 melpa 上的打算

但是 lolipop 依赖一个近期被合到 Emacs 里的函数。如果想在 Emacs 30 上用就需要打 patch

支持全平台需要有人来写对应平台的原生实现,因为别的平台没有 CoreAnimation 和 AppKit(虽然动画的逻辑基本上跟它们是解耦的

1 个赞

可以用package-vc来安装,倒也无妨。

这个就需要给emacs-plus上patch了。

1 个赞

我等会把 Emacs 30 需要的 patch 发一下吧,挺简单的,就是暴露一些 window structure 里的值

这是 Emacs 30.2 需要的 patch

--- a/window.c	2025-01-04 19:05:30
+++ b/window.c	2026-01-05 20:52:31
@@ -8099,6 +8099,53 @@
   (Lisp_Object window)
 {
   return decode_live_window (window)->cursor_type;
+}
+
+DEFUN ("window-cursor-info", Fwindow_cursor_info, Swindow_cursor_info,
+       0, 1, 0,
+       doc: /* Return information about the cursor of WINDOW.
+WINDOW must be a live window and defaults to the selected one.
+
+The returned value is a vector of 6 elements:
+  [TYPE X Y WIDTH HEIGHT ASCENT]
+where
+  TYPE is the symbol representing the type of the cursor.  See
+    `cursor-type' for the meaning of the value.
+  X and Y are pixel coordinates of the cursor's top-left corner, relative
+    to the top-left corner of WINDOW's text area.
+  WIDTH and HEIGHT are the pixel dimensions of the cursor.
+  ASCENT is the number of pixels the cursor extends above the baseline.
+
+If the cursor is not currently displayed for WINDOW, return nil.
+
+Note that any element except the first one in the returned vector may be
+-1 if the actual value is currently unavailable.  */)
+  (Lisp_Object window)
+{
+  struct window *w = decode_live_window (window);
+
+  if (!w->phys_cursor_on_p)
+    return Qnil;
+
+  /* Default values for TTY frames.  */
+  int phys_cursor_width = 1, phys_cursor_height = 1, phys_cursor_ascent = 1;
+
+#ifdef HAVE_WINDOW_SYSTEM
+  struct frame *f = XFRAME (WINDOW_FRAME (w));
+  if (FRAME_WINDOW_P (f))
+    {
+      phys_cursor_width = w->phys_cursor_width;
+      phys_cursor_height = w->phys_cursor_height;
+      phys_cursor_ascent = w->phys_cursor_ascent;
+    }
+#endif
+  return CALLN (Fvector,
+                w->cursor_type,
+                make_fixnum (w->phys_cursor.x),
+                make_fixnum (w->phys_cursor.y),
+                make_fixnum (phys_cursor_width),
+                make_fixnum (phys_cursor_height),
+                make_fixnum (phys_cursor_ascent));
 }
 
 
@@ -9036,5 +9083,6 @@
   defsubr (&Swindow_parameter);
   defsubr (&Sset_window_parameter);
   defsubr (&Swindow_cursor_type);
+  defsubr (&Swindow_cursor_info);
   defsubr (&Sset_window_cursor_type);
 }
2 个赞

在 Emacs 30 安装成功。

配合 Emacs 缓冲区切换动画、光标处粒子爆炸、鼠标点击波纹、彩虹文本、窗口地震特效 - #11,来自 ginqi7 的鼠标点击波纹。使用鼠标点击时,有种六脉神剑的感觉,挺好玩的。

坐等大佬们把 MacOS 下的 Emacs 添加更多有趣的动画。

厉害!发reddit去震撼世界吧

2026-01-05-22:30:15-Emacs 上传一个糊版的 GIF,给群友看看效果。

3 个赞

Vibe 了个 Windows 的,之后接着改

现在只能说能跑,果冻条是一条粗细均匀的矩形,还不够好看

本地网络不好,传不上视频,先来个截图

3 个赞

太赞了,眼馋 Neovide 已久,终于吃上果冻了。

反馈一个小 bug。当 breadcrumb-mode 开启时,坐标计算错误。

不能传视频,只好传截图。

这是坐标错误的截图。

这是坐标正确的截图。


补充一下,不止是 breadcrumb-mode,常规的 org-capture 窗口也会出现坐标计算错误。

看了一下发现是 window-body-pixel-edges 返回的值考虑了 header-line-height,但 window-cursor-info 也考虑了这个值

试试这个 commit