* overlay-in sorting problem
@ 2007-05-11 9:15 Sebastian Meisel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Meisel @ 2007-05-11 9:15 UTC (permalink / raw)
To: Emacs Mailing List
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: overlay-in sorting problem
@ 2007-05-11 11:48 martin rudalics
0 siblings, 0 replies; 2+ messages in thread
From: martin rudalics @ 2007-05-11 11:48 UTC (permalink / raw)
To: sebastianmeisel; +Cc: help-gnu-emacs
Try `overlay-recenter' at the starting position.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-11 11:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-11 9:15 overlay-in sorting problem Sebastian Meisel
-- strict thread matches above, loose matches on Subject: below --
2007-05-11 11:48 martin rudalics
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.