summaryrefslogtreecommitdiff
path: root/devdocs/elisp/compiler-errors.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/compiler-errors.html
new repository
Diffstat (limited to 'devdocs/elisp/compiler-errors.html')
-rw-r--r--devdocs/elisp/compiler-errors.html24
1 files changed, 24 insertions, 0 deletions
diff --git a/devdocs/elisp/compiler-errors.html b/devdocs/elisp/compiler-errors.html
new file mode 100644
index 00000000..9724b6ae
--- /dev/null
+++ b/devdocs/elisp/compiler-errors.html
@@ -0,0 +1,24 @@
+ <h3 class="section">Compiler Errors</h3> <p>Error and warning messages from byte compilation are printed in a buffer named <samp>*Compile-Log*</samp>. These messages include file names and line numbers identifying the location of the problem. The usual Emacs commands for operating on compiler output can be used on these messages. </p> <p>When an error is due to invalid syntax in the program, the byte compiler might get confused about the error’s exact location. One way to investigate is to switch to the buffer <samp> *Compiler Input*</samp>. (This buffer name starts with a space, so it does not show up in the Buffer Menu.) This buffer contains the program being compiled, and point shows how far the byte compiler was able to read; the cause of the error might be nearby. See <a href="syntax-errors">Syntax Errors</a>, for some tips for locating syntax errors. </p> <p>A common type of warning issued by the byte compiler is for functions and variables that were used but not defined. Such warnings report the line number for the end of the file, not the locations where the missing functions or variables were used; to find these, you must search the file manually. </p> <p>If you are sure that a warning message about a missing function or variable is unjustified, there are several ways to suppress it: </p> <ul> <li> You can suppress the warning for a specific call to a function <var>func</var> by conditionalizing it on an <code>fboundp</code> test, like this: <div class="example"> <pre class="example">(if (fboundp '<var>func</var>) ...(<var>func</var> ...)...)
+</pre>
+</div> <p>The call to <var>func</var> must be in the <var>then-form</var> of the <code>if</code>, and <var>func</var> must appear quoted in the call to <code>fboundp</code>. (This feature operates for <code>cond</code> as well.) </p> </li>
+<li> Likewise, you can suppress the warning for a specific use of a variable <var>variable</var> by conditionalizing it on a <code>boundp</code> test: <div class="example"> <pre class="example">(if (boundp '<var>variable</var>) ...<var>variable</var>...)
+</pre>
+</div> <p>The reference to <var>variable</var> must be in the <var>then-form</var> of the <code>if</code>, and <var>variable</var> must appear quoted in the call to <code>boundp</code>. </p> </li>
+<li> You can tell the compiler that a function is defined using <code>declare-function</code>. See <a href="declaring-functions">Declaring Functions</a>. </li>
+<li> Likewise, you can tell the compiler that a variable is defined using <code>defvar</code> with no initial value. (Note that this marks the variable as special, i.e. dynamically bound, but only within the current lexical scope, or file if at top-level.) See <a href="defining-variables">Defining Variables</a>. </li>
+</ul> <p>You can also suppress compiler warnings within a certain expression using the <code>with-suppressed-warnings</code> macro: </p> <dl> <dt id="with-suppressed-warnings">Special Form: <strong>with-suppressed-warnings</strong> <em>warnings body…</em>
+</dt> <dd>
+<p>In execution, this is equivalent to <code>(progn <var>body</var>...)</code>, but the compiler does not issue warnings for the specified conditions in <var>body</var>. <var>warnings</var> is an associative list of warning symbols and function/variable symbols they apply to. For instance, if you wish to call an obsolete function called <code>foo</code>, but want to suppress the compilation warning, say: </p> <div class="lisp"> <pre class="lisp">(with-suppressed-warnings ((obsolete foo))
+ (foo ...))
+</pre>
+</div> </dd>
+</dl> <p>For more coarse-grained suppression of compiler warnings, you can use the <code>with-no-warnings</code> construct: </p> <dl> <dt id="with-no-warnings">Special Form: <strong>with-no-warnings</strong> <em>body…</em>
+</dt> <dd>
+<p>In execution, this is equivalent to <code>(progn <var>body</var>...)</code>, but the compiler does not issue warnings for anything that occurs inside <var>body</var>. </p> <p>We recommend that you use <code>with-suppressed-warnings</code> instead, but if you do use this construct, that you use it around the smallest possible piece of code to avoid missing possible warnings other than one you intend to suppress. </p>
+</dd>
+</dl> <p>Byte compiler warnings can be controlled more precisely by setting the variable <code>byte-compile-warnings</code>. See its documentation string for details. </p> <p>Sometimes you may wish the byte-compiler warnings to be reported using <code>error</code>. If so, set <code>byte-compile-error-on-warn</code> to a non-<code>nil</code> value. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Compiler-Errors.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiler-Errors.html</a>
+ </p>
+</div>