diff options
| author | Stefan Monnier | 2012-06-18 11:57:41 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-06-18 11:57:41 -0400 |
| commit | 1053a8716ba9f1834eccff14ece377928a4bd244 (patch) | |
| tree | 775e64585480452dcaa629ee9ffa2b85505d3e01 | |
| parent | b7e8d081674c24b19c5ee39892a72aef25c1dfcc (diff) | |
| download | emacs-1053a8716ba9f1834eccff14ece377928a4bd244.tar.gz emacs-1053a8716ba9f1834eccff14ece377928a4bd244.zip | |
Fix return value of `defun' and un-define it.
* src/data.c (Fdefalias): Return `symbol'.
* doc/lispref/functions.texi (Defining Functions):
* doc/lispref/macros.texi (Defining Macros): Un-define the return value of
`defun', `defmacro' and `defalias'.
Fixes: debbugs:11686
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/functions.texi | 18 | ||||
| -rw-r--r-- | doc/lispref/macros.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-run.el | 4 | ||||
| -rw-r--r-- | src/ChangeLog | 28 | ||||
| -rw-r--r-- | src/data.c | 15 |
7 files changed, 41 insertions, 41 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 0439cf2be57..89efb5c6255 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-06-18 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * functions.texi (Defining Functions): | ||
| 4 | * macros.texi (Defining Macros): Un-define the return value of `defun', | ||
| 5 | `defmacro' and `defalias'. | ||
| 6 | |||
| 1 | 2012-06-17 Chong Yidong <cyd@gnu.org> | 7 | 2012-06-17 Chong Yidong <cyd@gnu.org> |
| 2 | 8 | ||
| 3 | * elisp.texi: Remove urlcolor setting. | 9 | * elisp.texi: Remove urlcolor setting. |
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 5fba243f65f..ab2789b5e6d 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -530,8 +530,7 @@ defines the symbol @var{name} as a function that looks like this: | |||
| 530 | @end example | 530 | @end example |
| 531 | 531 | ||
| 532 | @code{defun} stores this lambda expression in the function cell of | 532 | @code{defun} stores this lambda expression in the function cell of |
| 533 | @var{name}. It returns the value @var{name}, but usually we ignore this | 533 | @var{name}. Its return value is @emph{undefined}. |
| 534 | value. | ||
| 535 | 534 | ||
| 536 | As described previously, @var{argument-list} is a list of argument | 535 | As described previously, @var{argument-list} is a list of argument |
| 537 | names and may include the keywords @code{&optional} and @code{&rest}. | 536 | names and may include the keywords @code{&optional} and @code{&rest}. |
| @@ -543,9 +542,6 @@ Here are some examples: | |||
| 543 | @example | 542 | @example |
| 544 | @group | 543 | @group |
| 545 | (defun foo () 5) | 544 | (defun foo () 5) |
| 546 | @result{} foo | ||
| 547 | @end group | ||
| 548 | @group | ||
| 549 | (foo) | 545 | (foo) |
| 550 | @result{} 5 | 546 | @result{} 5 |
| 551 | @end group | 547 | @end group |
| @@ -553,9 +549,6 @@ Here are some examples: | |||
| 553 | @group | 549 | @group |
| 554 | (defun bar (a &optional b &rest c) | 550 | (defun bar (a &optional b &rest c) |
| 555 | (list a b c)) | 551 | (list a b c)) |
| 556 | @result{} bar | ||
| 557 | @end group | ||
| 558 | @group | ||
| 559 | (bar 1 2 3 4 5) | 552 | (bar 1 2 3 4 5) |
| 560 | @result{} (1 2 (3 4 5)) | 553 | @result{} (1 2 (3 4 5)) |
| 561 | @end group | 554 | @end group |
| @@ -576,7 +569,6 @@ Here are some examples: | |||
| 576 | (forward-word 1) | 569 | (forward-word 1) |
| 577 | (backward-char 1) | 570 | (backward-char 1) |
| 578 | (capitalize-word 1)) | 571 | (capitalize-word 1)) |
| 579 | @result{} capitalize-backwards | ||
| 580 | @end group | 572 | @end group |
| 581 | @end example | 573 | @end example |
| 582 | 574 | ||
| @@ -593,7 +585,7 @@ redefinition from unintentional redefinition. | |||
| 593 | @anchor{Definition of defalias} | 585 | @anchor{Definition of defalias} |
| 594 | This special form defines the symbol @var{name} as a function, with | 586 | This special form defines the symbol @var{name} as a function, with |
| 595 | definition @var{definition} (which can be any valid Lisp function). | 587 | definition @var{definition} (which can be any valid Lisp function). |
| 596 | It returns @var{definition}. | 588 | Its return value is @emph{undefined}. |
| 597 | 589 | ||
| 598 | If @var{docstring} is non-@code{nil}, it becomes the function | 590 | If @var{docstring} is non-@code{nil}, it becomes the function |
| 599 | documentation of @var{name}. Otherwise, any documentation provided by | 591 | documentation of @var{name}. Otherwise, any documentation provided by |
| @@ -1015,9 +1007,6 @@ function. | |||
| 1015 | @example | 1007 | @example |
| 1016 | @group | 1008 | @group |
| 1017 | (defun bar (n) (+ n 2)) | 1009 | (defun bar (n) (+ n 2)) |
| 1018 | @result{} bar | ||
| 1019 | @end group | ||
| 1020 | @group | ||
| 1021 | (symbol-function 'bar) | 1010 | (symbol-function 'bar) |
| 1022 | @result{} (lambda (n) (+ n 2)) | 1011 | @result{} (lambda (n) (+ n 2)) |
| 1023 | @end group | 1012 | @end group |
| @@ -1063,9 +1052,6 @@ subsequent attempt to access this cell will cause a | |||
| 1063 | @example | 1052 | @example |
| 1064 | @group | 1053 | @group |
| 1065 | (defun foo (x) x) | 1054 | (defun foo (x) x) |
| 1066 | @result{} foo | ||
| 1067 | @end group | ||
| 1068 | @group | ||
| 1069 | (foo 1) | 1055 | (foo 1) |
| 1070 | @result{}1 | 1056 | @result{}1 |
| 1071 | @end group | 1057 | @end group |
diff --git a/doc/lispref/macros.texi b/doc/lispref/macros.texi index b9b0e03c65a..efe298bf647 100644 --- a/doc/lispref/macros.texi +++ b/doc/lispref/macros.texi | |||
| @@ -113,7 +113,6 @@ uses this feature. | |||
| 113 | @group | 113 | @group |
| 114 | (defmacro inc (var) | 114 | (defmacro inc (var) |
| 115 | (list 'setq var (list '1+ var))) | 115 | (list 'setq var (list '1+ var))) |
| 116 | @result{} inc | ||
| 117 | @end group | 116 | @end group |
| 118 | 117 | ||
| 119 | @group | 118 | @group |
| @@ -124,7 +123,6 @@ uses this feature. | |||
| 124 | @group | 123 | @group |
| 125 | (defmacro inc2 (var1 var2) | 124 | (defmacro inc2 (var1 var2) |
| 126 | (list 'progn (list 'inc var1) (list 'inc var2))) | 125 | (list 'progn (list 'inc var1) (list 'inc var2))) |
| 127 | @result{} inc2 | ||
| 128 | @end group | 126 | @end group |
| 129 | 127 | ||
| 130 | @group | 128 | @group |
| @@ -207,9 +205,8 @@ like this: | |||
| 207 | @end example | 205 | @end example |
| 208 | 206 | ||
| 209 | (Note that the @sc{cdr} of this list is a function---a lambda expression.) | 207 | (Note that the @sc{cdr} of this list is a function---a lambda expression.) |
| 210 | This macro object is stored in the function cell of @var{name}. The | 208 | This macro object is stored in the function cell of @var{name}. Its return |
| 211 | value returned by evaluating the @code{defmacro} form is @var{name}, but | 209 | value is @emph{undefined}. |
| 212 | usually we ignore this value. | ||
| 213 | 210 | ||
| 214 | The shape and meaning of @var{argument-list} is the same as in a | 211 | The shape and meaning of @var{argument-list} is the same as in a |
| 215 | function, and the keywords @code{&rest} and @code{&optional} may be used | 212 | function, and the keywords @code{&rest} and @code{&optional} may be used |
| @@ -342,7 +339,6 @@ For example, (for i from 1 to 10 do (print i))." | |||
| 342 | (cons (list '<= var final) | 339 | (cons (list '<= var final) |
| 343 | (append body (list (list 'inc var))))))) | 340 | (append body (list (list 'inc var))))))) |
| 344 | @end group | 341 | @end group |
| 345 | @result{} for | ||
| 346 | 342 | ||
| 347 | @group | 343 | @group |
| 348 | (for i from 1 to 3 do | 344 | (for i from 1 to 3 do |
| @@ -512,7 +508,6 @@ it. Here is an example: | |||
| 512 | @group | 508 | @group |
| 513 | (defmacro foo (a) | 509 | (defmacro foo (a) |
| 514 | (list 'setq (eval a) t)) | 510 | (list 'setq (eval a) t)) |
| 515 | @result{} foo | ||
| 516 | @end group | 511 | @end group |
| 517 | @group | 512 | @group |
| 518 | (setq x 'b) | 513 | (setq x 'b) |
| @@ -429,6 +429,8 @@ still be supported for Emacs 24.x. | |||
| 429 | 429 | ||
| 430 | * Lisp changes in Emacs 24.2 | 430 | * Lisp changes in Emacs 24.2 |
| 431 | 431 | ||
| 432 | ** The return value of `defalias' has changed and is now undefined. | ||
| 433 | |||
| 432 | ** `defun' also accepts a (declare DECLS) form, like `defmacro'. | 434 | ** `defun' also accepts a (declare DECLS) form, like `defmacro'. |
| 433 | The interpretation of the DECLS is determined by `defun-declarations-alist'. | 435 | The interpretation of the DECLS is determined by `defun-declarations-alist'. |
| 434 | 436 | ||
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 635eef93d96..925d275386f 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el | |||
| @@ -123,7 +123,8 @@ the list ARGS... as it appears in the expression, | |||
| 123 | and the result should be a form to be evaluated instead of the original. | 123 | and the result should be a form to be evaluated instead of the original. |
| 124 | DECL is a declaration, optional, of the form (declare DECLS...) where | 124 | DECL is a declaration, optional, of the form (declare DECLS...) where |
| 125 | DECLS is a list of elements of the form (PROP . VALUES). These are | 125 | DECLS is a list of elements of the form (PROP . VALUES). These are |
| 126 | interpreted according to `macro-declarations-alist'." | 126 | interpreted according to `macro-declarations-alist'. |
| 127 | The return value is undefined." | ||
| 127 | (if (stringp docstring) nil | 128 | (if (stringp docstring) nil |
| 128 | (if decl (setq body (cons decl body))) | 129 | (if decl (setq body (cons decl body))) |
| 129 | (setq decl docstring) | 130 | (setq decl docstring) |
| @@ -158,6 +159,7 @@ See also the function `interactive'. | |||
| 158 | DECL is a declaration, optional, of the form (declare DECLS...) where | 159 | DECL is a declaration, optional, of the form (declare DECLS...) where |
| 159 | DECLS is a list of elements of the form (PROP . VALUES). These are | 160 | DECLS is a list of elements of the form (PROP . VALUES). These are |
| 160 | interpreted according to `defun-declarations-alist'. | 161 | interpreted according to `defun-declarations-alist'. |
| 162 | The return value is undefined. | ||
| 161 | 163 | ||
| 162 | \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)" | 164 | \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)" |
| 163 | ;; We can't just have `decl' as an &optional argument, because we need | 165 | ;; We can't just have `decl' as an &optional argument, because we need |
diff --git a/src/ChangeLog b/src/ChangeLog index 9a239de5b99..080748236b4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,8 +1,12 @@ | |||
| 1 | 2012-06-18 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * data.c (Fdefalias): Return `symbol' (bug#11686). | ||
| 4 | |||
| 1 | 2012-06-18 Martin Rudalics <rudalics@gmx.at> | 5 | 2012-06-18 Martin Rudalics <rudalics@gmx.at> |
| 2 | 6 | ||
| 3 | * buffer.c (Fkill_buffer): Don't throw an error when the buffer | 7 | * buffer.c (Fkill_buffer): Don't throw an error when the buffer |
| 4 | gets killed during executing of this function (Bug#11665). Try | 8 | gets killed during executing of this function (Bug#11665). |
| 5 | to always return Qt when the buffer has been actually killed. | 9 | Try to always return Qt when the buffer has been actually killed. |
| 6 | (Vkill_buffer_query_functions): In doc-string say that functions | 10 | (Vkill_buffer_query_functions): In doc-string say that functions |
| 7 | run by this hook should not change the current buffer. | 11 | run by this hook should not change the current buffer. |
| 8 | 12 | ||
| @@ -56,8 +60,8 @@ | |||
| 56 | (x_draw_glyph_string): Use them. | 60 | (x_draw_glyph_string): Use them. |
| 57 | * xfaces.c (Qline, Qwave): New Lisp objects. | 61 | * xfaces.c (Qline, Qwave): New Lisp objects. |
| 58 | (check_lface_attrs, merge_face_ref) | 62 | (check_lface_attrs, merge_face_ref) |
| 59 | (Finternal_set_lisp_face_attribute, realize_x_face): Handle | 63 | (Finternal_set_lisp_face_attribute, realize_x_face): |
| 60 | wave-style underline face attributes. | 64 | Handle wave-style underline face attributes. |
| 61 | * xterm.c (x_draw_underwave): New function. | 65 | * xterm.c (x_draw_underwave): New function. |
| 62 | (x_draw_glyph_string): Use it. | 66 | (x_draw_glyph_string): Use it. |
| 63 | 67 | ||
| @@ -130,8 +134,8 @@ | |||
| 130 | 134 | ||
| 131 | 2012-06-16 Eli Zaretskii <eliz@gnu.org> | 135 | 2012-06-16 Eli Zaretskii <eliz@gnu.org> |
| 132 | 136 | ||
| 133 | * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. If | 137 | * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. |
| 134 | all the glyphs of the glyph row came from strings, and we have no | 138 | If all the glyphs of the glyph row came from strings, and we have no |
| 135 | cursor positioning clues, put the cursor on the first glyph of the | 139 | cursor positioning clues, put the cursor on the first glyph of the |
| 136 | row. | 140 | row. |
| 137 | (handle_face_prop): Use chunk-relative overlay string index when | 141 | (handle_face_prop): Use chunk-relative overlay string index when |
| @@ -164,8 +168,8 @@ | |||
| 164 | Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined. | 168 | Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined. |
| 165 | (INTTYPEBITS): New macro, for clarity. | 169 | (INTTYPEBITS): New macro, for clarity. |
| 166 | (INTMASK, MOST_POSITIVE_FIXNUM): Use it. | 170 | (INTMASK, MOST_POSITIVE_FIXNUM): Use it. |
| 167 | (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): Simplify | 171 | (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): |
| 168 | now that USE_LSB_TAG is always defined. | 172 | Simplify now that USE_LSB_TAG is always defined. |
| 169 | (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast. | 173 | (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast. |
| 170 | (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler. | 174 | (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler. |
| 171 | 175 | ||
| @@ -183,11 +187,11 @@ | |||
| 183 | * lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct | 187 | * lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct |
| 184 | instead of union. | 188 | instead of union. |
| 185 | (XLI, XIL): Define. | 189 | (XLI, XIL): Define. |
| 186 | (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): Use | 190 | (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): |
| 187 | them. | 191 | Use them. |
| 188 | * emacs.c (gdb_use_struct): Renamed from gdb_use_union. | 192 | * emacs.c (gdb_use_struct): Rename from gdb_use_union. |
| 189 | * .gdbinit: Check gdb_use_struct instead of gdb_use_union. | 193 | * .gdbinit: Check gdb_use_struct instead of gdb_use_union. |
| 190 | * alloc.c (widen_to_Lisp_Object): Removed. | 194 | * alloc.c (widen_to_Lisp_Object): Remove. |
| 191 | (mark_memory): Use XIL instead of widen_to_Lisp_Object. | 195 | (mark_memory): Use XIL instead of widen_to_Lisp_Object. |
| 192 | * frame.c (delete_frame): Remove outdated comment. | 196 | * frame.c (delete_frame): Remove outdated comment. |
| 193 | * w32fns.c (Fw32_register_hot_key): Use XLI instead of checking | 197 | * w32fns.c (Fw32_register_hot_key): Use XLI instead of checking |
diff --git a/src/data.c b/src/data.c index 4449977dbe0..2aa27e65d77 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -637,8 +637,9 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, | |||
| 637 | Fput (symbol, Qautoload, XCDR (function)); | 637 | Fput (symbol, Qautoload, XCDR (function)); |
| 638 | 638 | ||
| 639 | XSYMBOL (symbol)->function = definition; | 639 | XSYMBOL (symbol)->function = definition; |
| 640 | /* Handle automatic advice activation */ | 640 | /* Handle automatic advice activation. */ |
| 641 | if (CONSP (XSYMBOL (symbol)->plist) && !NILP (Fget (symbol, Qad_advice_info))) | 641 | if (CONSP (XSYMBOL (symbol)->plist) |
| 642 | && !NILP (Fget (symbol, Qad_advice_info))) | ||
| 642 | { | 643 | { |
| 643 | call2 (Qad_activate_internal, symbol, Qnil); | 644 | call2 (Qad_activate_internal, symbol, Qnil); |
| 644 | definition = XSYMBOL (symbol)->function; | 645 | definition = XSYMBOL (symbol)->function; |
| @@ -647,11 +648,12 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, | |||
| 647 | } | 648 | } |
| 648 | 649 | ||
| 649 | DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0, | 650 | DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0, |
| 650 | doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. | 651 | doc: /* Set SYMBOL's function definition to DEFINITION. |
| 651 | Associates the function with the current load file, if any. | 652 | Associates the function with the current load file, if any. |
| 652 | The optional third argument DOCSTRING specifies the documentation string | 653 | The optional third argument DOCSTRING specifies the documentation string |
| 653 | for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string | 654 | for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string |
| 654 | determined by DEFINITION. */) | 655 | determined by DEFINITION. |
| 656 | The return value is undefined. */) | ||
| 655 | (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) | 657 | (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) |
| 656 | { | 658 | { |
| 657 | CHECK_SYMBOL (symbol); | 659 | CHECK_SYMBOL (symbol); |
| @@ -666,7 +668,10 @@ determined by DEFINITION. */) | |||
| 666 | LOADHIST_ATTACH (Fcons (Qdefun, symbol)); | 668 | LOADHIST_ATTACH (Fcons (Qdefun, symbol)); |
| 667 | if (!NILP (docstring)) | 669 | if (!NILP (docstring)) |
| 668 | Fput (symbol, Qfunction_documentation, docstring); | 670 | Fput (symbol, Qfunction_documentation, docstring); |
| 669 | return definition; | 671 | /* We used to return `definition', but now that `defun' and `defmacro' expand |
| 672 | to a call to `defalias', we return `symbol' for backward compatibility | ||
| 673 | (bug#11686). */ | ||
| 674 | return symbol; | ||
| 670 | } | 675 | } |
| 671 | 676 | ||
| 672 | DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, | 677 | DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, |