comparison src/buffer.c @ 22189:2a61a0a3a9be

(Fother_buffer): New arg FRAME. Calls changed. Pass it to frame_buffer_list, frame_buffer_predicate. (record_buffer): Pass selected frame to them and to set_frame_buffer_list.
author Richard M. Stallman <rms@gnu.org>
date Fri, 22 May 1998 20:05:56 +0000
parents e23d16d11ba9
children c07c0604d95d
comparison
equal deleted inserted replaced
22188:9fba463768ec 22189:2a61a0a3a9be
888 call0 (intern ("rename-auto-save-file")); 888 call0 (intern ("rename-auto-save-file"));
889 /* Refetch since that last call may have done GC. */ 889 /* Refetch since that last call may have done GC. */
890 return current_buffer->name; 890 return current_buffer->name;
891 } 891 }
892 892
893 DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 2, 0, 893 DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0,
894 "Return most recently selected buffer other than BUFFER.\n\ 894 "Return most recently selected buffer other than BUFFER.\n\
895 Buffers not visible in windows are preferred to visible buffers,\n\ 895 Buffers not visible in windows are preferred to visible buffers,\n\
896 unless optional second argument VISIBLE-OK is non-nil.\n\ 896 unless optional second argument VISIBLE-OK is non-nil.\n\
897 If no other buffer exists, the buffer `*scratch*' is returned.\n\ 897 If no other buffer exists, the buffer `*scratch*' is returned.\n\
898 If BUFFER is omitted or nil, some interesting buffer is returned.") 898 If BUFFER is omitted or nil, some interesting buffer is returned.")
899 (buffer, visible_ok) 899 (buffer, visible_ok, frame)
900 register Lisp_Object buffer, visible_ok; 900 register Lisp_Object buffer, visible_ok, frame;
901 { 901 {
902 Lisp_Object Fset_buffer_major_mode (); 902 Lisp_Object Fset_buffer_major_mode ();
903 register Lisp_Object tail, buf, notsogood, tem, pred, add_ons; 903 register Lisp_Object tail, buf, notsogood, tem, pred, add_ons;
904 notsogood = Qnil; 904 notsogood = Qnil;
905 905
906 if (NILP (frame))
907 frame = Fselected_frame ();
908
906 tail = Vbuffer_alist; 909 tail = Vbuffer_alist;
907 pred = frame_buffer_predicate (); 910 pred = frame_buffer_predicate (frame);
908 911
909 /* Consider buffers that have been seen in the selected frame 912 /* Consider buffers that have been seen in the selected frame
910 before other buffers. */ 913 before other buffers. */
911 914
912 tem = frame_buffer_list (); 915 tem = frame_buffer_list (frame);
913 add_ons = Qnil; 916 add_ons = Qnil;
914 while (CONSP (tem)) 917 while (CONSP (tem))
915 { 918 {
916 if (BUFFERP (XCONS (tem)->car)) 919 if (BUFFERP (XCONS (tem)->car))
917 add_ons = Fcons (Fcons (Qnil, XCONS (tem)->car), add_ons); 920 add_ons = Fcons (Fcons (Qnil, XCONS (tem)->car), add_ons);
1109 /* Make this buffer not be current. 1112 /* Make this buffer not be current.
1110 In the process, notice if this is the sole visible buffer 1113 In the process, notice if this is the sole visible buffer
1111 and give up if so. */ 1114 and give up if so. */
1112 if (b == current_buffer) 1115 if (b == current_buffer)
1113 { 1116 {
1114 tem = Fother_buffer (buf, Qnil); 1117 tem = Fother_buffer (buf, Qnil, Qnil);
1115 Fset_buffer (tem); 1118 Fset_buffer (tem);
1116 if (b == current_buffer) 1119 if (b == current_buffer)
1117 return Qnil; 1120 return Qnil;
1118 } 1121 }
1119 1122
1217 void 1220 void
1218 record_buffer (buf) 1221 record_buffer (buf)
1219 Lisp_Object buf; 1222 Lisp_Object buf;
1220 { 1223 {
1221 register Lisp_Object link, prev; 1224 register Lisp_Object link, prev;
1225 Lisp_Object frame;
1226 frame = Fselected_frame ();
1222 1227
1223 prev = Qnil; 1228 prev = Qnil;
1224 for (link = Vbuffer_alist; CONSP (link); link = XCONS (link)->cdr) 1229 for (link = Vbuffer_alist; CONSP (link); link = XCONS (link)->cdr)
1225 { 1230 {
1226 if (EQ (XCONS (XCONS (link)->car)->cdr, buf)) 1231 if (EQ (XCONS (XCONS (link)->car)->cdr, buf))
1240 Vbuffer_alist = link; 1245 Vbuffer_alist = link;
1241 1246
1242 /* Now move this buffer to the front of frame_buffer_list also. */ 1247 /* Now move this buffer to the front of frame_buffer_list also. */
1243 1248
1244 prev = Qnil; 1249 prev = Qnil;
1245 for (link = frame_buffer_list (); CONSP (link); link = XCONS (link)->cdr) 1250 for (link = frame_buffer_list (frame); CONSP (link);
1251 link = XCONS (link)->cdr)
1246 { 1252 {
1247 if (EQ (XCONS (link)->car, buf)) 1253 if (EQ (XCONS (link)->car, buf))
1248 break; 1254 break;
1249 prev = link; 1255 prev = link;
1250 } 1256 }
1252 /* Effectively do delq. */ 1258 /* Effectively do delq. */
1253 1259
1254 if (CONSP (link)) 1260 if (CONSP (link))
1255 { 1261 {
1256 if (NILP (prev)) 1262 if (NILP (prev))
1257 set_frame_buffer_list (XCONS (frame_buffer_list ())->cdr); 1263 set_frame_buffer_list (frame,
1264 XCONS (frame_buffer_list (frame))->cdr);
1258 else 1265 else
1259 XCONS (prev)->cdr = XCONS (XCONS (prev)->cdr)->cdr; 1266 XCONS (prev)->cdr = XCONS (XCONS (prev)->cdr)->cdr;
1260 1267
1261 XCONS (link)->cdr = frame_buffer_list (); 1268 XCONS (link)->cdr = frame_buffer_list (frame);
1262 set_frame_buffer_list (link); 1269 set_frame_buffer_list (frame, link);
1263 } 1270 }
1264 else 1271 else
1265 set_frame_buffer_list (Fcons (buf, frame_buffer_list ())); 1272 set_frame_buffer_list (frame, Fcons (buf, frame_buffer_list (frame)));
1266 } 1273 }
1267 1274
1268 DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, 1275 DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0,
1269 "Set an appropriate major mode for BUFFER, according to `default-major-mode'.\n\ 1276 "Set an appropriate major mode for BUFFER, according to `default-major-mode'.\n\
1270 Use this function before selecting the buffer, since it may need to inspect\n\ 1277 Use this function before selecting the buffer, since it may need to inspect\n\
1315 tem = Fwindow_dedicated_p (selected_window); 1322 tem = Fwindow_dedicated_p (selected_window);
1316 if (!NILP (tem)) 1323 if (!NILP (tem))
1317 error ("Cannot switch buffers in a dedicated window"); 1324 error ("Cannot switch buffers in a dedicated window");
1318 1325
1319 if (NILP (buffer)) 1326 if (NILP (buffer))
1320 buf = Fother_buffer (Fcurrent_buffer (), Qnil); 1327 buf = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil);
1321 else 1328 else
1322 { 1329 {
1323 buf = Fget_buffer (buffer); 1330 buf = Fget_buffer (buffer);
1324 if (NILP (buf)) 1331 if (NILP (buf))
1325 { 1332 {
1353 (buffer, other_window, norecord) 1360 (buffer, other_window, norecord)
1354 Lisp_Object buffer, other_window, norecord; 1361 Lisp_Object buffer, other_window, norecord;
1355 { 1362 {
1356 register Lisp_Object buf; 1363 register Lisp_Object buf;
1357 if (NILP (buffer)) 1364 if (NILP (buffer))
1358 buf = Fother_buffer (Fcurrent_buffer (), Qnil); 1365 buf = Fother_buffer (Fcurrent_buffer (), Qnil, Qnil);
1359 else 1366 else
1360 { 1367 {
1361 buf = Fget_buffer (buffer); 1368 buf = Fget_buffer (buffer);
1362 if (NILP (buf)) 1369 if (NILP (buf))
1363 { 1370 {
1619 if (NILP (buffer)) 1626 if (NILP (buffer))
1620 { 1627 {
1621 XSETBUFFER (buffer, current_buffer); 1628 XSETBUFFER (buffer, current_buffer);
1622 1629
1623 /* If we're burying the current buffer, unshow it. */ 1630 /* If we're burying the current buffer, unshow it. */
1624 Fswitch_to_buffer (Fother_buffer (buffer, Qnil), Qnil); 1631 Fswitch_to_buffer (Fother_buffer (buffer, Qnil, Qnil), Qnil);
1625 } 1632 }
1626 else 1633 else
1627 { 1634 {
1628 Lisp_Object buf1; 1635 Lisp_Object buf1;
1629 1636