79
votes
Accepted
What do I do when Emacs is frozen?
When C-g doesn't work, you can sometimes get control back with:
pkill -SIGUSR2 emacs
As @Archenoth points out, sending the SIGUSR2 signal to Emacs turns on debug-on-quit. This can be useful, but you'...
37
votes
debugging some elisp -- "end of file during parsing error" in init.el
The "end of file during parsing" error means that you have not closed a paren.
To debug this, you should
Do M-x check-parens RET to pinpoint the location of the current error.
Enable show-paren-mode ...
34
votes
Accepted
How do I troubleshoot Emacs problems?
Step 1: running emacs -Q
The first thing you need to do is run emacs without any of your customizations. If you can reproduce the problem in vanilla Emacs, it may actually be a bug in Emacs itself. ...
26
votes
Accepted
How do I debug `Package cl is deprecated`?
Try the following in an Emacs session with the code in question loaded up:
(require 'loadhist)
(file-dependents (feature-file 'cl))
21
votes
Accepted
How to cancel `edebug-defun`?
From (info "(elisp) Instrumenting") :
To remove instrumentation from a definition, simply re-evaluate its
definition in a way that does not instrument. There are two ways of
evaluating forms that ...
15
votes
Accepted
Wrong number of arguments on lambda key binding
“Wrong number of arguments: (1 . 2), 0” means that a function expects at least 1 and at most 2 arguments (i.e. 1 mandatory and 1 optional argument), but it was called with 0 arguments.
As npostavs ...
12
votes
How to fix "Symbol's function definition is void: org-babel-get-header"
According to https://lists.gnu.org/archive/html/emacs-orgmode/2015-11/msg00425.html ob-sh was renamed ob-shell in org 8.2 ... and I cite from there:
org-babel-get-header was removed in 0d000f5 (...
11
votes
Accepted
Error void-variable on function name
Short Answer
Replace func2 with #'func2:
(defun func2 (arg)
(if (listp arg)
(mapcar #'func2 arg)
arg))
Explanation
Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, ...
11
votes
Accepted
Melpa - 'Failed to download melpa'
The error seems to be saying that ((\, "http://melpa.org/packages/")) doesn't match the regex "\`https?:"
Let's look at that value, the one being added to package-archives:
'("melpa", "http://melpa....
10
votes
Why expression fails in init file, but works fine during session
I believe it is standard practice for themes installed as packages to add their own paths to custom-theme-load-path as an autoload. A call to package-initialize will execute all of your package ...
10
votes
How to cancel `edebug-defun`?
In other words, how do I rescind the directive that causes edebug to enter debugging mode when a particular function is invoked?
You can get this effect without removing instrumentation by setting ...
10
votes
Accepted
Tracking down a write to a variable
This is still under development, but in Emacs 26.1 (assuming nothing goes wrong) you will be able to do M-x debug-watch <variable> RET and then any change to the variable will land in the ...
10
votes
Accepted
Packages I never knew they existed cause problems
There was an issue with the latest straight.el commit.
https://github.com/doomemacs/doomemacs/issues/6960
One way to fix it, is to update straight repo and getting latest
version of straight , that ...
9
votes
How to debug startup problem, if `--debug-init' has no effect
You can use elisp-bug-hunter to automatically bisect your init file.
Automated error hunting
If your Emacs init file signals an error during startup, but you don’t
know why, simply issue
...
9
votes
Accepted
Debug an elisp error - show call stack when an error occurs
Use M-x set-variable RET debug-on-error RET t RET.
(Or M-: (setq debug-on-error t).)
That will open the debugger when the error is raised. You can see who called that recentf-mode, what arguments it ...
8
votes
Accepted
How to fix this startup package initialization problem?
The "misbehaving" file ~/.emacs.d/elpa/archives/gnu/archive-contents was most likely overwritten by HTML content of a page reporting a connection error. It should be safe to remove it. Emacs will ...
8
votes
Show line number on error
Maybe because it's 2018 now, but in my case,
I only had to turn on debugging like wasamasa suggested:
M-x toggle-debug-on-error
After this, M-x eval-buffer on my faulty Elisp file
gave context ...
8
votes
Can't get out of minibuffer completion
Is it possible there is an active recursive edit in the completion minibuffer? C-] by default is abort-recursive-edit. Alternatively keyboard-escape-quit or ESC ESC ESC might help?
8
votes
Accepted
Multiple URL formats for bug-reference-mode
Update
Starting with Emacs 28, bug-reference is able to automatically detect and configure itself for Git forges including GitHub and GitLab. Quoth (info "(emacs) Bug Reference"):
[...]
...
8
votes
Accepted
Surprisingly persistent local variable
In case someone else runs into this, I had enabled TeX-auto-save, which saves settings to an auto/ directory and loads them when a file is revisited.
https://www.gnu.org/software/auctex/manual/...
8
votes
Accepted
Is there any way to get the memory size (usage) of a Lisp variable/value?
Is there any way to get the memory size/usage of a variable?
Emacs 28 adds a more fine-grained memory usage reporting command than was previously available:
** New command 'memory-report'.
This ...
7
votes
Accepted
Why expression fails in init file, but works fine during session
From the emacs manual regarding packages:
By default, Emacs also automatically loads all installed packages in
subsequent Emacs sessions. This happens at startup, after processing
the init ...
7
votes
Accepted
Navigate to the source code of built-in functions and variables
The reason you sometimes see “interactive compiled Lisp function” (or likewise for variables) with no file name is that the function was loaded from a byte-compiled file and the corresponding Elisp ...
7
votes
Accepted
How to solve "Autoloading failed to define function sml-mode"?
This is a problem of conflicting libraries in load-path.
I think you should inspect your load-path to see if you have sml-mode directory in it twice. The first directory probably doesn't contain a ...
7
votes
How to see *Messages* buffer in Spacemacs?
It's just a buffer, so any of the numerous methods of switching to a buffer can be used.
For example, using standard Emacs key sequences:
C-xb *Messages* RET
C-xC-b and select *Messages*
M-x ibuffer ...
7
votes
Accepted
Can emacs show formatted backtraces?
Is there a way to get a pretty-printed backtrace buffer?
There is, but you'll have to wait for Emacs 27 to be released or get a build of it in the meantime. Quoth its etc/NEWS file:
* Changes in ...
6
votes
detecting obsolete/deprecated settings in elisp files, particularly .emacs
Others will no doubt add more info to help answer this.
I'll mention a few things that come to mind.
`M-x customize-changed' shows you a Customize buffer that tells you about stuff that has changed ...
6
votes
How to write assertions
Here's an assert macro in elisp based on an expert's advice on emacs mailing list:
(defmacro assert (test-form)
`(when (not ,test-form)
(error "Assertion failed: %s" (format "%s" ',test-form)))...
6
votes
Accepted
Signaling a breakpoint in Emacs Lisp
Add (debug) and you'll be thrown into a buffer showing you the backtrace and where you can examine the current state.
See: Emacs Manual "Explicit Entry to the Debugger"
6
votes
Accepted
Trace calls to a function with the parameters
The easiest way to find out the arguments passed to a function is to use M-x trace-function RET name-of-your-function RET. Once you're done, use M-x untrace-function or M-x untrace-all.
Note that ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
debugging × 536init-file × 43
org-mode × 39
python × 26
edebug × 19
debug × 18
variables × 17
package × 16
key-bindings × 15
spacemacs × 14
gdb × 14
gud × 13
backtrace × 13
buffers × 12
start-up × 11
error × 11
org-babel × 10
microsoft-windows × 10
tramp × 10
error-handling × 10
osx × 9
c++ × 9
performance × 9
latex × 8
auctex × 8