5

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)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • They weren't actually deleted, just displayed differently. Which is nearly as icky. I can't believe I didn't notice that side effect when I first made the solution. I believe the new one works as you would expect. – Trey Jackson Feb 27 '10 at 21:02

1 Answers1

6

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
  • 73,529
  • 11
  • 197
  • 229