diff options
| author | Karl Heuer | 1995-12-21 17:12:52 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-12-21 17:12:52 +0000 |
| commit | 113620cc876f15f38ac0719490dae15f92c93641 (patch) | |
| tree | e1fbe5f3e5157c656f5b7603ac50835ffc4f6ae6 /src | |
| parent | 5bb8cce10ceb6ed693c2833c9110bcbcb080000d (diff) | |
| download | emacs-113620cc876f15f38ac0719490dae15f92c93641.tar.gz emacs-113620cc876f15f38ac0719490dae15f92c93641.zip | |
(Ferror_message_string): New function.
(syms_of_print): defsubr it. Doc fix.
(print_error_message): New subroutine.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/src/print.c b/src/print.c index 50946656320..264397313b1 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -630,6 +630,81 @@ debug_print (arg) | |||
| 630 | fprintf (stderr, "\r\n"); | 630 | fprintf (stderr, "\r\n"); |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, | ||
| 634 | 1, 1, 0, | ||
| 635 | "Convert an error value (ERROR-SYMBOL . DATA) to an error message.") | ||
| 636 | (obj) | ||
| 637 | Lisp_Object obj; | ||
| 638 | { | ||
| 639 | struct buffer *old = current_buffer; | ||
| 640 | Lisp_Object original, printcharfun, value; | ||
| 641 | struct gcpro gcpro1; | ||
| 642 | |||
| 643 | print_error_message (obj, Vprin1_to_string_buffer, NULL); | ||
| 644 | |||
| 645 | set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); | ||
| 646 | value = Fbuffer_string (); | ||
| 647 | |||
| 648 | GCPRO1 (value); | ||
| 649 | Ferase_buffer (); | ||
| 650 | set_buffer_internal (old); | ||
| 651 | UNGCPRO; | ||
| 652 | |||
| 653 | return value; | ||
| 654 | } | ||
| 655 | |||
| 656 | /* Print an error message for the error DATA | ||
| 657 | onto Lisp output stream STREAM (suitable for the print functions). */ | ||
| 658 | |||
| 659 | print_error_message (data, stream) | ||
| 660 | Lisp_Object data, stream; | ||
| 661 | { | ||
| 662 | Lisp_Object errname, errmsg, file_error, tail; | ||
| 663 | struct gcpro gcpro1; | ||
| 664 | int i; | ||
| 665 | |||
| 666 | errname = Fcar (data); | ||
| 667 | |||
| 668 | if (EQ (errname, Qerror)) | ||
| 669 | { | ||
| 670 | data = Fcdr (data); | ||
| 671 | if (!CONSP (data)) data = Qnil; | ||
| 672 | errmsg = Fcar (data); | ||
| 673 | file_error = Qnil; | ||
| 674 | } | ||
| 675 | else | ||
| 676 | { | ||
| 677 | errmsg = Fget (errname, Qerror_message); | ||
| 678 | file_error = Fmemq (Qfile_error, | ||
| 679 | Fget (errname, Qerror_conditions)); | ||
| 680 | } | ||
| 681 | |||
| 682 | /* Print an error message including the data items. */ | ||
| 683 | |||
| 684 | tail = Fcdr_safe (data); | ||
| 685 | GCPRO1 (tail); | ||
| 686 | |||
| 687 | /* For file-error, make error message by concatenating | ||
| 688 | all the data items. They are all strings. */ | ||
| 689 | if (!NILP (file_error) && !NILP (tail)) | ||
| 690 | errmsg = XCONS (tail)->car, tail = XCONS (tail)->cdr; | ||
| 691 | |||
| 692 | if (STRINGP (errmsg)) | ||
| 693 | Fprinc (errmsg, stream); | ||
| 694 | else | ||
| 695 | write_string_1 ("peculiar error", -1, stream); | ||
| 696 | |||
| 697 | for (i = 0; CONSP (tail); tail = Fcdr (tail), i++) | ||
| 698 | { | ||
| 699 | write_string_1 (i ? ", " : ": ", 2, stream); | ||
| 700 | if (!NILP (file_error)) | ||
| 701 | Fprinc (Fcar (tail), stream); | ||
| 702 | else | ||
| 703 | Fprin1 (Fcar (tail), stream); | ||
| 704 | } | ||
| 705 | UNGCPRO; | ||
| 706 | } | ||
| 707 | |||
| 633 | #ifdef LISP_FLOAT_TYPE | 708 | #ifdef LISP_FLOAT_TYPE |
| 634 | 709 | ||
| 635 | /* | 710 | /* |
| @@ -1204,7 +1279,7 @@ syms_of_print () | |||
| 1204 | This may be any function of one argument.\n\ | 1279 | This may be any function of one argument.\n\ |
| 1205 | It may also be a buffer (output is inserted before point)\n\ | 1280 | It may also be a buffer (output is inserted before point)\n\ |
| 1206 | or a marker (output is inserted and the marker is advanced)\n\ | 1281 | or a marker (output is inserted and the marker is advanced)\n\ |
| 1207 | or the symbol t (output appears in the minibuffer line)."); | 1282 | or the symbol t (output appears in the echo area)."); |
| 1208 | Vstandard_output = Qt; | 1283 | Vstandard_output = Qt; |
| 1209 | Qstandard_output = intern ("standard-output"); | 1284 | Qstandard_output = intern ("standard-output"); |
| 1210 | staticpro (&Qstandard_output); | 1285 | staticpro (&Qstandard_output); |
| @@ -1249,6 +1324,7 @@ Also print formfeeds as backslash-f."); | |||
| 1249 | 1324 | ||
| 1250 | defsubr (&Sprin1); | 1325 | defsubr (&Sprin1); |
| 1251 | defsubr (&Sprin1_to_string); | 1326 | defsubr (&Sprin1_to_string); |
| 1327 | defsubr (&Serror_message_string); | ||
| 1252 | defsubr (&Sprinc); | 1328 | defsubr (&Sprinc); |
| 1253 | defsubr (&Sprint); | 1329 | defsubr (&Sprint); |
| 1254 | defsubr (&Sterpri); | 1330 | defsubr (&Sterpri); |