diff options
| author | Eli Zaretskii | 2023-01-07 19:57:30 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2023-01-07 19:57:30 +0200 |
| commit | 0cb686ffb6bbc017d3b71acbf40ed3e5c1a32863 (patch) | |
| tree | 101436bb61ce4ad76c042efbdcde3581a6c7c2ea | |
| parent | 7f855b5297b2806fa508e73de98cb8cecc6e7d8d (diff) | |
| download | emacs-0cb686ffb6bbc017d3b71acbf40ed3e5c1a32863.tar.gz emacs-0cb686ffb6bbc017d3b71acbf40ed3e5c1a32863.zip | |
Document the 'definition-name' property.
* doc/lispref/symbols.texi (Standard Properties): Document
'definition-name'.
* doc/lispref/functions.texi (Defining Functions): Describe how to
use 'definition-name' when generating function definitions at run
time. (Bug#60568)
| -rw-r--r-- | doc/lispref/functions.texi | 14 | ||||
| -rw-r--r-- | doc/lispref/symbols.texi | 17 |
2 files changed, 31 insertions, 0 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 3a8eddb93ea..f5572e447d3 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -685,6 +685,20 @@ Here are some examples: | |||
| 685 | @end group | 685 | @end group |
| 686 | @end example | 686 | @end example |
| 687 | 687 | ||
| 688 | @cindex defining functions dynamically | ||
| 689 | Most Emacs functions are part of the source code of Lisp programs, and | ||
| 690 | are defined when the Emacs Lisp reader reads the program source before | ||
| 691 | executing it. However, you can also define functions dynamically at | ||
| 692 | run time, e.g., by generating @code{defun} calls when your program's | ||
| 693 | code is executed. If you do this, be aware that Emacs's Help | ||
| 694 | commands, such as @kbd{C-h f}, which present in the @file{*Help*} | ||
| 695 | buffer a button to jump to the function's definition, might be unable | ||
| 696 | to find the source code because generating a function dynamically | ||
| 697 | usually looks very different from the usual static calls to | ||
| 698 | @code{defun}. You can make the job of finding the code which | ||
| 699 | generates such functions easier by using the @code{definition-name} | ||
| 700 | property, @pxref{Standard Properties}. | ||
| 701 | |||
| 688 | @cindex override existing functions | 702 | @cindex override existing functions |
| 689 | @cindex redefine existing functions | 703 | @cindex redefine existing functions |
| 690 | Be careful not to redefine existing functions unintentionally. | 704 | Be careful not to redefine existing functions unintentionally. |
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index 183367c0cda..5b53cbe310a 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi | |||
| @@ -555,6 +555,23 @@ value, saved value, customized-but-unsaved value, and themed values. | |||
| 555 | Do not set them directly; they are managed by @code{defcustom} and | 555 | Do not set them directly; they are managed by @code{defcustom} and |
| 556 | related functions. @xref{Variable Definitions}. | 556 | related functions. @xref{Variable Definitions}. |
| 557 | 557 | ||
| 558 | @item definition-name | ||
| 559 | This property is used to find the definition of a symbol in the source | ||
| 560 | code, when it might be hard to find the definition by textual search | ||
| 561 | of the source file. For example, a @code{define-derived-mode} | ||
| 562 | (@pxref{Derived Modes}) might define a mode-specific function or a | ||
| 563 | variable implicitly; or your Lisp program might generate a run-time | ||
| 564 | call to @code{defun} to define a function (@pxref{Defining | ||
| 565 | Functions}). In these and similar cases, the @code{definition-name} | ||
| 566 | property of the symbol should be another symbol whose definition can | ||
| 567 | be found by textual search and whose code defines the original symbol. | ||
| 568 | In the example with @code{define-derived-mode}, the value of this | ||
| 569 | property of the functions and variables it defines should be the mode | ||
| 570 | symbol. The Emacs Help commands such as @kbd{C-h f} (@pxref{Help,,, | ||
| 571 | emacs, The GNU Emacs Manual}) use this property to show the definition | ||
| 572 | of a symbol via a button in the @file{*Help*} buffer where the | ||
| 573 | symbol's documentation is shown. | ||
| 574 | |||
| 558 | @item disabled | 575 | @item disabled |
| 559 | If the value is non-@code{nil}, the named function is disabled as a | 576 | If the value is non-@code{nil}, the named function is disabled as a |
| 560 | command. @xref{Disabling Commands}. | 577 | command. @xref{Disabling Commands}. |