Emacs:左边缘的 TODO 指示器有一个奇怪的副作用 - 删除字符

标签 emacs

我刚看完 Emacs :TODO indicator at left side ,并试了一下。这似乎很有趣。小指示器三角形出现,但我得到了一个奇怪的副作用:文本本身正在被改变。正在删除字符。

前:

alt text

后:

alt text

模式行确实表明在运行 annotate-todo 后缓冲区已被更改。 .
这怎么解释?

(我在 Windows 上使用 emacs 22.2.1)

最佳答案

啊……我之前看到了我的方式的错误。这是一个新版本。

(defun annotate-todo ()
  "put fringe marker on TODO: lines in the curent buffer"
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "TODO:" nil t)
      (let ((overlay (make-overlay (- (point) 5) (point))))
        (overlay-put overlay 'before-string (propertize (format "A")
                                                        'display '(left-fringe right-triangle)))))))

第一个解决方案使用了 'display text 属性,它改变了指定文本的显示方式,在这种情况下,它被 left fringe 中的三角形替换。 .我需要做的是使用 'before-string overlay反而。这不会改变正在显示的字符串。

另一个优点,由此注释的代码的剪切/粘贴不带标记。

我已经更新了原始问题中的代码以反射(reflect)这一变化。

关于Emacs:左边缘的 TODO 指示器有一个奇怪的副作用 - 删除字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2348679/

相关文章:

emacs - 强制表排序

Emacs 斜体组织模式

ruby - 有没有人让 swank.rb 与 Emacs 24 一起工作?

emacs - Flycheck-Google-Cpplint 未正确配置

Emacs 23.2 为导航到的每个编译错误/警告打开一个新窗口

emacs - 如何在 Docker Hub 中从源代码构建 Emacs? BSS 和堆之间的差距

shell - Emacs ansi-term 作为登录 shell

emacs - 用 Emacs 交换 2 列

vim - 为什么我应该使用 IDE?

c++ - Emacs auto-complete-c-headers 不适用于引号