Emacs:在评论中突出显示TODO * * * [英] Emacs: highlighting TODO *only* in comments

查看:144
本文介绍了Emacs:在评论中突出显示TODO * * *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与另一个相关, Emacs:左侧的TODO指示器。我最近遇到了一个很小的模式,我很喜欢 FixmeMode 。它支持自动突出显示 TODO 标记,并在它们之间导航。然而,我认为只有在评论中识别TODO字符串是更有意义的,而不是污染整个文件。可以吗?

This question is related to another one, Emacs :TODO indicator at left side. I recently came across a minor mode I like a lot called FixmeMode. It supports auto highlighting of TODO marks, and navigating between them. However, I think it makes more sense to recognize the "TODO" strings only in comments, rather than polluting the whole file. Is it possible?

推荐答案

查看图书馆 fic-mode.el ,它已经在C ++和Emacs-Lisp中被验证。

Check out the library fic-mode.el, it has been verified in C++ and Emacs-Lisp.

它是专门用于回答这个问题的。

It was written specifically to answer this question.

安装就像任何标准包:

(require 'fic-mode)
(add-hook 'c++-mode-hook 'turn-on-fic-mode) 

尽管魏虎确实要求一个简单的方式将其添加到多种模式,所以这里:

Though Wei Hu did ask for an easy way to add it to multiple modes, so here goes:

(defun add-something-to-mode-hooks (mode-list something)
  "helper function to add a callback to multiple hooks"
  (dolist (mode mode-list)
    (add-hook (intern (concat (symbol-name mode) "-mode-hook")) something)))

(add-something-to-mode-hooks '(c++ tcl emacs-lisp) 'turn-on-fic-mode)

这篇关于Emacs:在评论中突出显示TODO * * *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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