* need double save-excursion -- why?
[not found] <E1AZNDK-0005CI-5D@monty-python.gnu.org>
@ 2003-12-25 21:30 ` Joe Corneli
[not found] ` <mailman.627.1072391527.868.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Joe Corneli @ 2003-12-25 21:30 UTC (permalink / raw)
When I run the function below on a file containing things like this:
####################################################################
\section{{ lefschetz}}
(lefschetz number of a map) \defn{
\item $X$ smooth compact manifold
\item $g:X\rightarrow X$ continuous
\item $G: X\rightarrow X\times X$
\item $G(x)=(x,g(x))$
\item $\#(G,\text{diagonal}(M\times M))$}
(global lefschetz number of a map: see ``lefschetz number of a map'')
(global lefschetz number: fact: smooth lefschetz fixed point theorem) \defn{
\item $X$ compact orientable manifold
\item $f:X\rightarrow X$ smooth
\item $L(f)\neq 0$
\item $f$ has a fixed point}
(lefschetz fixed point) \defn{
\item $f:X\rightarrow X$
\item $f(x)=x$
\item $+1$ is not an eigenvalue of $df_x:T_x(X)\rightarrow T_x(X)$}
####################################################################
I don't get good results: the outermost save-excursion is ignored,
and the cursor winds up near the bottom of the document.
However, if I wrap another save-excursion around the currently
outermost one, the second one is heeded and point is restored
properly.
Can anyone tell me this is necessary? Something like this is
documented in the Emacs Lisp Intro info file, but I don't understand
why a double layer of save-excursions is needed here.
(defun xi-grab-matching-defn-by-tagline (regexp)
"Grab the defns whose taglines contain a match for this regexp."
(interactive "MRegex: ")
(save-excursion
(beginning-of-buffer) ;; start at the beginning
(while (not (eobp))
(let ((found (search-forward-regexp (concat "^(.*" regexp ".*)") nil t)))
(if found
(let* ((beg (save-excursion (beginning-of-line)
(point)))
(end (save-excursion (end-of-line)
(search-forward-regexp "^$" nil t)
(beginning-of-line)
(point))) ; cut right before that
(entry (buffer-substring beg end)))
(save-excursion (set-buffer (get-buffer-create "CONCAT.tex"))
(insert entry)))
(end-of-buffer))))))
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <mailman.627.1072391527.868.help-gnu-emacs@gnu.org>]
* Re: need double save-excursion -- why?
[not found] ` <mailman.627.1072391527.868.help-gnu-emacs@gnu.org>
@ 2003-12-28 12:41 ` Jesper Harder
0 siblings, 0 replies; 3+ messages in thread
From: Jesper Harder @ 2003-12-28 12:41 UTC (permalink / raw)
Joe Corneli <jcorneli@math.utexas.edu> writes:
> I don't get good results: the outermost save-excursion is ignored,
> and the cursor winds up near the bottom of the document.
You problem could be:
> (beginning-of-buffer) ;; start at the beginning
,----[ C-h f beginning-of-buffer RET ]
| Don't use this command in Lisp programs!
| (goto-char (point-min)) is faster and avoids clobbering the mark.
`----
> (end-of-buffer))))))
,----[ C-h f end-of-buffer RET ]
| Don't use this command in Lisp programs!
| (goto-char (point-max)) is faster and avoids clobbering the mark.
`----
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <E1AZe1u-00038Z-U8@monty-python.gnu.org>]
end of thread, other threads:[~2003-12-28 12:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1AZNDK-0005CI-5D@monty-python.gnu.org>
2003-12-25 21:30 ` need double save-excursion -- why? Joe Corneli
[not found] ` <mailman.627.1072391527.868.help-gnu-emacs@gnu.org>
2003-12-28 12:41 ` Jesper Harder
[not found] <E1AZe1u-00038Z-U8@monty-python.gnu.org>
2003-12-25 22:30 ` Joe Corneli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).