Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

lisp - Emacs :TODO indicator at left side

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...