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

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

问题描述

我想在源代码中的任何位置都有一些indiacator在行的左侧。

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.

请参阅 Fringes 显示属性覆盖,最重要的是 before-string 属性。

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

注意:代码已更新27/02/2010至使用重叠式广告代替直接向当前文本添加文本属性。

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天全站免登陆