Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...