How to show Backtrace for emacs? - scala

I encounter an error:
scala-block-indentation: Wrong type argument: number-or-marker-p, nil
Whenever I click tab for indent in scala-mode.
I don't know where goes wrong in the code but want to fix it. However, I can only see this error in *Message* buffer without details. I tried to see this error in Backtrace but didn't know how. I tried (1) -debug-init to launch emacs (2) debug-on-entry command for scala-block-indentation but neither of them works.
Does anyone have ideas about how to enable BackTrace/Debugger for this function?

I have not used scala under emacs to tell if this can help you. But try (setq debug-on-error t) in your .emacs, or simply do M-: (setq debug-on-error t) to try for the current emacs session only.

Related

Determining why self-insert-command using commands for wrong mode

My emacs is somehow getting misconfigured, so that SPC in non-C modes is trying to do C-mode stuff. If I set debug-on-error to true and press space in a shell buffer, I get this backtrace.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
looking-at(nil)
c-state-semi-safe-place(465791)
c-literal-limits(nil nil)
c-mask-paragraph(nil t do-auto-fill)
c-do-auto-fill()
self-insert-command(1)
call-interactively(self-insert-command nil nil)
command-execute(self-insert-command)
I do not have a good way to reproduce it, but it happens fairly consistently when I load my (large, complicated) .emacs and work for a few hours.
It is entirely possible that I set something wrong in my .emacs, or it could be one of the packages I've recently added. I can probably figure out the problem if I know where to look. However, debug-when-behavior-of-space-command-is-changed does not seem to be a built-in option.
What are good options for figuring out what is changing the behavior of self-insert-command?
I am using:
GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
of 2015-04-10 on builder10-9.porkrind.org

Emacs tramp causes stack overflow

I am using emacs version 24.4.2. For some reason, i cannot use tramp at all. Any attempt to do so, i.e. trying to type /sudo:: causes a small hang of application followed by the following error in messages buffer:
expand-file-name: Lisp nesting exceeds `max-lisp-eval-depth'
What can i do to fix that error or diagnose it properly?
Update: Debugging shows the source of a problem is ido. Currently it is set up with following:
(setq ido-everywhere t)
(ido-mode t)
(setq ido-enable-flex-matching t)
Set debug-on-error to non-nil. See what function called expand-file-name, producing the error. Then try M-x debug-on-entry F, where F is that function, and step through the debugger with d to see what happens. Look at the code defining that function, in another window, while using the debugger.
You can also try, first, seeing whether you get the same broken behavior when you start Emacs without your init file: emacs -Q. If not, then recursively bisect your init file to find out what part of it introduces the problem.
My crystal ball is whispering to me that you have advised a function in such a way that it ends up, directly or indirectly, calling itself.

Publishing website using org-mode gives void function error

I am trying to create a website using org-mode from here. Having set everything up, when I go to the end of the line (require 'org-publish) and press C-x C-e, I get the following error,
Debugger entered--Lisp error: (void-function org-defvaralias)
org-defvaralias(org-agenda-filter-preset org-agenda-tag-filter-preset)
It seems that the function org-defvaralias is void. How do I fix this?
Looks like that's a function defined in org-compat.el; try M-: (require 'org-compat), which should load and execute that file if it's part of your Org-mode installation. (Emacs 24.3, Org 7.9.3f, does appear to include it, so if you're using a current Emacs, you should be good to go.)

Error: "wrong-number-of-arguments quote 0" when opening files with ".txt" extension

Every time I try to create or visit a file with a ".txt" extension, I get a stack trace like the following:
Debugger entered--Lisp error: (wrong-number-of-arguments quote 0)
quote()
set-auto-mode-0(quote nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(#<buffer file.txt> "~/path/to/file.txt" nil nil "~/path/to/file.txt" (24122033 2049))
find-file-noselect("/home/me/path/to/file.txt" nil nil)
ido-file-internal(raise-frame)
ido-find-file()
call-interactively(ido-find-file nil nil)
The buffer "file.txt" is open, however, in fundamental mode. This happens whether I use ido_find-file or M-x find file.
I tried to fix this by adding the following line in my init.el file:
(add-to-list 'auto-mode-alist '("\\.txt$" . text-mode))
...and I've changed the txt to [tT][xX][tT], switched out a \\' for the $, and tried fundamental-mode instead of text-mode; but no combination of changes seems to make the error go away.
I'm working with GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2), on xubuntu linux.
I presume the error starts with set-auto-mode(), but I don't know that for sure, and I don't know why the parens would be empty there. Has anyone else had this problem, or know what I'm doing wrong here?
If it's an auto-mode-alist issue, evaluate the following to confirm which mode Emacs is getting from that:
(assoc-default "foo.txt" auto-mode-alist 'string-match)
If it's nil, that's certainly the problem, and you do have a problem with your auto-mode-alist configuration.
It's probably not that, though -- there are a bunch of other things Emacs tries in set-auto-mode, so you likely need to narrow it down.
Try this:
M-x find-library RET files RET
M-x eval-buffer RET
C-xC-f foo.txt RET
Having evaluated the functions (n.b. you could really just evaluate set-auto-mode), you should now get a far more detailed stack trace when you hit the debugger, so you'll be able to figure out exactly where in set-auto-mode the call to set-auto-mode-0 is happening, and consequently which mechanism is resulting in a nil value for the major mode symbol.
(If you're unsure how to proceed from there, paste the stack trace into the question.)
I suspect that the problem is coming from a faultly local variables declaration in your file /home/me/path/to/file.txt. Do you have a local variables declaration in that file, and does it perhaps contain a quote (') that should not be there?
But I agree with the good advice that #phils gave, for tracking this down. There are a few different ways in which set-auto-mode can try to determine the mode. You will need to find out which one was being used (unless perhaps my guess helps).

Emacs: number-or-marker-p error

Some times when I mess up with icicles, dired, sunrise commander or some other guy -
number-or-marker-p
error pops up - and it nearly blocks emacs - no query-find-replace works, no ido any more. The only way - is to restart emacs. Does any body have a way to make emacs forget this error?
What should it do instead of issuing an error? Let's say you try M-x query-find-replace and this error happens. Should the operation just silently do nothing? At least with the error you know that something has gone wrong.
Either stop what you're doing that is breaking things, or fix (get it fixed) the underlying problem.
To start the process of fixing the bug, try setting debug-on-error to t, triggering the error and looking at the stack trace. Or add this to your .emacs:
(setq debug-on-error t)
Update the question with the backtrace and start again...