comparison src/minibuf.c @ 9903:133888d97e98

(Fdisplay_completion_list): Update COLUMN unconditionally. If a name is long, put it on its own line.
author Richard M. Stallman <rms@gnu.org>
date Sun, 13 Nov 1994 19:57:12 +0000
parents 6ee76b67cbfa
children 77b5eb8fc9e3
comparison
equal deleted inserted replaced
9902:32ed712a45a3 9903:133888d97e98
1430 register Lisp_Object tail, elt; 1430 register Lisp_Object tail, elt;
1431 register int i; 1431 register int i;
1432 int column = 0; 1432 int column = 0;
1433 struct gcpro gcpro1; 1433 struct gcpro gcpro1;
1434 struct buffer *old = current_buffer; 1434 struct buffer *old = current_buffer;
1435 int first = 1;
1435 1436
1436 /* Note that (when it matters) every variable 1437 /* Note that (when it matters) every variable
1437 points to a non-string that is pointed to by COMPLETIONS. */ 1438 points to a non-string that is pointed to by COMPLETIONS. */
1438 GCPRO1 (completions); 1439 GCPRO1 (completions);
1439 1440
1446 else 1447 else
1447 { 1448 {
1448 write_string ("Possible completions are:", -1); 1449 write_string ("Possible completions are:", -1);
1449 for (tail = completions, i = 0; !NILP (tail); tail = Fcdr (tail), i++) 1450 for (tail = completions, i = 0; !NILP (tail); tail = Fcdr (tail), i++)
1450 { 1451 {
1451 /* this needs fixing for the case of long completions 1452 Lisp_Object tem;
1452 and/or narrow windows */ 1453 int length;
1453 /* Sadly, the window it will appear in is not known 1454
1454 until after the text has been made. */ 1455 elt = Fcar (tail);
1455 if (i & 1) 1456 /* Compute the length of this element. */
1457 if (CONSP (elt))
1458 {
1459 tem = Fcar (elt);
1460 CHECK_STRING (tem, 0);
1461 length = XINT (XSTRING (tem)->size);
1462
1463 tem = Fcar (Fcdr (elt));
1464 CHECK_STRING (tem, 0);
1465 length += XINT (XSTRING (tem)->size);
1466 }
1467 else
1468 {
1469 CHECK_STRING (elt, 0);
1470 length = XINT (XSTRING (elt)->size);
1471 }
1472
1473 /* This does a bad job for narrower than usual windows.
1474 Sadly, the window it will appear in is not known
1475 until after the text has been made. */
1476
1477 /* If the previous completion was very wide,
1478 or we have two on this line already,
1479 don't put another on the same line. */
1480 if (column > 33 || first
1481 /* If this is really wide, don't put it second on a line. */
1482 || column > 0 && length > 45)
1483 {
1484 Fterpri (Qnil);
1485 column = 0;
1486 }
1487 /* Otherwise advance to column 35. */
1488 else
1456 { 1489 {
1457 if (BUFFERP (Vstandard_output)) 1490 if (BUFFERP (Vstandard_output))
1458 Findent_to (make_number (35), make_number (2)); 1491 {
1492 tem = Findent_to (make_number (35), make_number (2));
1493 column = XINT (tem);
1494 }
1459 else 1495 else
1460 { 1496 {
1461 do 1497 do
1462 { 1498 {
1463 write_string (" ", -1); 1499 write_string (" ", -1);
1464 column++; 1500 column++;
1465 } 1501 }
1466 while (column < 35); 1502 while (column < 35);
1467 } 1503 }
1468 } 1504 }
1469 else 1505
1470 { 1506 /* Output this element and update COLUMN. */
1471 Fterpri (Qnil);
1472 column = 0;
1473 }
1474 elt = Fcar (tail);
1475 if (CONSP (elt)) 1507 if (CONSP (elt))
1476 { 1508 {
1477 if (!BUFFERP (Vstandard_output))
1478 {
1479 Lisp_Object tem;
1480 tem = Flength (Fcar (elt));
1481 column += XINT (tem);
1482 tem = Flength (Fcar (Fcdr (elt)));
1483 column += XINT (tem);
1484 }
1485 Fprinc (Fcar (elt), Qnil); 1509 Fprinc (Fcar (elt), Qnil);
1486 Fprinc (Fcar (Fcdr (elt)), Qnil); 1510 Fprinc (Fcar (Fcdr (elt)), Qnil);
1487 } 1511 }
1488 else 1512 else
1513 Fprinc (elt, Qnil);
1514
1515 column += length;
1516
1517 /* If output is to a buffer, recompute COLUMN in a way
1518 that takes account of character widths. */
1519 if (BUFFERP (Vstandard_output))
1489 { 1520 {
1490 if (!BUFFERP (Vstandard_output)) 1521 tem = Fcurrent_column ();
1491 { 1522 column = XINT (tem);
1492 Lisp_Object tem;
1493 tem = Flength (elt);
1494 column += XINT (tem);
1495 }
1496 Fprinc (elt, Qnil);
1497 } 1523 }
1524
1525 first = 0;
1498 } 1526 }
1499 } 1527 }
1500 1528
1501 UNGCPRO; 1529 UNGCPRO;
1502 1530