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
30
votes
4answers
6k 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 ...
16
votes
1answer
4k 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 ...
15
votes
1answer
5k 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 ...
14
votes
2answers
526 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 ...
14
votes
3answers
437 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
2answers
342 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
1answer
433 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
155 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 ...
12
votes
2answers
2k 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' ...
8
votes
1answer
140 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
504 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-...
8
votes
1answer
944 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
1k 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
658 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
436 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
233 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
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 () (...
6
votes
2answers
111 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
158 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
109 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
2answers
541 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’ ...
5
votes
1answer
204 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
1answer
487 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 ...
5
votes
1answer
244 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 ...
4
votes
2answers
101 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
517 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
186 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
174 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
157 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
1answer
181 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
309 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
116 views

Which Lisp objects are byte-compiled?

A compiled program and a source code can be interpreted differently at runtime. The issue is that some Lisp objects should not be modified because of the byte-compilation. Emacs Lisp manual: 2.7 ...
4
votes
0answers
1k 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
46 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
242 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
607 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
142 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
291 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
80 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
75 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
1answer
495 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 () ...
3
votes
1answer
32 views

Avoiding warnings of undefined functions while compiling

I have a lot of code in my init file like this: (when library-is-available ;; Code that use that uses functions from library ) However, I get warnings that the functions that I am using are not ...
3
votes
1answer
184 views

Make a variable visible to some functions only

Consider the following metacode: ;;; -*- lexical-binding: t -*- (defvar var1 ...) (defvar var2 ...) (defun main () "Main entry point" ...) (defun func1 ...) (defun func2 ...) ... (defun funcn ...)...
3
votes
2answers
136 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
147 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
342 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
3answers
552 views

error: Invalid byte opcode: op=183, ptr=2

I byte-compile my ~/.emacs.d/init.el. It was done by Emacs 26.1 from Cygwin and I got error when load emacs-nox 25.2 from Debian WSL: error: Invalid byte opcode: op=183, ptr=2 Were new opcodes ...
2
votes
1answer
416 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
498 views

Fixing “reference/assignment to free variable” warning during compilation if variable is dynamically bounded

For: (defun my-ag/font-lock-extend-region () (save-excursion (goto-char font-lock-beg) (forward-line 2) (setq font-lock-beg (point)))) I've got: Warning: reference to free variable '...
2
votes
1answer
145 views

*Compile-log* buffer warning

I am a newbie to Emacs Lisp. started Emacs and the *Compile-log* buffer shows the following logs which I don't have much clue of. I was trying to install Magit and Helm. should anything in this log ...