diff options
| author | Dmitry Antipov | 2012-08-28 10:20:08 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-08-28 10:20:08 +0400 |
| commit | 66322887059e1f2711e07def5eff661281cee855 (patch) | |
| tree | edf1ef336402c53b08c69f2b0d92c2391a2549d5 /src | |
| parent | a3d794a153425b09a0185c660926c241d13e0f2c (diff) | |
| download | emacs-66322887059e1f2711e07def5eff661281cee855.tar.gz emacs-66322887059e1f2711e07def5eff661281cee855.zip | |
Always use set_buffer_if_live to restore original buffer at unwind.
* buffer.h (record_unwind_current_buffer): New function.
* bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c:
* keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c:
* undo.c, window.c: Adjust users.
* buffer.c (set_buffer_if_live): Fix comment.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/buffer.c | 2 | ||||
| -rw-r--r-- | src/buffer.h | 9 | ||||
| -rw-r--r-- | src/bytecode.c | 2 | ||||
| -rw-r--r-- | src/dispnew.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 7 | ||||
| -rw-r--r-- | src/fileio.c | 2 | ||||
| -rw-r--r-- | src/fns.c | 2 | ||||
| -rw-r--r-- | src/insdel.c | 2 | ||||
| -rw-r--r-- | src/keyboard.c | 2 | ||||
| -rw-r--r-- | src/keymap.c | 4 | ||||
| -rw-r--r-- | src/minibuf.c | 2 | ||||
| -rw-r--r-- | src/print.c | 2 | ||||
| -rw-r--r-- | src/process.c | 4 | ||||
| -rw-r--r-- | src/textprop.c | 4 | ||||
| -rw-r--r-- | src/undo.c | 2 | ||||
| -rw-r--r-- | src/window.c | 4 |
17 files changed, 37 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0806cc0ff95..889c8efebdb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2012-08-28 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-08-28 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Always use set_buffer_if_live to restore original buffer at unwind. | ||
| 4 | * buffer.h (record_unwind_current_buffer): New function. | ||
| 5 | * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c: | ||
| 6 | * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c: | ||
| 7 | * undo.c, window.c: Adjust users. | ||
| 8 | * buffer.c (set_buffer_if_live): Fix comment. | ||
| 9 | |||
| 10 | 2012-08-28 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 11 | |||
| 3 | Fix usage of set_buffer_internal. | 12 | Fix usage of set_buffer_internal. |
| 4 | * buffer.h (set_buffer_internal): Make it BUFFER_INLINE. | 13 | * buffer.h (set_buffer_internal): Make it BUFFER_INLINE. |
| 5 | * buffer.c (set_buffer_if_live): Use set_buffer_internal. | 14 | * buffer.c (set_buffer_if_live): Use set_buffer_internal. |
diff --git a/src/buffer.c b/src/buffer.c index 5185e6c89f1..61ec736ad1a 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2204,7 +2204,7 @@ ends when the current command terminates. Use `switch-to-buffer' or | |||
| 2204 | return buffer; | 2204 | return buffer; |
| 2205 | } | 2205 | } |
| 2206 | 2206 | ||
| 2207 | /* Set the current buffer to BUFFER provided it is alive. */ | 2207 | /* Set the current buffer to BUFFER provided if it is alive. */ |
| 2208 | 2208 | ||
| 2209 | Lisp_Object | 2209 | Lisp_Object |
| 2210 | set_buffer_if_live (Lisp_Object buffer) | 2210 | set_buffer_if_live (Lisp_Object buffer) |
diff --git a/src/buffer.h b/src/buffer.h index 929da3c4791..3acf1423816 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1038,6 +1038,15 @@ set_buffer_internal (struct buffer *b) | |||
| 1038 | set_buffer_internal_1 (b); | 1038 | set_buffer_internal_1 (b); |
| 1039 | } | 1039 | } |
| 1040 | 1040 | ||
| 1041 | /* Arrange to go back to the original buffer after the next | ||
| 1042 | call to unbind_to if the original buffer is still alive. */ | ||
| 1043 | |||
| 1044 | BUFFER_INLINE void | ||
| 1045 | record_unwind_current_buffer (void) | ||
| 1046 | { | ||
| 1047 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | ||
| 1048 | } | ||
| 1049 | |||
| 1041 | /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. | 1050 | /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. |
| 1042 | If NEXTP is non-NULL, return next overlay there. | 1051 | If NEXTP is non-NULL, return next overlay there. |
| 1043 | See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. */ | 1052 | See overlay_at arg CHANGE_REQ for meaning of CHRQ arg. */ |
diff --git a/src/bytecode.c b/src/bytecode.c index 753f149ae01..40729cbd453 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -1051,7 +1051,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 1051 | 1051 | ||
| 1052 | CASE (Bsave_current_buffer): /* Obsolete since ??. */ | 1052 | CASE (Bsave_current_buffer): /* Obsolete since ??. */ |
| 1053 | CASE (Bsave_current_buffer_1): | 1053 | CASE (Bsave_current_buffer_1): |
| 1054 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 1054 | record_unwind_current_buffer (); |
| 1055 | NEXT; | 1055 | NEXT; |
| 1056 | 1056 | ||
| 1057 | CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ | 1057 | CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ |
diff --git a/src/dispnew.c b/src/dispnew.c index f37b872274a..4e307880111 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -5762,7 +5762,7 @@ change_frame_size_1 (struct frame *f, int newheight, int newwidth, | |||
| 5762 | 5762 | ||
| 5763 | UNBLOCK_INPUT; | 5763 | UNBLOCK_INPUT; |
| 5764 | 5764 | ||
| 5765 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 5765 | record_unwind_current_buffer (); |
| 5766 | 5766 | ||
| 5767 | run_window_configuration_change_hook (f); | 5767 | run_window_configuration_change_hook (f); |
| 5768 | 5768 | ||
diff --git a/src/editfns.c b/src/editfns.c index 0bd632d14b7..7b451e4e443 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -946,13 +946,10 @@ BODY is executed just like `progn'. | |||
| 946 | usage: (save-current-buffer &rest BODY) */) | 946 | usage: (save-current-buffer &rest BODY) */) |
| 947 | (Lisp_Object args) | 947 | (Lisp_Object args) |
| 948 | { | 948 | { |
| 949 | Lisp_Object val; | ||
| 950 | ptrdiff_t count = SPECPDL_INDEX (); | 949 | ptrdiff_t count = SPECPDL_INDEX (); |
| 951 | 950 | ||
| 952 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 951 | record_unwind_current_buffer (); |
| 953 | 952 | return unbind_to (count, Fprogn (args)); | |
| 954 | val = Fprogn (args); | ||
| 955 | return unbind_to (count, val); | ||
| 956 | } | 953 | } |
| 957 | 954 | ||
| 958 | DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, | 955 | DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, |
diff --git a/src/fileio.c b/src/fileio.c index 44696cc8e62..7466914af1c 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3480,7 +3480,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3480 | Lisp_Object workbuf; | 3480 | Lisp_Object workbuf; |
| 3481 | struct buffer *buf; | 3481 | struct buffer *buf; |
| 3482 | 3482 | ||
| 3483 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3483 | record_unwind_current_buffer (); |
| 3484 | 3484 | ||
| 3485 | workbuf = Fget_buffer_create (build_string (" *code-converting-work*")); | 3485 | workbuf = Fget_buffer_create (build_string (" *code-converting-work*")); |
| 3486 | buf = XBUFFER (workbuf); | 3486 | buf = XBUFFER (workbuf); |
| @@ -4656,7 +4656,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_ | |||
| 4656 | { | 4656 | { |
| 4657 | struct buffer *prev = current_buffer; | 4657 | struct buffer *prev = current_buffer; |
| 4658 | 4658 | ||
| 4659 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 4659 | record_unwind_current_buffer (); |
| 4660 | 4660 | ||
| 4661 | CHECK_BUFFER (object); | 4661 | CHECK_BUFFER (object); |
| 4662 | 4662 | ||
diff --git a/src/insdel.c b/src/insdel.c index 53a3a1370cd..8cb98566085 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -2117,7 +2117,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute, | |||
| 2117 | return Qnil; | 2117 | return Qnil; |
| 2118 | } | 2118 | } |
| 2119 | 2119 | ||
| 2120 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 2120 | record_unwind_current_buffer (); |
| 2121 | 2121 | ||
| 2122 | Fset_buffer (combine_after_change_buffer); | 2122 | Fset_buffer (combine_after_change_buffer); |
| 2123 | 2123 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index f31480e3b88..d9b88a8a911 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -9572,7 +9572,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9572 | because we may get input from a subprocess which | 9572 | because we may get input from a subprocess which |
| 9573 | wants to change the selected window and stuff (say, | 9573 | wants to change the selected window and stuff (say, |
| 9574 | emacsclient). */ | 9574 | emacsclient). */ |
| 9575 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 9575 | record_unwind_current_buffer (); |
| 9576 | 9576 | ||
| 9577 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) | 9577 | if (! FRAME_LIVE_P (XFRAME (selected_frame))) |
| 9578 | Fkill_emacs (Qnil); | 9578 | Fkill_emacs (Qnil); |
diff --git a/src/keymap.c b/src/keymap.c index 21f7dcb5d37..4031091501c 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1570,9 +1570,7 @@ like in the respective argument of `key-binding'. */) | |||
| 1570 | would not be a problem here, but it is easier to keep | 1570 | would not be a problem here, but it is easier to keep |
| 1571 | things the same. | 1571 | things the same. |
| 1572 | */ | 1572 | */ |
| 1573 | 1573 | record_unwind_current_buffer (); | |
| 1574 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | ||
| 1575 | |||
| 1576 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); | 1574 | set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); |
| 1577 | } | 1575 | } |
| 1578 | } | 1576 | } |
diff --git a/src/minibuf.c b/src/minibuf.c index 2154d1654df..41cc48017eb 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -817,7 +817,7 @@ get_minibuffer (EMACS_INT depth) | |||
| 817 | while the buffer doesn't know about them any more. */ | 817 | while the buffer doesn't know about them any more. */ |
| 818 | delete_all_overlays (XBUFFER (buf)); | 818 | delete_all_overlays (XBUFFER (buf)); |
| 819 | reset_buffer (XBUFFER (buf)); | 819 | reset_buffer (XBUFFER (buf)); |
| 820 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 820 | record_unwind_current_buffer (); |
| 821 | Fset_buffer (buf); | 821 | Fset_buffer (buf); |
| 822 | if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode")))) | 822 | if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode")))) |
| 823 | call0 (intern ("minibuffer-inactive-mode")); | 823 | call0 (intern ("minibuffer-inactive-mode")); |
diff --git a/src/print.c b/src/print.c index 36d0b5dce9d..52c07c79122 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -487,7 +487,7 @@ temp_output_buffer_setup (const char *bufname) | |||
| 487 | register struct buffer *old = current_buffer; | 487 | register struct buffer *old = current_buffer; |
| 488 | register Lisp_Object buf; | 488 | register Lisp_Object buf; |
| 489 | 489 | ||
| 490 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 490 | record_unwind_current_buffer (); |
| 491 | 491 | ||
| 492 | Fset_buffer (Fget_buffer_create (build_string (bufname))); | 492 | Fset_buffer (Fget_buffer_create (build_string (bufname))); |
| 493 | 493 | ||
diff --git a/src/process.c b/src/process.c index 64c70c49590..fbe56ebcb54 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -5196,7 +5196,7 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5196 | /* There's no good reason to let process filters change the current | 5196 | /* There's no good reason to let process filters change the current |
| 5197 | buffer, and many callers of accept-process-output, sit-for, and | 5197 | buffer, and many callers of accept-process-output, sit-for, and |
| 5198 | friends don't expect current-buffer to be changed from under them. */ | 5198 | friends don't expect current-buffer to be changed from under them. */ |
| 5199 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 5199 | record_unwind_current_buffer (); |
| 5200 | 5200 | ||
| 5201 | /* Read and dispose of the process output. */ | 5201 | /* Read and dispose of the process output. */ |
| 5202 | outstream = p->filter; | 5202 | outstream = p->filter; |
| @@ -6587,7 +6587,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason) | |||
| 6587 | /* There's no good reason to let sentinels change the current | 6587 | /* There's no good reason to let sentinels change the current |
| 6588 | buffer, and many callers of accept-process-output, sit-for, and | 6588 | buffer, and many callers of accept-process-output, sit-for, and |
| 6589 | friends don't expect current-buffer to be changed from under them. */ | 6589 | friends don't expect current-buffer to be changed from under them. */ |
| 6590 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 6590 | record_unwind_current_buffer (); |
| 6591 | 6591 | ||
| 6592 | sentinel = p->sentinel; | 6592 | sentinel = p->sentinel; |
| 6593 | if (NILP (sentinel)) | 6593 | if (NILP (sentinel)) |
diff --git a/src/textprop.c b/src/textprop.c index 20d98b0e6f3..b6895fc426a 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -760,7 +760,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) | |||
| 760 | 760 | ||
| 761 | if (BUFFERP (object) && current_buffer != XBUFFER (object)) | 761 | if (BUFFERP (object) && current_buffer != XBUFFER (object)) |
| 762 | { | 762 | { |
| 763 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 763 | record_unwind_current_buffer (); |
| 764 | Fset_buffer (object); | 764 | Fset_buffer (object); |
| 765 | } | 765 | } |
| 766 | 766 | ||
| @@ -843,7 +843,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */) | |||
| 843 | 843 | ||
| 844 | if (BUFFERP (object) && current_buffer != XBUFFER (object)) | 844 | if (BUFFERP (object) && current_buffer != XBUFFER (object)) |
| 845 | { | 845 | { |
| 846 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 846 | record_unwind_current_buffer (); |
| 847 | Fset_buffer (object); | 847 | Fset_buffer (object); |
| 848 | } | 848 | } |
| 849 | 849 | ||
diff --git a/src/undo.c b/src/undo.c index 777e3291806..9cd1d5f9f67 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -324,7 +324,7 @@ truncate_undo_list (struct buffer *b) | |||
| 324 | /* Make the buffer current to get its local values of variables such | 324 | /* Make the buffer current to get its local values of variables such |
| 325 | as undo_limit. Also so that Vundo_outer_limit_function can | 325 | as undo_limit. Also so that Vundo_outer_limit_function can |
| 326 | tell which buffer to operate on. */ | 326 | tell which buffer to operate on. */ |
| 327 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 327 | record_unwind_current_buffer (); |
| 328 | set_buffer_internal (b); | 328 | set_buffer_internal (b); |
| 329 | 329 | ||
| 330 | list = BVAR (b, undo_list); | 330 | list = BVAR (b, undo_list); |
diff --git a/src/window.c b/src/window.c index 330636efed9..ba1ec2544f8 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3101,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 3101 | /* Use the right buffer. Matters when running the local hooks. */ | 3101 | /* Use the right buffer. Matters when running the local hooks. */ |
| 3102 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) | 3102 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) |
| 3103 | { | 3103 | { |
| 3104 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3104 | record_unwind_current_buffer (); |
| 3105 | Fset_buffer (Fwindow_buffer (Qnil)); | 3105 | Fset_buffer (Fwindow_buffer (Qnil)); |
| 3106 | } | 3106 | } |
| 3107 | 3107 | ||
| @@ -3205,7 +3205,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3205 | because that might itself be a local variable. */ | 3205 | because that might itself be a local variable. */ |
| 3206 | if (window_initialized) | 3206 | if (window_initialized) |
| 3207 | { | 3207 | { |
| 3208 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3208 | record_unwind_current_buffer (); |
| 3209 | Fset_buffer (buffer); | 3209 | Fset_buffer (buffer); |
| 3210 | } | 3210 | } |
| 3211 | 3211 | ||