Mercurial > emacs
comparison src/doc.c @ 14069:a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Harmonize arguments with documentation.
author | Erik Naggum <erik@naggum.no> |
---|---|
date | Tue, 09 Jan 1996 00:31:22 +0000 |
parents | 13e55327ef5e |
children | ee40177f6c68 |
comparison
equal
deleted
inserted
replaced
14068:a3c83dde295e | 14069:a45a97ebdf1c |
---|---|
261 return Fread (get_doc_string (filepos)); | 261 return Fread (get_doc_string (filepos)); |
262 } | 262 } |
263 | 263 |
264 DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, | 264 DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, |
265 "Return the documentation string of FUNCTION.\n\ | 265 "Return the documentation string of FUNCTION.\n\ |
266 Unless a non-nil second argument is given, the\n\ | 266 Unless a non-nil second argument RAW is given, the\n\ |
267 string is passed through `substitute-command-keys'.") | 267 string is passed through `substitute-command-keys'.") |
268 (function, raw) | 268 (function, raw) |
269 Lisp_Object function, raw; | 269 Lisp_Object function, raw; |
270 { | 270 { |
271 Lisp_Object fun; | 271 Lisp_Object fun; |
348 | 348 |
349 DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0, | 349 DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0, |
350 "Return the documentation string that is SYMBOL's PROP property.\n\ | 350 "Return the documentation string that is SYMBOL's PROP property.\n\ |
351 This is like `get', but it can refer to strings stored in the\n\ | 351 This is like `get', but it can refer to strings stored in the\n\ |
352 `etc/DOC' file; and if the value is a string, it is passed through\n\ | 352 `etc/DOC' file; and if the value is a string, it is passed through\n\ |
353 `substitute-command-keys'. A non-nil third argument avoids this\n\ | 353 `substitute-command-keys'. A non-nil third argument RAW avoids this\n\ |
354 translation.") | 354 translation.") |
355 (sym, prop, raw) | 355 (symbol, prop, raw) |
356 Lisp_Object sym, prop, raw; | 356 Lisp_Object symbol, prop, raw; |
357 { | 357 { |
358 register Lisp_Object tem; | 358 register Lisp_Object tem; |
359 | 359 |
360 tem = Fget (sym, prop); | 360 tem = Fget (symbol, prop); |
361 if (INTEGERP (tem)) | 361 if (INTEGERP (tem)) |
362 tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem))); | 362 tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem))); |
363 else if (CONSP (tem)) | 363 else if (CONSP (tem)) |
364 tem = get_doc_string (tem); | 364 tem = get_doc_string (tem); |
365 if (NILP (raw) && STRINGP (tem)) | 365 if (NILP (raw) && STRINGP (tem)) |
526 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap.\n\ | 526 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap.\n\ |
527 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR\n\ | 527 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR\n\ |
528 as the keymap for future \\=\\[COMMAND] substrings.\n\ | 528 as the keymap for future \\=\\[COMMAND] substrings.\n\ |
529 \\=\\= quotes the following character and is discarded;\n\ | 529 \\=\\= quotes the following character and is discarded;\n\ |
530 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.") | 530 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.") |
531 (str) | 531 (string) |
532 Lisp_Object str; | 532 Lisp_Object string; |
533 { | 533 { |
534 unsigned char *buf; | 534 unsigned char *buf; |
535 int changed = 0; | 535 int changed = 0; |
536 register unsigned char *strp; | 536 register unsigned char *strp; |
537 register unsigned char *bufp; | 537 register unsigned char *bufp; |
543 unsigned char *start; | 543 unsigned char *start; |
544 int length; | 544 int length; |
545 Lisp_Object name; | 545 Lisp_Object name; |
546 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 546 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
547 | 547 |
548 if (NILP (str)) | 548 if (NILP (string)) |
549 return Qnil; | 549 return Qnil; |
550 | 550 |
551 CHECK_STRING (str, 0); | 551 CHECK_STRING (string, 0); |
552 tem = Qnil; | 552 tem = Qnil; |
553 keymap = Qnil; | 553 keymap = Qnil; |
554 name = Qnil; | 554 name = Qnil; |
555 GCPRO4 (str, tem, keymap, name); | 555 GCPRO4 (string, tem, keymap, name); |
556 | 556 |
557 /* KEYMAP is either nil (which means search all the active keymaps) | 557 /* KEYMAP is either nil (which means search all the active keymaps) |
558 or a specified local map (which means search just that and the | 558 or a specified local map (which means search just that and the |
559 global map). If non-nil, it might come from Voverriding_local_map, | 559 global map). If non-nil, it might come from Voverriding_local_map, |
560 or from a \\<mapname> construct in STR itself.. */ | 560 or from a \\<mapname> construct in STRING itself.. */ |
561 keymap = current_kboard->Voverriding_terminal_local_map; | 561 keymap = current_kboard->Voverriding_terminal_local_map; |
562 if (NILP (keymap)) | 562 if (NILP (keymap)) |
563 keymap = Voverriding_local_map; | 563 keymap = Voverriding_local_map; |
564 | 564 |
565 bsize = XSTRING (str)->size; | 565 bsize = XSTRING (string)->size; |
566 bufp = buf = (unsigned char *) xmalloc (bsize); | 566 bufp = buf = (unsigned char *) xmalloc (bsize); |
567 | 567 |
568 strp = (unsigned char *) XSTRING (str)->data; | 568 strp = (unsigned char *) XSTRING (string)->data; |
569 while (strp < (unsigned char *) XSTRING (str)->data + XSTRING (str)->size) | 569 while (strp < (unsigned char *) XSTRING (string)->data + XSTRING (string)->size) |
570 { | 570 { |
571 if (strp[0] == '\\' && strp[1] == '=') | 571 if (strp[0] == '\\' && strp[1] == '=') |
572 { | 572 { |
573 /* \= quotes the next character; | 573 /* \= quotes the next character; |
574 thus, to put in \[ without its special meaning, use \=\[. */ | 574 thus, to put in \[ without its special meaning, use \=\[. */ |
582 | 582 |
583 changed = 1; | 583 changed = 1; |
584 strp += 2; /* skip \[ */ | 584 strp += 2; /* skip \[ */ |
585 start = strp; | 585 start = strp; |
586 | 586 |
587 while ((strp - (unsigned char *) XSTRING (str)->data | 587 while ((strp - (unsigned char *) XSTRING (string)->data |
588 < XSTRING (str)->size) | 588 < XSTRING (string)->size) |
589 && *strp != ']') | 589 && *strp != ']') |
590 strp++; | 590 strp++; |
591 length = strp - start; | 591 length = strp - start; |
592 strp++; /* skip ] */ | 592 strp++; /* skip ] */ |
593 | 593 |
594 /* Save STRP in IDX. */ | 594 /* Save STRP in IDX. */ |
595 idx = strp - (unsigned char *) XSTRING (str)->data; | 595 idx = strp - (unsigned char *) XSTRING (string)->data; |
596 tem = Fintern (make_string (start, length), Qnil); | 596 tem = Fintern (make_string (start, length), Qnil); |
597 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil); | 597 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil); |
598 | 598 |
599 /* Disregard menu bar bindings; it is positively annoying to | 599 /* Disregard menu bar bindings; it is positively annoying to |
600 mention them when there's no menu bar, and it isn't terribly | 600 mention them when there's no menu bar, and it isn't terribly |
629 | 629 |
630 changed = 1; | 630 changed = 1; |
631 strp += 2; /* skip \{ or \< */ | 631 strp += 2; /* skip \{ or \< */ |
632 start = strp; | 632 start = strp; |
633 | 633 |
634 while ((strp - (unsigned char *) XSTRING (str)->data | 634 while ((strp - (unsigned char *) XSTRING (string)->data |
635 < XSTRING (str)->size) | 635 < XSTRING (string)->size) |
636 && *strp != '}' && *strp != '>') | 636 && *strp != '}' && *strp != '>') |
637 strp++; | 637 strp++; |
638 length = strp - start; | 638 length = strp - start; |
639 strp++; /* skip } or > */ | 639 strp++; /* skip } or > */ |
640 | 640 |
641 /* Save STRP in IDX. */ | 641 /* Save STRP in IDX. */ |
642 idx = strp - (unsigned char *) XSTRING (str)->data; | 642 idx = strp - (unsigned char *) XSTRING (string)->data; |
643 | 643 |
644 /* Get the value of the keymap in TEM, or nil if undefined. | 644 /* Get the value of the keymap in TEM, or nil if undefined. |
645 Do this while still in the user's current buffer | 645 Do this while still in the user's current buffer |
646 in case it is a local variable. */ | 646 in case it is a local variable. */ |
647 name = Fintern (make_string (start, length), Qnil); | 647 name = Fintern (make_string (start, length), Qnil); |
680 new = (unsigned char *) xrealloc (buf, bsize += length); | 680 new = (unsigned char *) xrealloc (buf, bsize += length); |
681 bufp += new - buf; | 681 bufp += new - buf; |
682 buf = new; | 682 buf = new; |
683 bcopy (start, bufp, length); | 683 bcopy (start, bufp, length); |
684 bufp += length; | 684 bufp += length; |
685 /* Check STR again in case gc relocated it. */ | 685 /* Check STRING again in case gc relocated it. */ |
686 strp = (unsigned char *) XSTRING (str)->data + idx; | 686 strp = (unsigned char *) XSTRING (string)->data + idx; |
687 } | 687 } |
688 else /* just copy other chars */ | 688 else /* just copy other chars */ |
689 *bufp++ = *strp++; | 689 *bufp++ = *strp++; |
690 } | 690 } |
691 | 691 |
692 if (changed) /* don't bother if nothing substituted */ | 692 if (changed) /* don't bother if nothing substituted */ |
693 tem = make_string (buf, bufp - buf); | 693 tem = make_string (buf, bufp - buf); |
694 else | 694 else |
695 tem = str; | 695 tem = string; |
696 xfree (buf); | 696 xfree (buf); |
697 RETURN_UNGCPRO (tem); | 697 RETURN_UNGCPRO (tem); |
698 } | 698 } |
699 | 699 |
700 syms_of_doc () | 700 syms_of_doc () |