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

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

问题描述

这个问题与另一个问题有关,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.

安装就像任何标准包一样:

The installation is like any standard package:

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

虽然 Wei Hu 确实要求一种简单的方法将其添加到多种模式,所以这里是:

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 *only*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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