help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

overlay-in sorting problem


From: Sebastian Meisel
Subject: overlay-in sorting problem
Date: Fri, 11 May 2007 11:15:04 +0200
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

Dear Emacs-users,

I try to write a function, that shows the numbers of the items in an latex enumerate environment. It works fine, but only if I call the function, when the point is in the first items region.

Otherwise the numbers count backward from the current item to the first one, and the forward from the current item. This seems the be cause by the way the overlay-list is create from overlay-in. Even when I move the point before
overlay-in is called, I get this effect. What can I do?

-->

(defvar LaTeX-enumerate-number 1 "Number for enumerate environement.")

(defun LaTeX-enumerate-overlays ()
 "Return number of items in overlay."
 (interactive)
 (save-excursion
   (when (re-search-backward "\\\\begin\{enumerate\}" nil t 1)
     (let ((start (match-end 0)))
   (when (re-search-forward "\\\\end\{enumerate\}" nil t 1)
     (let ((end (match-beginning 0)))
       (TeX-fold-region start end)
       (goto-char start)
       (let ((overlays (overlays-in start end)))
         (while overlays
       (let ((overlay (car overlays)))
(when (equal (overlay-get overlay 'TeX-fold-display-string-spec) "*") (let ((enum-number-string (format "[%s]" LaTeX-enumerate-number))) (overlay-put overlay 'TeX-fold-display-string-spec enum-number-string)
             (overlay-put overlay  'display enum-number-string)
             (setq LaTeX-enumerate-number (+ LaTeX-enumerate-number 1))))
         (setq overlays (cdr overlays)
           ))))))))
   (setq LaTeX-enumerate-number 1)))
<-----
called within:

\begin{enumerate}
\item test
\item test
\item test
\end{enumerate}

results in

\begin{enumerate}
[1] test <point was hier>
[2] test
[3] test
\end{enumerate}

or

\begin{enumerate}
[2] test
[1] test <point was hier>
[3] test
\end{enumerate}

or

\begin{enumerate}
[3] test
[2] test
[1] test <point was hier>
\end{enumerate}

where the first result is the expected.

Thank for any hints

Sebastian Meisel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]