aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2018-06-07 18:53:27 -0700
committerPaul Eggert2018-06-07 19:11:50 -0700
commit0e1bfd3886bc8e95fc1b5b13aff565be6caa44e2 (patch)
tree28b7c76f39aeb9d273b2e6d31e256d44e9bf943a
parenta0aa1d4ecc123d652285ef10ea62ed55c6c118d6 (diff)
downloademacs-0e1bfd3886bc8e95fc1b5b13aff565be6caa44e2.tar.gz
emacs-0e1bfd3886bc8e95fc1b5b13aff565be6caa44e2.zip
Minor cleanup of save_excursion_restore
* src/editfns.c (save_excursion_restore): Use clearer names for locals. Free earlier, removing the need for a label and goto.
-rw-r--r--src/editfns.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 2377ceb18af..e672c0eb74d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1016,37 +1016,30 @@ save_excursion_save (void)
1016void 1016void
1017save_excursion_restore (Lisp_Object info) 1017save_excursion_restore (Lisp_Object info)
1018{ 1018{
1019 Lisp_Object tem, tem1; 1019 Lisp_Object marker = XSAVE_OBJECT (info, 0);
1020 1020 Lisp_Object window = XSAVE_OBJECT (info, 2);
1021 tem = Fmarker_buffer (XSAVE_OBJECT (info, 0)); 1021 free_misc (info);
1022 Lisp_Object buffer = Fmarker_buffer (marker);
1022 /* If we're unwinding to top level, saved buffer may be deleted. This 1023 /* If we're unwinding to top level, saved buffer may be deleted. This
1023 means that all of its markers are unchained and so tem is nil. */ 1024 means that all of its markers are unchained and so BUFFER is nil. */
1024 if (NILP (tem)) 1025 if (NILP (buffer))
1025 goto out; 1026 return;
1026 1027
1027 Fset_buffer (tem); 1028 Fset_buffer (buffer);
1028 1029
1029 /* Point marker. */ 1030 Fgoto_char (marker);
1030 tem = XSAVE_OBJECT (info, 0); 1031 unchain_marker (XMARKER (marker));
1031 Fgoto_char (tem);
1032 unchain_marker (XMARKER (tem));
1033 1032
1034 /* If buffer was visible in a window, and a different window was 1033 /* If buffer was visible in a window, and a different window was
1035 selected, and the old selected window is still showing this 1034 selected, and the old selected window is still showing this
1036 buffer, restore point in that window. */ 1035 buffer, restore point in that window. */
1037 tem = XSAVE_OBJECT (info, 2); 1036 if (WINDOWP (window) && !EQ (window, selected_window))
1038 if (WINDOWP (tem) 1037 {
1039 && !EQ (tem, selected_window) 1038 /* Set window point if WINDOW is live and shows the current buffer. */
1040 && (tem1 = XWINDOW (tem)->contents, 1039 Lisp_Object contents = XWINDOW (window)->contents;
1041 (/* Window is live... */ 1040 if (BUFFERP (contents) && XBUFFER (contents) == current_buffer)
1042 BUFFERP (tem1) 1041 Fset_window_point (window, make_number (PT));
1043 /* ...and it shows the current buffer. */ 1042 }
1044 && XBUFFER (tem1) == current_buffer)))
1045 Fset_window_point (tem, make_number (PT));
1046
1047 out:
1048
1049 free_misc (info);
1050} 1043}
1051 1044
1052DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, 1045DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0,