Emacs:左侧的 TODO 指示器

发布于 2024-08-21 06:01:41 字数 156 浏览 8 评论 0原文

我希望在源代码中的任何位置都在该行的左侧有某种指示器

#TODO: some comment

//TODO: some comments

该指示器可以是一个公正的标记,并且我已经启用了该行emacs 中显示的数字。

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

#TODO: some comment

//TODO: some comments

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瀞厅☆埖开 2024-08-28 06:01:41

该命令将执行您想要的操作。

(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

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

或者,如果您只想将其用于某些模式,则可以将其添加到这些模式挂钩中。

请参阅边缘'display' 属性叠加层,最重要的是 before-string 属性。

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

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)))))))

You can customize the bitmap as desired.

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.

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

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

三寸金莲 2024-08-28 06:01:41

I like the approach described in this post on emacs-fu, which adds TODO/FIXME/... to the font-lock settings of the modes where you need it. In contrast to Trey's approach this should highlight the words as you type, whereas his approach should only highlight them when you open a file (or do I get this wrong).

Anyway its up to you. A good google search gives you probably even more ideas: http://www.google.com/search?q=emacs+highlight+todo

Update: Your question has already been answered: Emacs, highlight all occurences of a word

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文