diff options
| author | Miles Bader | 2000-10-03 01:56:15 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-10-03 01:56:15 +0000 |
| commit | a6d81c937bd2a0f2ebdfeeed413764b106338c02 (patch) | |
| tree | dc8c2261296d974cf1bb3c7aba65feb1eba7d4c6 | |
| parent | 96f71a4964c3963a36be0fef120590b985ec7267 (diff) | |
| download | emacs-a6d81c937bd2a0f2ebdfeeed413764b106338c02.tar.gz emacs-a6d81c937bd2a0f2ebdfeeed413764b106338c02.zip | |
(Narrowing): Get rid of warning about now-fixed save-restriction bug.
| -rw-r--r-- | lispref/positions.texi | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/lispref/positions.texi b/lispref/positions.texi index 7ae412ffe5a..378134e30c2 100644 --- a/lispref/positions.texi +++ b/lispref/positions.texi | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | @c -*-texinfo-*- | 1 | @c -*-texinfo-*- |
| 2 | @c This is part of the GNU Emacs Lisp Reference Manual. | 2 | @c This is part of the GNU Emacs Lisp Reference Manual. |
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000 |
| 4 | @c Free Software Foundation, Inc. | 4 | @c Free Software Foundation, Inc. |
| 5 | @c See the file elisp.texi for copying conditions. | 5 | @c See the file elisp.texi for copying conditions. |
| 6 | @setfilename ../info/positions | 6 | @setfilename ../info/positions |
| @@ -911,29 +911,6 @@ restored with temporary narrowing still in effect. If the old point | |||
| 911 | value were outside the limits of the temporary narrowing, this would | 911 | value were outside the limits of the temporary narrowing, this would |
| 912 | fail to restore it accurately. | 912 | fail to restore it accurately. |
| 913 | 913 | ||
| 914 | The @code{save-restriction} special form records the values of the | ||
| 915 | beginning and end of the accessible portion as distances from the | ||
| 916 | beginning and end of the buffer. In other words, it records the amount | ||
| 917 | of inaccessible text before and after the accessible portion. | ||
| 918 | |||
| 919 | This method yields correct results if @var{body} does further narrowing. | ||
| 920 | However, @code{save-restriction} can become confused if the body widens | ||
| 921 | and then makes changes outside the range of the saved narrowing. When | ||
| 922 | this is what you want to do, @code{save-restriction} is not the right | ||
| 923 | tool for the job. Here is what you must use instead: | ||
| 924 | |||
| 925 | @example | ||
| 926 | @group | ||
| 927 | (let ((beg (point-min-marker)) | ||
| 928 | (end (point-max-marker))) | ||
| 929 | (unwind-protect | ||
| 930 | (progn @var{body}) | ||
| 931 | (save-excursion | ||
| 932 | (set-buffer (marker-buffer beg)) | ||
| 933 | (narrow-to-region beg end)))) | ||
| 934 | @end group | ||
| 935 | @end example | ||
| 936 | |||
| 937 | Here is a simple example of correct use of @code{save-restriction}: | 914 | Here is a simple example of correct use of @code{save-restriction}: |
| 938 | 915 | ||
| 939 | @example | 916 | @example |