Questions tagged [byte-compilation]

is for the Emacs Lisp compiler in Emacs that compiles lisp code to byte-code for faster execution compared to uncompiled lisp code. Byte-compiled code is read by the byte-code interpreter.

Filter by
Sorted by
Tagged with
27
votes
4answers
4k views

Can I avoid outdated byte-compiled elisp files?

Occasionally, when I start Emacs, I get a message like. Source file `/home/USER/.emacs.d/elpa/....el' newer than byte-compiled file Also, I sometimes edit a package I'm developing and forget to ...
15
votes
2answers
477 views

Can a function or macro specify byte-compiler warnings?

I'm writing a function which, in principle, takes an arbitrary number of arguments. In practice, however, it should only ever be passed an even number of arguments, and will produce undesirable ...
13
votes
2answers
308 views

Are macros expanded when the file is compiled?

I have a macro that needs to be expanded at every single instance of its use compile-time. Is there a way I can specify this to be so without going through the codebase and carefully wrapping each ...
13
votes
3answers
253 views

Defun inside let with lexical binding gives byte-compile warning “the function is not known to be defined”

I want to get the effect of a static variable by using defun inside of let with lexical binding to create a closure. However, when byte-compiling the file, I get a warning. Am I doing something wrong, ...
13
votes
1answer
3k views

suppress warning: assignment to free variable (and others)

How can I suppress the "assignment to free variable" warning when byte compiling an emacs lisp file? I'm actually mostly interested in suppressing it for a specific buffer when using flycheck, but I ...
13
votes
1answer
360 views

Macro with defcustom leads to “Symbol's value as variable is void” error when byte-compiled

In two of my packages I have a macro where the body depends on a variable defined in a defcustom form. When installing the packages from Melpa, the byte-compilation ends with: Error: Symbol's ...
12
votes
2answers
131 views

byte compiled version of elisp files

I have both .el and the byte compiled version (.elc) of an elisp file. Accidentally I delete the .el file. Can I retrieve the .el file from its .elc version? Is an .elc file without its .el file ...
10
votes
2answers
1k views

`Warning (bytecomp)` is a bit vague - can I get any more information?

When I start emacs, I get a couple of byte compilation warnings in a window that pops up: Warning (bytecomp): `interactive-p' is an obsolete function (as of 23.2); use `called-interactively-p' ...
9
votes
1answer
2k views

Dealing with “Warning: assignment to free variable” when certain libraries can be missing by design

Byte compilation of my mode: (defun dict-setup-expansions () "Add `dict-mode' specific expansions." (set (make-local-variable 'er/try-expand-list) (list #'dict-mark-article))) gives warning: ...
8
votes
1answer
119 views

Why is Emacs asking me to save changed buffers, when I install a package?

Every time when I change something in a buffer, and then I decided to install a package from packages.el, Emacs is repeatingly asking me if I want to save the other buffers, because it's changed. I ...
8
votes
1answer
326 views

eval-when-compile: defsubst vs defmacro vs define-inline

I defined some simple functions in init.el, for example my-cache-file: (defconst my-cache-directory (expand-file-name ".cache" user-emacs-directory)) ; ~/.emacs/.cache (defun my-cache-file (x) (...
8
votes
1answer
619 views

How do I run multiple versions of Emacs with the same .emacs.d

I alternatively run 24.5 and 25.0.50. Unfortunately, packages installed and compiled from 25.0.50 don't work with Emacs 24.5 (cl-struct-define is a common culprit). One trivial solution is to not ...
7
votes
2answers
750 views

Performance differences in comparing symbols and strings

In sx.el, we have a case where we need to verify if we've passed GET or POST as an argument. Currently we have the argument passing as a string and are using (string= "GET" url-method) to compare it ...
7
votes
3answers
634 views

Byte-compilation of a multi-file package: “the function is not known to be defined”

Imagine that I have the following files in my (ridiculous) package: File test1.el: ;;; test1.el --- ;;; Code: (defvar test-var1) (defun test-fun1 (test) nil) ...
6
votes
1answer
405 views

Recursive load error in csharp mode on upgrading to 24.4

I'm on OSX 10.9.4 and I was previously running emacs 24.3 installed via brew. This morning I got around to asking brew to upgrade me to 24.4. Everything seemed to go smoothly, except csharp-mode no ...
6
votes
1answer
171 views

package.el: How can I avoid byte-compilation

How can I tell package.el to not byte-compile? It is generally OK to byte-compile installed packages but it makes difficult to test a new Emacs with byte compiler improvements (such as Emacs 26 from ...
6
votes
2answers
95 views

Byte-compiling a file against a package that may or may not be here

I am trying to include support for smartparens in a major-mode package. I want that if a user is using smartparens, then he will get additional pair definitions, and if he isn't, he will not notice ...
6
votes
1answer
120 views

Can the byte-compiler warn me about unused variables?

I've just finished a pretty significant refactoring; byte-compiler warnings were a great way to quickly find errors, without even running tests. Still, there's one kind of code smell that the byte-...
6
votes
0answers
91 views

How to build Emacs without byte-compiling Lisp files

Q:  Is there an option to build Emacs without byte-compiling the Lisp files? BACKGROUND:  The length of time needed to build Emacs makes debugging / developing an extremely slow process. For example,...
5
votes
1answer
165 views

How can I make Emacs warn about calls to my pure functions?

Emacs' byte-compiler can tell me if I call pure functions without saving the result: (defun foo-calls-add () ;; value returned from (+ 1 2) is unused: (+ 1 2) 12) However, I don't get any ...
5
votes
2answers
2k views

Debugging “Warning: Reference to free variable”

I have something like below (from the answer) in my init file: (add-hook 'LaTeX-mode-hook 'my-latex-hook) (defun my-latex-hook () (require 'tex-site) (define-key LaTeX-mode-map "-" (lambda () (...
5
votes
1answer
418 views

What does a byte compiled Emacs file contains and how is it executed?

I didn't know byte compiled emacs files (.elc) were actually version-specific until Malabarba pointed that to me. So this made me ask what do those files actually contain and how does their ...
4
votes
2answers
92 views

What compilers are used during installation of a package?

When I download and install auctex, I read that The simplest way of installing AUCTeX is by using the Emacs package manager integrated in Emacs 24 and greater (ELPA). Simply do M-x package-list-...
4
votes
1answer
396 views

Strange elisp byte-compiler warning about unused variables

The following elisp code inserts hello world! 10 times: -*- lexical-binding: t -*- (dotimes (i 10) (insert "hello world!\n")) If I byte-compile that code, I get the following message: hellos.el:2:1:...
4
votes
2answers
132 views

Prevent byte-compiler warnings after requiring features

In Elisp packages, we sometimes want to use a feature only if the user has installed another package without specifying that package as a dependency for our own. E.g. (when (require 'markdown-mode ...
4
votes
1answer
143 views

Which functions cannot be redefined after byte compilation?

Given a function that calls not: (defun my-not (x) (not x)) M-x disassemble gives: byte code for my-not: doc: ... args: (arg1) 0 dup 1 not 2 return I ...
4
votes
3answers
69 views

How do I get byte-compilation warnings about undefined variables?

The following code works fine with M-x eval-buffer, and byte-compiles without any warnings. (eval-when-compile (defconst demo-one 1)) (defvar demo-some-var `(foo bar ,demo-one)) However, if I ...
4
votes
2answers
278 views

Where are these variables defined? - bytecomp Warnings

Lately I'm getting warnings when compiling the .emacs Warning (bytecomp): reference to free variable ‘url-http-extra-headers’ Warning (bytecomp): reference to free variable ‘oauth--token-data’ ...
4
votes
1answer
97 views

Does package-install do byte-compilation?

When installing a package from the package menu, can/will package-install do automatic byte compilation of the installed package files? Or is this something the user must do manually himself ...
4
votes
1answer
293 views

How can I get lint warnings when I've forgotten to require a package?

Flycheck has a brilliant ability to warn about when I'm using a function foo-bar but have forgotten to add (require 'foo) at the top of my file. However, it's inconsistent. It doesn't always warn for ...
4
votes
0answers
922 views

byte-compile much slower in X (vs. -nw)

Setup Windows 10 host with X server (VcXsrv) Linux guest (Arch) in virtual machine (VMware) Benchmark (defmacro measure-time (&rest body) "Measure the time it takes to evaluate BODY." `(let ...
4
votes
0answers
35 views

A workflow for managing compiled elisp packages with different versions of emacs

I am using different versions of emacs, on different computers. On some of those (work computers) I don't really have a choice to update, whereas for my personal computers, I like to run the latest ...
4
votes
0answers
169 views

Is there an ELISP decompiler?

I'm thinking of writing one so that when I get those horrible tracebacks from bytecode files, I can better see where I was at. Is there one already? Are there any other tools for showing an error ...
3
votes
2answers
426 views

Where and when should emacs lisp files be byte-compiled?

Do you have examples of packages that benefit substantially from byte-compilation? I would prefer to avoid byte-compiling files when it is not necessary, in particular when installing hundreds of ...
3
votes
2answers
113 views

Can one inhibit eval-when-compile?

There is an eval-when-compile macro but, AFAICT, no eval-when-not-compiling or load-time-only, that would be very convenient for me now. Do you know any generic workaround? Why do I need this: I ...
3
votes
2answers
229 views

Disassembly of a bytecode *file*?

There is a disassembler for functions, but is there something that will disassemble a bytecode file? Thoughts on how to accomplish?
3
votes
1answer
69 views

How to get Emacs to know that a symbol has a function definition

While reading the source file prelude-ivy.el in the Prelude modules directory, I saw that there was a warning associated with "here" in the last line, specifically that prelude-required-packages was ...
3
votes
1answer
50 views

When I (byte-compile-file “my-package.el”), can I treat warnings as errors?

As part of CI testing, I'm byte-compiling package files to make sure there are no errors. I'd like to take this a step further and ensure there are no warnings, either (like 'function not known to be ...
3
votes
2answers
97 views

byte compile file-local variables

Is it possible to access a user-defined file-local variable during byte-compilation? As an example, I am trying to get this code to work: --- testfilelocals.el --- ;; -*- my-file-local: "foo" -*- (...
3
votes
2answers
90 views

byte-compile and lexical-binding

Could someone in the know please help me understand what's going on here: ;; -*- lexical-binding: t; -*- (let* ((a 0)) (let* ((a 1)) (funcall (byte-compile (lambda () a))))) ;;=> 0 wat? Not ...
3
votes
0answers
226 views

Byte-compiling a file loads macros with `(eval-and-compile)` but not `(eval-when-compile)`

I created a buffer, test1.el: (eval-when-compile (defmacro dummy-macro (_) nil) (dummy-macro s)) Trying to compile this file, I get the following errors: In toplevel form: test1.el:3:16:Warning:...
2
votes
1answer
253 views

Function might not be defined at runtim

To use directory-files-recursively in Emacs 24.x, I'm adding the following to a file cider-compat.el: (eval-and-compile (unless (fboundp 'directory-files-recursively) (defun directory-files-...
2
votes
1answer
345 views

How to specify the directory for file-exists/delete-file/byte-compile-file?

I thought it would be great to save a Elisp file (in my init), and it compiles automatically a byte-compile Elisp-file. So I wrote a function for this. (defun remove-elc-and-compile-on-save () ...
2
votes
1answer
155 views

Why are custom themes not usually byte-compiled?

Three pieces of evidence suggest custom themes should not be byte-compiled: All built-in themes under etc/themes specify no-byte-compile: t. The function custom-available-themes considers only .el ...
2
votes
1answer
102 views

What effect does eval-and-compile have on a defun-within-let?

The byte-compiler does not currently seem to recognise that a function has been defined when using defun within a let expression under lexical-binding, as explained in Stefan's answer to this question....
2
votes
0answers
55 views

byte-compiling in presence of pcase patterns

TIL that trying to compile anything with pcase matching in it may lead to an explosion of code generated during expansion. Even the most innocent looking patterns may generate hundreds of branches and ...
2
votes
0answers
231 views

How much faster is C than compiled elisp? [closed]

I'd like to write some lightning-fast functions for analyzing LaTeX code. Because they could involve a lot of complicated processing of large documents, I don't know whether it's a good idea to write ...
1
vote
2answers
51 views

byte compile warning: `unintern` called with 1 argument, but requires 2

Q:  How to fix elmo-unintern to use 2 arguments instead of 1, or silence the byte-compiler on this issue. Here is the macro definition: (defmacro elmo-unintern (string) "Delete the symbol named ...
1
vote
2answers
252 views

Does `load` prefer .elc files over .el files?

Do .elc files take precedence over .el files when using load? Say I have two files in my load path: foo.el and foo.elc. If I call (load "foo"), will the byte-compiled version (foo.elc) always be ...
1
vote
2answers
196 views

Recompile a .gz file in emacs' progmodes directory

c-electric-lt-gt in cc-cmds.el.gz treats > as a closing paren only if it isn't immediately followed by another >. This behaviour is incorrect for C++11 and I tried to modify it by changing the ...