diff options
| author | Chong Yidong | 2011-04-08 14:53:26 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-04-08 14:53:26 -0400 |
| commit | 6b8bc570715801cb194dc4273370eab87628e8bf (patch) | |
| tree | 01e4531fd38069dffbfb0150a2a596ddd8de2bd2 | |
| parent | 3726838a9cca22d420036cd2462398f54318f5d5 (diff) | |
| parent | 0080dc6bd919f83c036bb6072800032b1723b248 (diff) | |
| download | emacs-6b8bc570715801cb194dc4273370eab87628e8bf.tar.gz emacs-6b8bc570715801cb194dc4273370eab87628e8bf.zip | |
Merge changes from emacs-23 branch
| -rw-r--r-- | doc/emacs/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/emacs/display.texi | 16 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 15 | ||||
| -rw-r--r-- | doc/lispref/buffers.texi | 159 | ||||
| -rw-r--r-- | doc/lispref/minibuf.texi | 34 | ||||
| -rw-r--r-- | doc/lispref/positions.texi | 99 | ||||
| -rw-r--r-- | etc/NEWS.23 | 7 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc/vc-annotate.el | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/process.c | 6 | ||||
| -rw-r--r-- | src/term.c | 3 |
12 files changed, 201 insertions, 157 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index b25e6ce219f..47aa395c730 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-03-26 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * display.texi (Auto Scrolling): Fix scroll-up/scroll-down confusion. | ||
| 4 | |||
| 1 | 2011-03-30 Eli Zaretskii <eliz@gnu.org> | 5 | 2011-03-30 Eli Zaretskii <eliz@gnu.org> |
| 2 | 6 | ||
| 3 | * display.texi (Auto Scrolling): Document the limit of 100 lines | 7 | * display.texi (Auto Scrolling): Document the limit of 100 lines |
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 405ee26312f..7777aacf0e5 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi | |||
| @@ -206,16 +206,18 @@ how aggressively it scrolls by setting the variables | |||
| 206 | @code{scroll-up-aggressively} and @code{scroll-down-aggressively}. | 206 | @code{scroll-up-aggressively} and @code{scroll-down-aggressively}. |
| 207 | The value of @code{scroll-up-aggressively} should be either | 207 | The value of @code{scroll-up-aggressively} should be either |
| 208 | @code{nil}, or a fraction @var{f} between 0 and 1. A fraction | 208 | @code{nil}, or a fraction @var{f} between 0 and 1. A fraction |
| 209 | specifies where on the screen to put point when scrolling upward: when | 209 | specifies where on the screen to put point when scrolling upward, |
| 210 | a window scrolls up because point is above the window start, the new | 210 | i.e.@: when point moves forward in the buffer, and therefore text |
| 211 | scrolls up in the window. When point goes off the window end, the new | ||
| 211 | start position is chosen to put point @var{f} parts of the window | 212 | start position is chosen to put point @var{f} parts of the window |
| 212 | height from the top. Thus, larger @var{f} means more aggressive | 213 | height from the bottom. Thus, larger @var{f} means more aggressive |
| 213 | scrolling. The default value, @code{nil}, is equivalent to 0.5. | 214 | scrolling: more new text is brought into view. The default value, |
| 215 | @code{nil}, is equivalent to 0.5. | ||
| 214 | 216 | ||
| 215 | Likewise, @code{scroll-down-aggressively} is used for scrolling | 217 | Likewise, @code{scroll-down-aggressively} is used for scrolling |
| 216 | down. The value specifies how far point should be placed from the | 218 | down, i.e.@: moving point back in the buffer. The value specifies how |
| 217 | bottom of the window; thus, as with @code{scroll-up-aggressively}, a | 219 | far point should be placed from the top of the window; thus, as with |
| 218 | larger value is more aggressive. | 220 | @code{scroll-up-aggressively}, a larger value is more aggressive. |
| 219 | 221 | ||
| 220 | These two variables are ignored if either @code{scroll-step} or | 222 | These two variables are ignored if either @code{scroll-step} or |
| 221 | @code{scroll-conservatively} are set to a non-zero value. | 223 | @code{scroll-conservatively} are set to a non-zero value. |
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 445e94a0c43..784f62dc4cc 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2011-03-21 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * minibuf.texi (Basic Completion): Be a bit more precise about the | ||
| 4 | valid kinds of completion tables. | ||
| 5 | (Programmed Completion): Remove obsolete text about lambda expressions | ||
| 6 | not being valid completion tables. | ||
| 7 | |||
| 8 | 2011-03-19 Chong Yidong <cyd@stupidchicken.com> | ||
| 9 | |||
| 10 | * positions.texi (Excursions): Explain the "save-excursion | ||
| 11 | defeated by set-buffer" warning. | ||
| 12 | |||
| 13 | * buffers.texi (Current Buffer): Copyedits. Don't recommend using | ||
| 14 | save-excursion. Suggested by Uday S Reddy. | ||
| 15 | |||
| 1 | 2011-04-01 Stefan Monnier <monnier@iro.umontreal.ca> | 16 | 2011-04-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 17 | ||
| 3 | * variables.texi (Defining Variables): Mention the new meaning of `defvar'. | 18 | * variables.texi (Defining Variables): Mention the new meaning of `defvar'. |
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi index 07889cdbaa3..0f9de74c948 100644 --- a/doc/lispref/buffers.texi +++ b/doc/lispref/buffers.texi | |||
| @@ -85,43 +85,63 @@ This function returns @code{t} if @var{object} is a buffer, | |||
| 85 | @cindex changing to another buffer | 85 | @cindex changing to another buffer |
| 86 | @cindex current buffer | 86 | @cindex current buffer |
| 87 | 87 | ||
| 88 | There are, in general, many buffers in an Emacs session. At any time, | 88 | There are, in general, many buffers in an Emacs session. At any |
| 89 | one of them is designated as the @dfn{current buffer}. This is the | 89 | time, one of them is designated the @dfn{current buffer}---the buffer |
| 90 | buffer in which most editing takes place, because most of the primitives | 90 | in which most editing takes place. Most of the primitives for |
| 91 | for examining or changing text in a buffer operate implicitly on the | 91 | examining or changing text operate implicitly on the current buffer |
| 92 | current buffer (@pxref{Text}). Normally the buffer that is displayed on | 92 | (@pxref{Text}). |
| 93 | the screen in the selected window is the current buffer, but this is not | 93 | |
| 94 | always so: a Lisp program can temporarily designate any buffer as | 94 | Normally, the buffer displayed in the selected window is the current |
| 95 | current in order to operate on its contents, without changing what is | 95 | buffer, but this is not always so: a Lisp program can temporarily |
| 96 | displayed on the screen. | 96 | designate any buffer as current in order to operate on its contents, |
| 97 | 97 | without changing what is displayed on the screen. The most basic | |
| 98 | The way to designate a current buffer in a Lisp program is by calling | 98 | function for designating a current buffer is @code{set-buffer}. |
| 99 | @code{set-buffer}. The specified buffer remains current until a new one | 99 | |
| 100 | is designated. | 100 | @defun current-buffer |
| 101 | 101 | This function returns the current buffer. | |
| 102 | When an editing command returns to the editor command loop, the | 102 | |
| 103 | command loop designates the buffer displayed in the selected window as | 103 | @example |
| 104 | current, to prevent confusion: the buffer that the cursor is in when | 104 | @group |
| 105 | Emacs reads a command is the buffer that the command will apply to. | 105 | (current-buffer) |
| 106 | (@xref{Command Loop}.) Therefore, @code{set-buffer} is not the way to | 106 | @result{} #<buffer buffers.texi> |
| 107 | switch visibly to a different buffer so that the user can edit it. For | 107 | @end group |
| 108 | that, you must use the functions described in @ref{Displaying Buffers}. | 108 | @end example |
| 109 | 109 | @end defun | |
| 110 | @strong{Warning:} Lisp functions that change to a different current buffer | 110 | |
| 111 | should not depend on the command loop to set it back afterwards. | 111 | @defun set-buffer buffer-or-name |
| 112 | Editing commands written in Emacs Lisp can be called from other programs | 112 | This function makes @var{buffer-or-name} the current buffer. |
| 113 | as well as from the command loop; it is convenient for the caller if | 113 | @var{buffer-or-name} must be an existing buffer or the name of an |
| 114 | the subroutine does not change which buffer is current (unless, of | 114 | existing buffer. The return value is the buffer made current. |
| 115 | course, that is the subroutine's purpose). Therefore, you should | 115 | |
| 116 | normally use @code{set-buffer} within a @code{save-current-buffer} or | 116 | This function does not display the buffer in any window, so the user |
| 117 | @code{save-excursion} (@pxref{Excursions}) form that will restore the | 117 | cannot necessarily see the buffer. But Lisp programs will now operate |
| 118 | current buffer when your function is done. Here, as an example, is a | 118 | on it. |
| 119 | @end defun | ||
| 120 | |||
| 121 | When an editing command returns to the editor command loop, Emacs | ||
| 122 | automatically calls @code{set-buffer} on the buffer shown in the | ||
| 123 | selected window. This is to prevent confusion: it ensures that the | ||
| 124 | buffer that the cursor is in, when Emacs reads a command, is the | ||
| 125 | buffer to which that command applies (@pxref{Command Loop}). Thus, | ||
| 126 | you should not use @code{set-buffer} to switch visibly to a different | ||
| 127 | buffer; for that, use the functions described in @ref{Displaying | ||
| 128 | Buffers}. | ||
| 129 | |||
| 130 | When writing a Lisp function, do @emph{not} rely on this behavior of | ||
| 131 | the command loop to restore the current buffer after an operation. | ||
| 132 | Editing commands can also be called as Lisp functions by other | ||
| 133 | programs, not just from the command loop; it is convenient for the | ||
| 134 | caller if the subroutine does not change which buffer is current | ||
| 135 | (unless, of course, that is the subroutine's purpose). | ||
| 136 | |||
| 137 | To operate temporarily on another buffer, put the @code{set-buffer} | ||
| 138 | within a @code{save-current-buffer} form. Here, as an example, is a | ||
| 119 | simplified version of the command @code{append-to-buffer}: | 139 | simplified version of the command @code{append-to-buffer}: |
| 120 | 140 | ||
| 121 | @example | 141 | @example |
| 122 | @group | 142 | @group |
| 123 | (defun append-to-buffer (buffer start end) | 143 | (defun append-to-buffer (buffer start end) |
| 124 | "Append to specified buffer the text of the region." | 144 | "Append the text of the region to BUFFER." |
| 125 | (interactive "BAppend to buffer: \nr") | 145 | (interactive "BAppend to buffer: \nr") |
| 126 | (let ((oldbuf (current-buffer))) | 146 | (let ((oldbuf (current-buffer))) |
| 127 | (save-current-buffer | 147 | (save-current-buffer |
| @@ -131,27 +151,36 @@ simplified version of the command @code{append-to-buffer}: | |||
| 131 | @end example | 151 | @end example |
| 132 | 152 | ||
| 133 | @noindent | 153 | @noindent |
| 134 | This function binds a local variable to record the current buffer, and | 154 | Here, we bind a local variable to record the current buffer, and then |
| 135 | then @code{save-current-buffer} arranges to make it current again. | 155 | @code{save-current-buffer} arranges to make it current again later. |
| 136 | Next, @code{set-buffer} makes the specified buffer current. Finally, | 156 | Next, @code{set-buffer} makes the specified buffer current, and |
| 137 | @code{insert-buffer-substring} copies the string from the original | 157 | @code{insert-buffer-substring} copies the string from the original |
| 138 | current buffer to the specified (and now current) buffer. | 158 | buffer to the specified (and now current) buffer. |
| 139 | 159 | ||
| 140 | If the buffer appended to happens to be displayed in some window, | 160 | Alternatively, we can use the @code{with-current-buffer} macro: |
| 141 | the next redisplay will show how its text has changed. Otherwise, you | 161 | |
| 142 | will not see the change immediately on the screen. The buffer becomes | 162 | @example |
| 143 | current temporarily during the execution of the command, but this does | 163 | @group |
| 144 | not cause it to be displayed. | 164 | (defun append-to-buffer (buffer start end) |
| 145 | 165 | "Append the text of the region to BUFFER." | |
| 146 | If you make local bindings (with @code{let} or function arguments) for | 166 | (interactive "BAppend to buffer: \nr") |
| 147 | a variable that may also have buffer-local bindings, make sure that the | 167 | (let ((oldbuf (current-buffer))) |
| 148 | same buffer is current at the beginning and at the end of the local | 168 | (with-current-buffer (get-buffer-create buffer) |
| 149 | binding's scope. Otherwise you might bind it in one buffer and unbind | 169 | (insert-buffer-substring oldbuf start end)))) |
| 150 | it in another! There are two ways to do this. In simple cases, you may | 170 | @end group |
| 151 | see that nothing ever changes the current buffer within the scope of the | 171 | @end example |
| 152 | binding. Otherwise, use @code{save-current-buffer} or | 172 | |
| 153 | @code{save-excursion} to make sure that the buffer current at the | 173 | In either case, if the buffer appended to happens to be displayed in |
| 154 | beginning is current again whenever the variable is unbound. | 174 | some window, the next redisplay will show how its text has changed. |
| 175 | If it is not displayed in any window, you will not see the change | ||
| 176 | immediately on the screen. The command causes the buffer to become | ||
| 177 | current temporarily, but does not cause it to be displayed. | ||
| 178 | |||
| 179 | If you make local bindings (with @code{let} or function arguments) | ||
| 180 | for a variable that may also have buffer-local bindings, make sure | ||
| 181 | that the same buffer is current at the beginning and at the end of the | ||
| 182 | local binding's scope. Otherwise you might bind it in one buffer and | ||
| 183 | unbind it in another! | ||
| 155 | 184 | ||
| 156 | Do not rely on using @code{set-buffer} to change the current buffer | 185 | Do not rely on using @code{set-buffer} to change the current buffer |
| 157 | back, because that won't do the job if a quit happens while the wrong | 186 | back, because that won't do the job if a quit happens while the wrong |
| @@ -168,29 +197,9 @@ have been wrong to do this: | |||
| 168 | @end example | 197 | @end example |
| 169 | 198 | ||
| 170 | @noindent | 199 | @noindent |
| 171 | Using @code{save-current-buffer}, as we did, handles quitting, errors, | 200 | Using @code{save-current-buffer} or @code{with-current-buffer}, as we |
| 172 | and @code{throw}, as well as ordinary evaluation. | 201 | did, correctly handles quitting, errors, and @code{throw}, as well as |
| 173 | 202 | ordinary evaluation. | |
| 174 | @defun current-buffer | ||
| 175 | This function returns the current buffer. | ||
| 176 | |||
| 177 | @example | ||
| 178 | @group | ||
| 179 | (current-buffer) | ||
| 180 | @result{} #<buffer buffers.texi> | ||
| 181 | @end group | ||
| 182 | @end example | ||
| 183 | @end defun | ||
| 184 | |||
| 185 | @defun set-buffer buffer-or-name | ||
| 186 | This function makes @var{buffer-or-name} the current buffer. | ||
| 187 | @var{buffer-or-name} must be an existing buffer or the name of an | ||
| 188 | existing buffer. The return value is the buffer made current. | ||
| 189 | |||
| 190 | This function does not display the buffer in any window, so the user | ||
| 191 | cannot necessarily see the buffer. But Lisp programs will now operate | ||
| 192 | on it. | ||
| 193 | @end defun | ||
| 194 | 203 | ||
| 195 | @defspec save-current-buffer body@dots{} | 204 | @defspec save-current-buffer body@dots{} |
| 196 | The @code{save-current-buffer} special form saves the identity of the | 205 | The @code{save-current-buffer} special form saves the identity of the |
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 07975e64b35..acc68b0aafa 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -645,9 +645,9 @@ higher-level completion features that do use the minibuffer. | |||
| 645 | @defun try-completion string collection &optional predicate | 645 | @defun try-completion string collection &optional predicate |
| 646 | This function returns the longest common substring of all possible | 646 | This function returns the longest common substring of all possible |
| 647 | completions of @var{string} in @var{collection}. The value of | 647 | completions of @var{string} in @var{collection}. The value of |
| 648 | @var{collection} must be a list of strings or symbols, an alist, an | 648 | @var{collection} must be a list of strings, an alist whose keys are |
| 649 | obarray, a hash table, or a completion function (@pxref{Programmed | 649 | strings or symbols, an obarray, a hash table, or a completion function |
| 650 | Completion}). | 650 | (@pxref{Programmed Completion}). |
| 651 | 651 | ||
| 652 | Completion compares @var{string} against each of the permissible | 652 | Completion compares @var{string} against each of the permissible |
| 653 | completions specified by @var{collection}. If no permissible | 653 | completions specified by @var{collection}. If no permissible |
| @@ -658,11 +658,11 @@ to all possible matching completions. | |||
| 658 | 658 | ||
| 659 | If @var{collection} is an alist (@pxref{Association Lists}), the | 659 | If @var{collection} is an alist (@pxref{Association Lists}), the |
| 660 | permissible completions are the elements of the alist that are either | 660 | permissible completions are the elements of the alist that are either |
| 661 | strings, symbols, or conses whose @sc{car} is a string or symbol. | 661 | strings, or conses whose @sc{car} is a string or symbol. |
| 662 | Symbols are converted to strings using @code{symbol-name}. Other | 662 | Symbols are converted to strings using @code{symbol-name}. Other |
| 663 | elements of the alist are ignored. (Remember that in Emacs Lisp, the | 663 | elements of the alist are ignored. (Remember that in Emacs Lisp, the |
| 664 | elements of alists do not @emph{have} to be conses.) In particular, a | 664 | elements of alists do not @emph{have} to be conses.) In particular, a |
| 665 | list of strings or symbols is allowed, even though we usually do not | 665 | list of strings is allowed, even though we usually do not |
| 666 | think of such lists as alists. | 666 | think of such lists as alists. |
| 667 | 667 | ||
| 668 | @cindex obarray in completion | 668 | @cindex obarray in completion |
| @@ -678,7 +678,7 @@ Also, you cannot intern a given symbol in more than one obarray. | |||
| 678 | If @var{collection} is a hash table, then the keys that are strings | 678 | If @var{collection} is a hash table, then the keys that are strings |
| 679 | are the possible completions. Other keys are ignored. | 679 | are the possible completions. Other keys are ignored. |
| 680 | 680 | ||
| 681 | You can also use a symbol that is a function as @var{collection}. | 681 | You can also use a function as @var{collection}. |
| 682 | Then the function is solely responsible for performing completion; | 682 | Then the function is solely responsible for performing completion; |
| 683 | @code{try-completion} returns whatever this function returns. The | 683 | @code{try-completion} returns whatever this function returns. The |
| 684 | function is called with three arguments: @var{string}, @var{predicate} | 684 | function is called with three arguments: @var{string}, @var{predicate} |
| @@ -1632,12 +1632,12 @@ which performs completion according to the rules used in Emacs 21; and | |||
| 1632 | @subsection Programmed Completion | 1632 | @subsection Programmed Completion |
| 1633 | @cindex programmed completion | 1633 | @cindex programmed completion |
| 1634 | 1634 | ||
| 1635 | Sometimes it is not possible to create an alist or an obarray | 1635 | Sometimes it is not possible or convenient to create an alist or |
| 1636 | containing all the intended possible completions. In such a case, you | 1636 | an obarray containing all the intended possible completions ahead |
| 1637 | can supply your own function to compute the completion of a given | 1637 | of time. In such a case, you can supply your own function to compute |
| 1638 | string. This is called @dfn{programmed completion}. Emacs uses | 1638 | the completion of a given string. This is called @dfn{programmed |
| 1639 | programmed completion when completing file names (@pxref{File Name | 1639 | completion}. Emacs uses programmed completion when completing file |
| 1640 | Completion}), among many other cases. | 1640 | names (@pxref{File Name Completion}), among many other cases. |
| 1641 | 1641 | ||
| 1642 | To use this feature, pass a function as the @var{collection} | 1642 | To use this feature, pass a function as the @var{collection} |
| 1643 | argument to @code{completing-read}. The function | 1643 | argument to @code{completing-read}. The function |
| @@ -1665,7 +1665,7 @@ specifies which method to run. | |||
| 1665 | @end itemize | 1665 | @end itemize |
| 1666 | 1666 | ||
| 1667 | There are currently four methods, i.e. four flag values, one for | 1667 | There are currently four methods, i.e. four flag values, one for |
| 1668 | each of the four different basic operations: | 1668 | each of the four different basic operations: |
| 1669 | 1669 | ||
| 1670 | @itemize @bullet | 1670 | @itemize @bullet |
| 1671 | @item | 1671 | @item |
| @@ -1696,14 +1696,6 @@ in the string to complete, and END is the position of the end boundary | |||
| 1696 | in SUFFIX. | 1696 | in SUFFIX. |
| 1697 | @end itemize | 1697 | @end itemize |
| 1698 | 1698 | ||
| 1699 | It would be consistent and clean for completion functions to allow | ||
| 1700 | lambda expressions (lists that are functions) as well as function | ||
| 1701 | symbols as @var{collection}, but this is impossible. Lists as | ||
| 1702 | completion tables already have other meanings, and it would be | ||
| 1703 | unreliable to treat one differently just because it is also a possible | ||
| 1704 | function. So you must arrange for any function you wish to use for | ||
| 1705 | completion to be encapsulated in a symbol. | ||
| 1706 | |||
| 1707 | @defun completion-table-dynamic function | 1699 | @defun completion-table-dynamic function |
| 1708 | This function is a convenient way to write a function that can act as | 1700 | This function is a convenient way to write a function that can act as |
| 1709 | programmed completion function. The argument @var{function} should be | 1701 | programmed completion function. The argument @var{function} should be |
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index a44cd1fbcc7..1124d58ebcc 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi | |||
| @@ -797,69 +797,72 @@ is zero or less. | |||
| 797 | @cindex excursion | 797 | @cindex excursion |
| 798 | 798 | ||
| 799 | It is often useful to move point ``temporarily'' within a localized | 799 | It is often useful to move point ``temporarily'' within a localized |
| 800 | portion of the program, or to switch buffers temporarily. This is | 800 | portion of the program. This is called an @dfn{excursion}, and it is |
| 801 | called an @dfn{excursion}, and it is done with the @code{save-excursion} | 801 | done with the @code{save-excursion} special form. This construct |
| 802 | special form. This construct initially remembers the identity of the | 802 | remembers the initial identity of the current buffer, and its values |
| 803 | current buffer, and its values of point and the mark, and restores them | 803 | of point and the mark, and restores them after the excursion |
| 804 | after the completion of the excursion. | 804 | completes. It is the standard way to move point within one part of a |
| 805 | 805 | program and avoid affecting the rest of the program, and is used | |
| 806 | The forms for saving and restoring the configuration of windows are | 806 | thousands of times in the Lisp sources of Emacs. |
| 807 | described elsewhere (see @ref{Window Configurations}, and @pxref{Frame | 807 | |
| 808 | Configurations}). When only the identity of the current buffer needs | 808 | If you only need to save and restore the identity of the current |
| 809 | to be saved and restored, it is preferable to use | 809 | buffer, use @code{save-current-buffer} or @code{with-current-buffer} |
| 810 | @code{save-current-buffer} instead. | 810 | instead (@pxref{Current Buffer}). If you need to save or restore |
| 811 | window configurations, see the forms described in @ref{Window | ||
| 812 | Configurations} and in @ref{Frame Configurations}. | ||
| 811 | 813 | ||
| 812 | @defspec save-excursion body@dots{} | 814 | @defspec save-excursion body@dots{} |
| 813 | @cindex mark excursion | 815 | @cindex mark excursion |
| 814 | @cindex point excursion | 816 | @cindex point excursion |
| 815 | The @code{save-excursion} special form saves the identity of the current | 817 | This special form saves the identity of the current buffer and the |
| 816 | buffer and the values of point and the mark in it, evaluates | 818 | values of point and the mark in it, evaluates @var{body}, and finally |
| 817 | @var{body}, and finally restores the buffer and its saved values of | 819 | restores the buffer and its saved values of point and the mark. All |
| 818 | point and the mark. All three saved values are restored even in case of | 820 | three saved values are restored even in case of an abnormal exit via |
| 819 | an abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}). | 821 | @code{throw} or error (@pxref{Nonlocal Exits}). |
| 820 | 822 | ||
| 821 | The @code{save-excursion} special form is the standard way to move | 823 | The value returned by @code{save-excursion} is the result of the last |
| 822 | point within one part of a program and avoid affecting the rest of the | 824 | form in @var{body}, or @code{nil} if no body forms were given. |
| 823 | program. It is used more than 4000 times in the Lisp sources | 825 | @end defspec |
| 824 | of Emacs. | ||
| 825 | 826 | ||
| 826 | @code{save-excursion} does not save the values of point and the mark for | 827 | Because @code{save-excursion} only saves point and mark for the |
| 827 | other buffers, so changes in other buffers remain in effect after | 828 | buffer that was current at the start of the excursion, any changes |
| 828 | @code{save-excursion} exits. | 829 | made to point and/or mark in other buffers, during the excursion, will |
| 830 | remain in effect afterward. This frequently leads to unintended | ||
| 831 | consequences, so the byte compiler warns if you call @code{set-buffer} | ||
| 832 | during an excursion: | ||
| 829 | 833 | ||
| 830 | @cindex window excursions | 834 | @example |
| 831 | Likewise, @code{save-excursion} does not restore window-buffer | 835 | Warning: @code{save-excursion} defeated by @code{set-buffer} |
| 832 | correspondences altered by functions such as @code{switch-to-buffer}. | 836 | @end example |
| 833 | One way to restore these correspondences, and the selected window, is to | ||
| 834 | use @code{save-window-excursion} inside @code{save-excursion} | ||
| 835 | (@pxref{Window Configurations}). | ||
| 836 | 837 | ||
| 837 | The value returned by @code{save-excursion} is the result of the last | 838 | @noindent |
| 838 | form in @var{body}, or @code{nil} if no body forms were given. | 839 | To avoid such problems, you should call @code{save-excursion} only |
| 840 | after setting the desired current buffer, as in the following example: | ||
| 839 | 841 | ||
| 840 | @example | 842 | @example |
| 841 | @group | 843 | @group |
| 842 | (save-excursion @var{forms}) | 844 | (defun append-string-to-buffer (string buffer) |
| 843 | @equiv{} | 845 | "Append STRING to the end of BUFFER." |
| 844 | (let ((old-buf (current-buffer)) | 846 | (with-current-buffer buffer |
| 845 | (old-pnt (point-marker)) | 847 | (save-excursion |
| 846 | @end group | 848 | (goto-char (point-max)) |
| 847 | (old-mark (copy-marker (mark-marker)))) | 849 | (insert string)))) |
| 848 | (unwind-protect | ||
| 849 | (progn @var{forms}) | ||
| 850 | (set-buffer old-buf) | ||
| 851 | @group | ||
| 852 | (goto-char old-pnt) | ||
| 853 | (set-marker (mark-marker) old-mark))) | ||
| 854 | @end group | 850 | @end group |
| 855 | @end example | 851 | @end example |
| 856 | @end defspec | 852 | |
| 853 | @cindex window excursions | ||
| 854 | Likewise, @code{save-excursion} does not restore window-buffer | ||
| 855 | correspondences altered by functions such as @code{switch-to-buffer}. | ||
| 856 | One way to restore these correspondences, and the selected window, is to | ||
| 857 | use @code{save-window-excursion} inside @code{save-excursion} | ||
| 858 | (@pxref{Window Configurations}). | ||
| 857 | 859 | ||
| 858 | @strong{Warning:} Ordinary insertion of text adjacent to the saved | 860 | @strong{Warning:} Ordinary insertion of text adjacent to the saved |
| 859 | point value relocates the saved value, just as it relocates all markers. | 861 | point value relocates the saved value, just as it relocates all |
| 860 | More precisely, the saved value is a marker with insertion type | 862 | markers. More precisely, the saved value is a marker with insertion |
| 861 | @code{nil}. @xref{Marker Insertion Types}. Therefore, when the saved | 863 | type @code{nil}. @xref{Marker Insertion Types}. Therefore, when the |
| 862 | point value is restored, it normally comes before the inserted text. | 864 | saved point value is restored, it normally comes before the inserted |
| 865 | text. | ||
| 863 | 866 | ||
| 864 | Although @code{save-excursion} saves the location of the mark, it does | 867 | Although @code{save-excursion} saves the location of the mark, it does |
| 865 | not prevent functions which modify the buffer from setting | 868 | not prevent functions which modify the buffer from setting |
diff --git a/etc/NEWS.23 b/etc/NEWS.23 index 3e7a364ffd0..458e2bb3d32 100644 --- a/etc/NEWS.23 +++ b/etc/NEWS.23 | |||
| @@ -21,6 +21,13 @@ with a prefix argument or by typing C-u C-h C-n. | |||
| 21 | crt*.o files, if they are in a non-standard location. This is only | 21 | crt*.o files, if they are in a non-standard location. This is only |
| 22 | used on x86-64 and s390x GNU/Linux architectures. | 22 | used on x86-64 and s390x GNU/Linux architectures. |
| 23 | 23 | ||
| 24 | ** The MS-Windows build prefers libpng version 1.14 or later. | ||
| 25 | Versions of libpng before 1.14 had security issues, so we now | ||
| 26 | recommend to use version 1.14 or later. Precompiled Windows binaries | ||
| 27 | require version 1.14 or later. See README.W32 and nt/INSTALL for | ||
| 28 | details and pointers to URLs where the latest libpng can be | ||
| 29 | downloaded. | ||
| 30 | |||
| 24 | * Changes in Emacs 23.3 | 31 | * Changes in Emacs 23.3 |
| 25 | 32 | ||
| 26 | ** The last-resort backup file `%backup%~' is now written to | 33 | ** The last-resort backup file `%backup%~' is now written to |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d93dd27477a..551e12f94ba 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-03-24 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | * vc-annotate.el (vc-annotate-show-log-revision-at-line): | ||
| 4 | Fix typo in docstring. | ||
| 5 | |||
| 1 | 2011-04-08 Eli Zaretskii <eliz@gnu.org> | 6 | 2011-04-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * simple.el (list-processes): If async subprocesses are not | 8 | * simple.el (list-processes): If async subprocesses are not |
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index 479dbb5caea..271fce12429 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el | |||
| @@ -489,7 +489,7 @@ Return a cons (REV . FILENAME)." | |||
| 489 | "Visit the log of the revision at line. | 489 | "Visit the log of the revision at line. |
| 490 | If the VC backend supports it, only show the log entry for the revision. | 490 | If the VC backend supports it, only show the log entry for the revision. |
| 491 | If a *vc-change-log* buffer exists and already shows a log for | 491 | If a *vc-change-log* buffer exists and already shows a log for |
| 492 | the file in question, search for the log entry required and move point ." | 492 | the file in question, search for the log entry required and move point." |
| 493 | (interactive) | 493 | (interactive) |
| 494 | (if (not (equal major-mode 'vc-annotate-mode)) | 494 | (if (not (equal major-mode 'vc-annotate-mode)) |
| 495 | (message "Cannot be invoked outside of a vc annotate buffer") | 495 | (message "Cannot be invoked outside of a vc annotate buffer") |
diff --git a/src/ChangeLog b/src/ChangeLog index dc06f81d972..efacbbc4583 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-04-08 Svante Signell <svante.signell@telia.com> (tiny change) | ||
| 2 | |||
| 3 | * term.c (init_tty): Fix incorrect ifdef placement (Bug#8450). | ||
| 4 | |||
| 5 | 2011-03-19 Christoph Scholtes <cschol2112@googlemail.com> | ||
| 6 | |||
| 7 | * process.c (Fformat_network_address): Doc fix. | ||
| 8 | |||
| 1 | 2011-04-08 T.V. Raman <tv.raman.tv@gmail.com> (tiny change) | 9 | 2011-04-08 T.V. Raman <tv.raman.tv@gmail.com> (tiny change) |
| 2 | 10 | ||
| 3 | * xml.c (parse_region): Avoid creating spurious whiespace nodes. | 11 | * xml.c (parse_region): Avoid creating spurious whiespace nodes. |
diff --git a/src/process.c b/src/process.c index 4476014edfa..6cddbf6d1a9 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1261,9 +1261,9 @@ at end of BUFFER, unless you specify an output stream or filter | |||
| 1261 | function to handle the output. BUFFER may also be nil, meaning that | 1261 | function to handle the output. BUFFER may also be nil, meaning that |
| 1262 | this process is not associated with any buffer. | 1262 | this process is not associated with any buffer. |
| 1263 | 1263 | ||
| 1264 | PROGRAM is the program file name. It is searched for in PATH. If | 1264 | PROGRAM is the program file name. It is searched for in `exec-path' |
| 1265 | nil, just associate a pty with the buffer. Remaining arguments are | 1265 | (which see). If nil, just associate a pty with the buffer. Remaining |
| 1266 | strings to give program as arguments. | 1266 | arguments are strings to give program as arguments. |
| 1267 | 1267 | ||
| 1268 | If you want to separate standard output from standard error, invoke | 1268 | If you want to separate standard output from standard error, invoke |
| 1269 | the command through a shell and redirect one of them using the shell | 1269 | the command through a shell and redirect one of them using the shell |
diff --git a/src/term.c b/src/term.c index 39c9592e28f..9be9950d5eb 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3155,13 +3155,12 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3155 | if we don't have one at the moment. */ | 3155 | if we don't have one at the moment. */ |
| 3156 | fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); | 3156 | fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); |
| 3157 | else | 3157 | else |
| 3158 | #else | 3158 | #endif /* O_IGNORE_CTTY */ |
| 3159 | /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only | 3159 | /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only |
| 3160 | defined on Hurd. On other systems, we need to explicitly | 3160 | defined on Hurd. On other systems, we need to explicitly |
| 3161 | dissociate ourselves from the controlling tty when we want to | 3161 | dissociate ourselves from the controlling tty when we want to |
| 3162 | open a frame on the same terminal. */ | 3162 | open a frame on the same terminal. */ |
| 3163 | fd = emacs_open (name, O_RDWR | O_NOCTTY, 0); | 3163 | fd = emacs_open (name, O_RDWR | O_NOCTTY, 0); |
| 3164 | #endif /* O_IGNORE_CTTY */ | ||
| 3165 | 3164 | ||
| 3166 | tty->name = xstrdup (name); | 3165 | tty->name = xstrdup (name); |
| 3167 | terminal->name = xstrdup (name); | 3166 | terminal->name = xstrdup (name); |