Mercurial > emacs
comparison src/buffer.c @ 3884:19b4e1fef348
* buffer.c (list_buffers_1): Make desired_point a lisp object; set
it to nil, unless we find the current buffer.
(Flist_buffers): Don't try to set point in the buffer list unless
list_buffers_1 actually returns an integer. Don't use a full
save_excursion; just save and restore the buffer.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 22 Jun 1993 07:39:26 +0000 |
parents | 594bc11c67ba |
children | a860278e3ab3 |
comparison
equal
deleted
inserted
replaced
3883:b9e5a869b33e | 3884:19b4e1fef348 |
---|---|
1033 Lisp_Object files; | 1033 Lisp_Object files; |
1034 { | 1034 { |
1035 register Lisp_Object tail, tem, buf; | 1035 register Lisp_Object tail, tem, buf; |
1036 Lisp_Object col1, col2, col3, minspace; | 1036 Lisp_Object col1, col2, col3, minspace; |
1037 register struct buffer *old = current_buffer, *b; | 1037 register struct buffer *old = current_buffer, *b; |
1038 int desired_point = 0; | 1038 Lisp_Object desired_point; |
1039 Lisp_Object other_file_symbol; | 1039 Lisp_Object other_file_symbol; |
1040 | 1040 |
1041 desired_point = Qnil; | |
1041 other_file_symbol = intern ("list-buffers-directory"); | 1042 other_file_symbol = intern ("list-buffers-directory"); |
1042 | 1043 |
1043 XFASTINT (col1) = 19; | 1044 XFASTINT (col1) = 19; |
1044 XFASTINT (col2) = 25; | 1045 XFASTINT (col2) = 25; |
1045 XFASTINT (col3) = 40; | 1046 XFASTINT (col3) = 40; |
1068 /* Optionally don't mention buffers that lack files. */ | 1069 /* Optionally don't mention buffers that lack files. */ |
1069 if (!NILP (files) && NILP (b->filename)) | 1070 if (!NILP (files) && NILP (b->filename)) |
1070 continue; | 1071 continue; |
1071 /* Identify the current buffer. */ | 1072 /* Identify the current buffer. */ |
1072 if (b == old) | 1073 if (b == old) |
1073 desired_point = point; | 1074 XFASTINT (desired_point) = point; |
1074 write_string (b == old ? "." : " ", -1); | 1075 write_string (b == old ? "." : " ", -1); |
1075 /* Identify modified buffers */ | 1076 /* Identify modified buffers */ |
1076 write_string (BUF_MODIFF (b) > b->save_modified ? "*" : " ", -1); | 1077 write_string (BUF_MODIFF (b) > b->save_modified ? "*" : " ", -1); |
1077 write_string (NILP (b->read_only) ? " " : "% ", -1); | 1078 write_string (NILP (b->read_only) ? " " : "% ", -1); |
1078 Fprinc (b->name, Qnil); | 1079 Fprinc (b->name, Qnil); |
1104 write_string ("\n", -1); | 1105 write_string ("\n", -1); |
1105 } | 1106 } |
1106 | 1107 |
1107 current_buffer->read_only = Qt; | 1108 current_buffer->read_only = Qt; |
1108 set_buffer_internal (old); | 1109 set_buffer_internal (old); |
1109 return make_number (desired_point); | 1110 return desired_point; |
1110 } | 1111 } |
1111 | 1112 |
1112 DEFUN ("list-buffers", Flist_buffers, Slist_buffers, 0, 1, "P", | 1113 DEFUN ("list-buffers", Flist_buffers, Slist_buffers, 0, 1, "P", |
1113 "Display a list of names of existing buffers.\n\ | 1114 "Display a list of names of existing buffers.\n\ |
1114 The list is displayed in a buffer named `*Buffer List*'.\n\ | 1115 The list is displayed in a buffer named `*Buffer List*'.\n\ |
1118 The M column contains a * for buffers that are modified.\n\ | 1119 The M column contains a * for buffers that are modified.\n\ |
1119 The R column contains a % for buffers that are read-only.") | 1120 The R column contains a % for buffers that are read-only.") |
1120 (files) | 1121 (files) |
1121 Lisp_Object files; | 1122 Lisp_Object files; |
1122 { | 1123 { |
1123 int count = specpdl_ptr - specpdl; | |
1124 Lisp_Object desired_point; | 1124 Lisp_Object desired_point; |
1125 | 1125 |
1126 desired_point = | 1126 desired_point = |
1127 internal_with_output_to_temp_buffer ("*Buffer List*", | 1127 internal_with_output_to_temp_buffer ("*Buffer List*", |
1128 list_buffers_1, files); | 1128 list_buffers_1, files); |
1129 | 1129 |
1130 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1130 if (NUMBERP (desired_point)) |
1131 Fset_buffer (build_string ("*Buffer List*")); | 1131 { |
1132 SET_PT (XINT (desired_point)); | 1132 int count = specpdl_ptr - specpdl; |
1133 | 1133 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
1134 return unbind_to (count, Qnil); | 1134 Fset_buffer (build_string ("*Buffer List*")); |
1135 SET_PT (XINT (desired_point)); | |
1136 return unbind_to (count, Qnil); | |
1137 } | |
1135 } | 1138 } |
1136 | 1139 |
1137 DEFUN ("kill-all-local-variables", Fkill_all_local_variables, Skill_all_local_variables, | 1140 DEFUN ("kill-all-local-variables", Fkill_all_local_variables, Skill_all_local_variables, |
1138 0, 0, 0, | 1141 0, 0, 0, |
1139 "Switch to Fundamental mode by killing current buffer's local variables.\n\ | 1142 "Switch to Fundamental mode by killing current buffer's local variables.\n\ |