Is it possible to have a text string as a text property in emacs? Let me explain. I usually work with latex documents and I need to format their bibliographies that have, e.g., this structure:
\begin{thebibliography}{9}
\bibitem{bib1}
Some text...
\bibitem{bib2}
Some text...
\bibitem{bib3}
Some text...
...
I'd like to have in my buffer:
\begin{thebibliography}{9}
\bibitem{bib1} [1]
Some text...
\bibitem{bib2} [2]
Some text...
\bibitem{bib3} [3]
Some text...
...
where [1], [2], [3] are not meant to be "real text" but "properties" of the corresponding strings. (A sort of "watermark"...) Actually those strings should not be send to the latex compiler...
I know I can use commented text (and so I do in my daily work) but it would be better for my needs if I could get that behaviour.
EDIT. Ok, Drew showed me the way... I did it with:
(defun BibitemNumbering ()
(interactive)
(save-excursion
(let ((counter 0))
(while (search-forward-regexp "\\\\bibitem{[^}]+}\\(\n\\)" nil t)
(save-excursion
(let ((b (make-marker))
(e (make-marker)))
(setq counter (1+ counter))
(set-marker b (match-beginning 1))
(set-marker e (point))
(put-text-property b e 'display (concat " ["
(number-to-string counter)
"]\n"))
)))
)))
Is this the right way? Also, I'd like to have the displayed string "coloured" or with a coloured background. How can I set this?