all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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; 6+ 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] 6+ messages in thread

* Re: emacs documentation for (La)TeX
       [not found] <E1AZe1u-00038Z-U8@monty-python.gnu.org>
@ 2003-12-25 22:23 ` Joe Corneli
  2003-12-25 22:30 ` need double save-excursion -- why? Joe Corneli
       [not found] ` <mailman.628.1072394739.868.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Joe Corneli @ 2003-12-25 22:23 UTC (permalink / raw)
  Cc: help-gnu-emacs

> Hm.  I just tried C-h C-i and the message buffer tells me:
> 
>     Loading info-look...done
>     Processing Info node `(emacs)Command Index'...
>     Cannot access Info node `(emacs)Command Index'
>     Processing Info node `(emacs)Command Index'...done
>     Processing Info node `(emacs)Variable Index'...
>     Cannot access Info node `(emacs)Variable Index'
>     Processing Info node `(emacs)Variable Index'...done
>     Processing Info node `(elisp)Index'...
>     Cannot access Info node `(elisp)Index'
>     Processing Info node `(elisp)Index'...done
> 
> "Cannot access Info node" -- bad.  I guess it's just a
> misconfiguration on my part, though.

I had the same problem.  However, info-lookup-symbol worked fine in
latex mode.  I haven't looked further into the problem with emacs
info lookup.

The main difference between info lookup and describe-function is that
the latter (typically) has links to the source, whereas the former
doesn't.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: need double save-excursion -- why?
       [not found] <E1AZe1u-00038Z-U8@monty-python.gnu.org>
  2003-12-25 22:23 ` emacs documentation for (La)TeX Joe Corneli
@ 2003-12-25 22:30 ` Joe Corneli
       [not found] ` <mailman.628.1072394739.868.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Joe Corneli @ 2003-12-25 22:30 UTC (permalink / raw)
  Cc: help-gnu-emacs

Actually, I take back what I said about needing a double
save-excursion.  The outer save-excursion doesn't seem to help after
all. What might have helped was running the function through
edebug. (Not that I figured out what the problem was, but rather it
somehow seems to fix the problem temporarily to have the edebugger
running.)  Totally confused now...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs documentation for (La)TeX
       [not found] ` <mailman.628.1072394739.868.help-gnu-emacs@gnu.org>
@ 2003-12-25 22:34   ` Kai Grossjohann
  2003-12-26  3:10     ` Brad Collins
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Grossjohann @ 2003-12-25 22:34 UTC (permalink / raw)


Joe Corneli <jcorneli@math.utexas.edu> writes:

> The main difference between info lookup and describe-function is that
> the latter (typically) has links to the source, whereas the former
> doesn't.

Ah, links to the source.  That is useful indeed.

Kai

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs documentation for (La)TeX
  2003-12-25 22:34   ` emacs documentation for (La)TeX Kai Grossjohann
@ 2003-12-26  3:10     ` Brad Collins
  0 siblings, 0 replies; 6+ messages in thread
From: Brad Collins @ 2003-12-26  3:10 UTC (permalink / raw)


Kai Grossjohann <kai@emptydomain.de> writes:

> Joe Corneli <jcorneli@math.utexas.edu> writes:
>
>> The main difference between info lookup and describe-function is that
>> the latter (typically) has links to the source, whereas the former
>> doesn't.
>
> Ah, links to the source.  That is useful indeed.

Well it links to the *documentation* in the source, not the whole source
itself.

The wonderful thing is that C-h f/m/c are internal documentation--it's
in context with what you are doing or looking at in a way that an
external manual--even the very good info manuals, can not do.

This is why Emacs is called a self-documenting editor--because it not
not only lets you peek under the hood to see what's going on, it tells
you exactly what's going on why you do it.

Try 'C-h k h" 

,----[ C-h k h ]
| h runs the command self-insert-command
| (self-insert-command N)
|    which is an interactive built-in function.
| 
| Insert the character you type.
| Whichever character you type to run this command is inserted.
`----

This really blew me away when I first saw it.  Typing the 'h' key runs
the command self-insert-character which inserts the character into the
buffer. 

The question that I think many people would ask is, why would
I need or even want to know this?

This is what sets Emacs apart from everything else in the world of
software--it changes the relationship that the user has with the
software and encourages you to understand and tinker with everything.

Emacs forces you to drop your illusions about text and to understand
that practically everything in computing is just plain text when you
boil away the fat and fur.

This explains the obsession that people who have drunk the Emacs
Cool-Aid have with trying to do everything in Emacs.  After you
understand that, say email, is just plain text, you want to start
using the power of Emacs to edit and work with. 

So if Emacs is an editor, for editing text, you can also think of
Emacs itself as a collection of text files (written in elisp) which
can in turn be edited by Emacs.  The purpose of Emacs then, (at least
one reason) is to edit Emacs....

b/

--
Brad Collins
Chenla Labs
Bangkok, Thailand

^ permalink raw reply	[flat|nested] 6+ messages in thread

* 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; 6+ 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] 6+ messages in thread

end of thread, other threads:[~2003-12-28 12:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1AZe1u-00038Z-U8@monty-python.gnu.org>
2003-12-25 22:23 ` emacs documentation for (La)TeX Joe Corneli
2003-12-25 22:30 ` need double save-excursion -- why? Joe Corneli
     [not found] ` <mailman.628.1072394739.868.help-gnu-emacs@gnu.org>
2003-12-25 22:34   ` emacs documentation for (La)TeX Kai Grossjohann
2003-12-26  3:10     ` Brad Collins
     [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

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.