Skip to main content
edited title
Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

write Put “save-excursion” OUTERMOST when usingOutermost When Using Both “save-excursion” &And “save-restriction” together

deleted 28 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

I'm reading Emacs Lisp Intro by Robert J. Chassell.

In 6.1 The ‘save-restriction’ Special Form

when you use both ‘save-excursion’ and ‘save-restriction’, one right after the other, you should use ‘save-excursion’ outermost. If you write them in reverse order, you may fail to record narrowing in the buffer to which Emacs switches after calling ‘save-excursion’.

And in 6.2 what-line

(Note that the ‘(widen)’ expression comes between the ‘save-restriction’ and ‘save-excursion’ special forms. When you write the two ‘save- ...’ expressions in sequence, write ‘save-excursion’ outermost.)

I'm really confused about why it should be written like this:

(save-excursion
  (save-restriction
    BODY...))

Any help is appreciated!

I'm reading Emacs Lisp Intro by Robert J. Chassell.

In 6.1 The ‘save-restriction’ Special Form

when you use both ‘save-excursion’ and ‘save-restriction’, one right after the other, you should use ‘save-excursion’ outermost. If you write them in reverse order, you may fail to record narrowing in the buffer to which Emacs switches after calling ‘save-excursion’.

And in 6.2 what-line

(Note that the ‘(widen)’ expression comes between the ‘save-restriction’ and ‘save-excursion’ special forms. When you write the two ‘save- ...’ expressions in sequence, write ‘save-excursion’ outermost.)

I'm really confused about why it should be written like this:

(save-excursion
  (save-restriction
    BODY...))

Any help is appreciated!

I'm reading Emacs Lisp Intro by Robert J. Chassell.

In 6.1 The ‘save-restriction’ Special Form

when you use both ‘save-excursion’ and ‘save-restriction’, one right after the other, you should use ‘save-excursion’ outermost. If you write them in reverse order, you may fail to record narrowing in the buffer to which Emacs switches after calling ‘save-excursion’.

And in 6.2 what-line

(Note that the ‘(widen)’ expression comes between the ‘save-restriction’ and ‘save-excursion’ special forms. When you write the two ‘save- ...’ expressions in sequence, write ‘save-excursion’ outermost.)

I'm really confused about why it should be written like this:

(save-excursion
  (save-restriction
    BODY...))

Why write `save“save-excursion'excursion” OUTERMOST when using `save“save-excursion' and `saveexcursion” & “save-restriction'restriction” together?

added 5 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading
edited title
Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading
edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Loading
edited tags
Link
NickD
  • 33.6k
  • 3
  • 30
  • 47
Loading
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading