diff options
| author | Basil L. Contovounesios | 2019-06-26 22:13:34 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-06-26 22:16:52 +0100 |
| commit | 8b775c30adaad63a4838e911d6c02e55a4269c4e (patch) | |
| tree | f214e16ac921891b48ed4cc0abc003d4d071295c | |
| parent | 7648c125dfdd0232362c35c2898bbe355c874dc1 (diff) | |
| download | emacs-8b775c30adaad63a4838e911d6c02e55a4269c4e.tar.gz emacs-8b775c30adaad63a4838e911d6c02e55a4269c4e.zip | |
Clarify & update (elisp) Writing Emacs Primitives
* doc/lispref/internals.texi (Writing Emacs Primitives): Update some
of the sample code listings, fixing argument lists and parentheses.
Replace ... with @dots{}. Describe UNEVALLED special forms as
taking a single argument. (bug#36392)
| -rw-r--r-- | doc/lispref/internals.texi | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 7cbd2966839..6a7ea1c6913 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi | |||
| @@ -654,8 +654,8 @@ appearance.) | |||
| 654 | @smallexample | 654 | @smallexample |
| 655 | @group | 655 | @group |
| 656 | DEFUN ("or", For, Sor, 0, UNEVALLED, 0, | 656 | DEFUN ("or", For, Sor, 0, UNEVALLED, 0, |
| 657 | doc: /* Eval args until one of them yields non-nil, then return | 657 | doc: /* Eval args until one of them yields non-nil, |
| 658 | that value. | 658 | then return that value. |
| 659 | The remaining args are not evalled at all. | 659 | The remaining args are not evalled at all. |
| 660 | If all args return nil, return nil. | 660 | If all args return nil, return nil. |
| 661 | @end group | 661 | @end group |
| @@ -729,7 +729,7 @@ less than 8. | |||
| 729 | This is an interactive specification, a string such as might be used | 729 | This is an interactive specification, a string such as might be used |
| 730 | as the argument of @code{interactive} in a Lisp function | 730 | as the argument of @code{interactive} in a Lisp function |
| 731 | (@pxref{Using Interactive}). In the case | 731 | (@pxref{Using Interactive}). In the case |
| 732 | of @code{or}, it is 0 (a null pointer), indicating that @code{or} | 732 | of @code{or}, it is @code{0} (a null pointer), indicating that @code{or} |
| 733 | cannot be called interactively. A value of @code{""} indicates a | 733 | cannot be called interactively. A value of @code{""} indicates a |
| 734 | function that should receive no arguments when called interactively. | 734 | function that should receive no arguments when called interactively. |
| 735 | If the value begins with a @samp{"(}, the string is evaluated as a | 735 | If the value begins with a @samp{"(}, the string is evaluated as a |
| @@ -737,11 +737,11 @@ Lisp form. For example: | |||
| 737 | 737 | ||
| 738 | @example | 738 | @example |
| 739 | @group | 739 | @group |
| 740 | DEFUN ("foo", Ffoo, Sfoo, 0, UNEVALLED, 0 | 740 | DEFUN ("foo", Ffoo, Sfoo, 0, 3, |
| 741 | "(list (read-char-by-name \"Insert character: \")\ | 741 | "(list (read-char-by-name \"Insert character: \")\ |
| 742 | (prefix-numeric-value current-prefix-arg)\ | 742 | (prefix-numeric-value current-prefix-arg)\ |
| 743 | t))", | 743 | t)", |
| 744 | doc: /* @dots{} */) | 744 | doc: /* @dots{} */) |
| 745 | @end group | 745 | @end group |
| 746 | @end example | 746 | @end example |
| 747 | 747 | ||
| @@ -771,8 +771,8 @@ this: | |||
| 771 | @example | 771 | @example |
| 772 | @group | 772 | @group |
| 773 | DEFUN ("bar", Fbar, Sbar, 0, UNEVALLED, 0 | 773 | DEFUN ("bar", Fbar, Sbar, 0, UNEVALLED, 0 |
| 774 | doc: /* @dots{} */ | 774 | doc: /* @dots{} */ |
| 775 | attributes: @var{attr1} @var{attr2} @dots{}) | 775 | attributes: @var{attr1} @var{attr2} @dots{}) |
| 776 | @end group | 776 | @end group |
| 777 | @end example | 777 | @end example |
| 778 | 778 | ||
| @@ -808,15 +808,18 @@ arguments. If the primitive accepts a fixed maximum number of Lisp | |||
| 808 | arguments, there must be one C argument for each Lisp argument, and | 808 | arguments, there must be one C argument for each Lisp argument, and |
| 809 | each argument must be of type @code{Lisp_Object}. (Various macros and | 809 | each argument must be of type @code{Lisp_Object}. (Various macros and |
| 810 | functions for creating values of type @code{Lisp_Object} are declared | 810 | functions for creating values of type @code{Lisp_Object} are declared |
| 811 | in the file @file{lisp.h}.) If the primitive has no upper limit on | 811 | in the file @file{lisp.h}.) If the primitive is a special form, it |
| 812 | the number of Lisp arguments, it must have exactly two C arguments: | 812 | must accept a Lisp list containing its unevaluated Lisp arguments as a |
| 813 | the first is the number of Lisp arguments, and the second is the | 813 | single argument of type @code{Lisp_Object}. If the primitive has no |
| 814 | address of a block containing their values. These have types | 814 | upper limit on the number of evaluated Lisp arguments, it must have |
| 815 | @code{int} and @w{@code{Lisp_Object *}} respectively. Since | 815 | exactly two C arguments: the first is the number of Lisp arguments, |
| 816 | @code{Lisp_Object} can hold any Lisp object of any data type, you | 816 | and the second is the address of a block containing their values. |
| 817 | can determine the actual data type only at run time; so if you want | 817 | These have types @code{ptrdiff_t} and @w{@code{Lisp_Object *}}, |
| 818 | a primitive to accept only a certain type of argument, you must check | 818 | respectively. Since @code{Lisp_Object} can hold any Lisp object of |
| 819 | the type explicitly using a suitable predicate (@pxref{Type Predicates}). | 819 | any data type, you can determine the actual data type only at run |
| 820 | time; so if you want a primitive to accept only a certain type of | ||
| 821 | argument, you must check the type explicitly using a suitable | ||
| 822 | predicate (@pxref{Type Predicates}). | ||
| 820 | @cindex type checking internals | 823 | @cindex type checking internals |
| 821 | 824 | ||
| 822 | @cindex garbage collection protection | 825 | @cindex garbage collection protection |
| @@ -906,9 +909,9 @@ of macros and functions to manipulate Lisp objects. | |||
| 906 | @smallexample | 909 | @smallexample |
| 907 | @group | 910 | @group |
| 908 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | 911 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, |
| 909 | Scoordinates_in_window_p, 2, 2, 0, | 912 | Scoordinates_in_window_p, 2, 2, 0, |
| 910 | doc: /* Return non-nil if COORDINATES are in WINDOW. | 913 | doc: /* Return non-nil if COORDINATES are in WINDOW. |
| 911 | ... | 914 | @dots{} |
| 912 | @end group | 915 | @end group |
| 913 | @group | 916 | @group |
| 914 | or `right-margin' is returned. */) | 917 | or `right-margin' is returned. */) |
| @@ -921,16 +924,15 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | |||
| 921 | @end group | 924 | @end group |
| 922 | 925 | ||
| 923 | @group | 926 | @group |
| 924 | CHECK_LIVE_WINDOW (window); | 927 | w = decode_live_window (window); |
| 925 | w = XWINDOW (window); | ||
| 926 | f = XFRAME (w->frame); | 928 | f = XFRAME (w->frame); |
| 927 | CHECK_CONS (coordinates); | 929 | CHECK_CONS (coordinates); |
| 928 | lx = Fcar (coordinates); | 930 | lx = Fcar (coordinates); |
| 929 | ly = Fcdr (coordinates); | 931 | ly = Fcdr (coordinates); |
| 930 | CHECK_NUMBER_OR_FLOAT (lx); | 932 | CHECK_NUMBER (lx); |
| 931 | CHECK_NUMBER_OR_FLOAT (ly); | 933 | CHECK_NUMBER (ly); |
| 932 | x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH(f); | 934 | x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f); |
| 933 | y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH(f); | 935 | y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f); |
| 934 | @end group | 936 | @end group |
| 935 | 937 | ||
| 936 | @group | 938 | @group |
| @@ -940,14 +942,14 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | |||
| 940 | return Qnil; | 942 | return Qnil; |
| 941 | @end group | 943 | @end group |
| 942 | 944 | ||
| 943 | ... | 945 | @dots{} |
| 944 | 946 | ||
| 945 | @group | 947 | @group |
| 946 | case ON_MODE_LINE: /* In mode line of window. */ | 948 | case ON_MODE_LINE: /* In mode line of window. */ |
| 947 | return Qmode_line; | 949 | return Qmode_line; |
| 948 | @end group | 950 | @end group |
| 949 | 951 | ||
| 950 | ... | 952 | @dots{} |
| 951 | 953 | ||
| 952 | @group | 954 | @group |
| 953 | case ON_SCROLL_BAR: /* On scroll-bar of window. */ | 955 | case ON_SCROLL_BAR: /* On scroll-bar of window. */ |
| @@ -957,7 +959,7 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | |||
| 957 | 959 | ||
| 958 | @group | 960 | @group |
| 959 | default: | 961 | default: |
| 960 | abort (); | 962 | emacs_abort (); |
| 961 | @} | 963 | @} |
| 962 | @} | 964 | @} |
| 963 | @end group | 965 | @end group |