Emacs :TODO 指示器在左侧 [英] Emacs :TODO indicator at left side

查看:19
本文介绍了Emacs :TODO 指示器在左侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在源代码中的任何地方都在行的左侧有某种指标

I want to have sort of indiacator at left side of the line wherever I have in the source code

#TODO:一些评论

//TODO: 一些评论

//TODO: some comments

指示器可能只是一个标记,我已经启用了在 emacs 中显示的行号.

The indicator could be a just mark and I already enabled line numbers displayed at emacs.

推荐答案

此命令将执行您想要的操作.

This command will do something like you want.

(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 "A"
                                                        'display '(left-fringe right-triangle)))))))

您可以自定义位图 根据需要.

要将此应用于所有文件,您可以将其添加到 'find-file-hooks

To get this to apply to all files, you could add it to the 'find-file-hooks

(add-hook 'find-file-hooks 'annotate-todo)

或者,如果您只需要某些模式,可以将其添加到这些模式挂钩中.

Or, if you want it just for certain modes, you could add it to those mode hooks.

参见边缘显示"属性Overlays,最重要的是 before-string 属性.

See Fringes, The 'display' Property, Overlays, and most importantly the before-string property.

注意:代码已于 2010 年 2 月 27 日更新为使用叠加层而不是直接向当前文本添加文本属性.

Note: The code was updated 27/02/2010 to use overlays instead of directly adding text properties to the current text.

这篇关于Emacs :TODO 指示器在左侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆