diff options
Diffstat (limited to 'devdocs/elisp/wrong-time.html')
| -rw-r--r-- | devdocs/elisp/wrong-time.html | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/wrong-time.html b/devdocs/elisp/wrong-time.html new file mode 100644 index 00000000..af78f3a1 --- /dev/null +++ b/devdocs/elisp/wrong-time.html @@ -0,0 +1,14 @@ + <h4 class="subsection">Wrong Time</h4> <p>The most common problem in writing macros is doing some of the real work prematurely—while expanding the macro, rather than in the expansion itself. For instance, one real package had this macro definition: </p> <div class="example"> <pre class="example">(defmacro my-set-buffer-multibyte (arg) + (if (fboundp 'set-buffer-multibyte) + (set-buffer-multibyte arg))) +</pre> +</div> <p>With this erroneous macro definition, the program worked fine when interpreted but failed when compiled. This macro definition called <code>set-buffer-multibyte</code> during compilation, which was wrong, and then did nothing when the compiled package was run. The definition that the programmer really wanted was this: </p> <div class="example"> <pre class="example">(defmacro my-set-buffer-multibyte (arg) + (if (fboundp 'set-buffer-multibyte) + `(set-buffer-multibyte ,arg))) +</pre> +</div> <p>This macro expands, if appropriate, into a call to <code>set-buffer-multibyte</code> that will be executed when the compiled program is actually run. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Wrong-Time.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Wrong-Time.html</a> + </p> +</div> |
