tags:

views:

126

answers:

1

I just read Emacs :TODO indicator at left side, and tried it out. It seems intriguing. The little indicator triangles appear, but I'm getting a weird side effect: the text itself is being altered. Characters are being deleted.

Before:

alt text

After:

alt text

The mode-line does indicate that the buffer has been altered after running annotate-todo. What explains this?

(I'm using emacs 22.2.1 on Windows)

+3  A: 

Ahhh... I see the error of my ways earlier. Here's a new version.

(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 (format "A")
                                                        'display '(left-fringe right-triangle)))))))

The first solution used a the 'display text property, which changes how the specified text is displayed, in this case it was replaced by the triangle in the left fringe. What I needed to do was to use a 'before-string overlay instead. Which doesn't change the string being displayed.

Another advantage, the cut/paste of the code annotated by this does not carry the markup.

I've updated the code in the original question to reflect this change as well.

Trey Jackson
this works perfectly! Thanks Trey
Cheeso