Inserting citation with reftex-citation breaks Emacs buffer - emacs

I am trying to get started with RefTeX in Emacs 24.1.50.3, built --without-x. Running
(reftex-citation)
seems to work at first. I can enter a regex and get a list of matching citations in my bibliography. However, selecting an entry makes the buffer stops working. Attempting to navigate gives the following error
Debugger entered--Lisp error: (error "Marker does not point anywhere")
posn-at-point()
line-move-visual(1 nil)
line-move(1 nil nil 1)
byte-code("\302\303\211 $\207" [arg try-vscroll line-move nil] 5)
next-line(1 1)
call-interactively(next-line nil nil)
This should not be caused by my init.el, because it occurs even when I launch emacs with --no-site-files and enter (reftex-mode) manually.

Actually, --no-site-file does not inhibit your init.el file.
See C-hig (emacs) Initial Options RET
Start emacs -Q to be sure this is not being caused by non-standard libraries.
If so, then it sounds like a bug, in which case:
M-x report-emacs-bug RET

Related

Launch make and go to the error position by shortcuts within Emacs

I use Emacs to code. At the moment, to compile an OCaml project, I need to type make in a terminal. If there is an error, I have to go back to Emacs to find the erroneous file and location by following the error indication.
Now, I would like to launch make inside Emacs by a keyboard shortcut, which opens a buffer to show the compilation, then
1) if there is no error, then close the buffer automatically
2) if there is an error, another shortcut will lead me to the erroneous file and line within Emacs.
Does anyone know how to write .emacs to enable this mechanism?
PS: This is my current .emacs.
I have posted a question to compile one .tex file within Emacs by a shortcut (Ctrl + c + m + m), this works well. But in case of error, I don't ask it to lead me to the error position.
M-x compile RET
See the Emacs manual, node Compilation.
And see node Compilation Mode for how to visit error occurrences.
Some years back, I had the same question, here's the answer I got on the #emacs irc channel.
;; from enberg on #emacs
(setq compilation-finish-function
(lambda (buf str)
(if (null (string-match ".*exited abnormally.*" str))
;;no errors, make the compilation window go away in a few seconds
(progn
(run-at-time
"2 sec" nil 'delete-windows-on
(get-buffer-create "*compilation*"))
(message "No Compilation Errors!")))))
;; save the file when I press compile
(setq mode-compile-always-save-buffer-p t)

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

org-bibtex-yank fails with Wrong type argument: stringp, nil

Org 8.2.10
Emacs 24.4.1
I have a bibtex entry in the scratch buffer, then M-w the entry.
It's in the kill-ring
I then swap to an org-mode buffer and try
M org-bibtex-yank
I receive an error: Wrong type argument: stringp, nil
I've toggled-debug-on-error and the backtrace is below. I have checked that the entry is on the kill-ring - I can yank it to a scratch buffer.
I've set debug-on-entry for org-bibtex-yank, and went a long way down the rabbit hole! I can see the entry in some steps of the debugger, but got lost!
I'd be grateful for any pointers on either the problem, or getting more information that might help.
thanks
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
looking-at(nil)
bibtex-parse-entry()
org-bibtex-read()
org-bibtex-yank()
call-interactively(org-bibtex-yank record nil)
command-execute(org-bibtex-yank record)
execute-extended-command(nil "org-bibtex-yank")
smex-read-and-run(("toggle-debug-on-error" "org-bibtex-yank" "debug-on-entry" "describe-function" "apropos" "set-variable" "package-list-packages" "load-theme" "describe-variable" "bibtex-yank" "eshell" "package-refresh-contents" "yank" "org-mode" "org-bibtex" "flyspell-mode" "server-force-delete" "org-bibtex-read-buffer" "R" "S" "S+" "cd" "dm" "5x5" "S+3" "S+6" "SAS" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "pdb" "pwd" "rsh" "sdb" "xdb" "Sqpe" "calc" "diff" "dirs" "ffap" "gnus" ...))
smex()
call-interactively(smex nil nil)
command-execute(smex)
I know this issue "org-bibtex-yank fails with Wrong type argument: stringp, nil". Especially I can't paste an bibtex-entry from the web and paste it to an Org file via org-bibtex-yank.
My current work around:
Open in Emacs buffer for the bibtex mode. May be you use a dummy.bib
In bibtex-mode buffer call
M-x bibtex-set-dialect
Choose either bibtex or biblatex
Now I paste the bibtex-entry to the bib-file and check the behavior:
- Mark and copy via M-w a bibentry in the bibtex-mode buffer
- Change to your Org file
- Use there
M-x org-bibtex-yank.
Typically now it works.
The issue seems to be that bibtex-parse-entry requires that bibtex-set-dialect is called before calling it.
Unfortunately you can't do a (simple) file variable in a bibtex file.
M-x add-file-local-variable
for variable bibtex and value either bibtex or biblatex won't work.
As bibtex.el does not support this.
Try in Org file
# Local Variables:
# eval: (bibtex-set-dialect 'biblatex)
# End:
Try in bibtex file
M-x add-file-local-variable
and replace the line
bibtex: biblatex
by
eval: (bibtex-set-dialect 'biblatex)
Or read:
https://tex.stackexchange.com/questions/78455/does-emacs-support-editing-bibliography-files-for-biblatex

how to find syntax error in elisp

if this is a duplicate please delete.
I was just editing my .emacs file and after i had my changes done. I
restarted emacs. But whet it comes up again it claims that the config
file has some errors. And i should start with "--debug-init" thats what
i also have done. But it did not helped me to solve nor find the syntax error.
So is there a way to find the lines which have syntaxerror. Or even better if
there would be something like a (e)lisp lint like you have for e.g xml, json, js
and so on. Thanks in advance
Edit
Managed to get the dump:
Debugger entered--Lisp error: (void-variable whitespace-mode)
redisplay_internal\ \(C\ function\)()
delete-process(#<process server-client-test>)
Someunicodefoo" [("server") server-use-tcp server-auth-dir server-socket-dir generate-new-buffer " *temp*" funcall make-byte-code 0 "Someunicodefoo" vconcat vector [buffer-name kill-buffer] 2 "\n\n(fn)" insert-file-contents-literally expand-file-name looking-at "127\\.0\\.0\\.1:[0-9]+ \\([0-9]+\\)" comm process-attributes string-to-number match-string 1 t :other delete-process make-network-process :name "server-client-test" :family local :server nil :noquery :service] 14 "\n\n(fn)"])
server-running-p("server")
byte-code("Someunicodefoo" [load-file-name buffer-file-name recentf-menu-before user-emacs-directory recentf-save-file server-name add-to-list load-path file-name-directory "../packages" tool-bar-mode 0 load "ergoemacs-keybindings/ergoemacs-mode" ergoemacs-mode 1 "init_load_packages" "init_version" "init_functions" "init_settings" "init_aliases" "init_abbrevs-lisp-mode" "init_keybinding" "init_mouse" "init_clean_menus" require recentf "Close" ".recentf" recentf-mode server server-running-p t server-start] 4)
load("/home/dirk/.emacs.d/ergoemacs_1.9.3.1/site-lisp/../ergoemacs/init")
eval-buffer(#<buffer *load*-842275> nil "/home/dirk/.emacs.d/ergoemacs_1.9.3.1/site-lisp/site-start.el" nil t) ; Reading at buffer position 1432
load-with-code-conversion("/home/dirk/.emacs.d/ergoemacs_1.9.3.1/site-lisp/site-start.el" "/home/dirk/.emacs.d/ergoemacs_1.9.3.1/site-lisp/site-start.el" nil nil)
load("/home/dirk/.emacs.d/ergoemacs_1.9.3.1/site-lisp/site-start.el" nil nil t)
load-file("~/.emacs.d/ergoemacs_1.9.3.1/site-lisp/site-start.el")
eval-buffer(#<buffer *load*> nil "/home/dirk/.emacs" nil t) ; Reading at buffer position 2883
load-with-code-conversion("/home/dirk/.emacs" "/home/dirk/.emacs" t t)
load("~/.emacs" t t)
command-line()
normal-top-level()
One way to do it is to open the file and mark the first half of it and apply eval-region. If an error is reported, mark half of it and repeat. If an error isn't reported, apply it to the other half.
This way you could narrow down the problem and once you have found it you can hopefully figure out the problem.
Another technique I use to find incorrect parentheses is to add an extra parenthesis to the beginning and end of the file, respectively and run C-M-f and C-M-b from the beginning and end, respectively. If there are incorrect parentheses, they will match the newly added ones, and the point will move to the incorrect ones.
EDIT: You can use M-x check-parens to check for unmatched parentheses.
For "lint"-like checking, there's elint.el, but more importantly, there's the byte-compiler: M-x byte-compile-file RET lets you byte-compile a file and will give you all kinds of warnings about syntax and style.
But your backtrace indicates that the problem is probably not one of syntax. Most like there's a whitespace-mode that appears somewhere in a menu (i.e. in an :enable property of a menu entry), and that signals an error because the whitespace-mode variable happens not to be defined yet. So as Phils suggests, loading whitespace would probably work around the problem.

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).