Emacs desktop-save-mode startup error - emacs

After adding the following code in my .emacs file, comes up some error during startup of emacs. I am a newbie of emacs, is there some one can help me figure out where are the errors come from?
Added code in .emacs:
;; Auto-saving the Desktop
(require 'desktop)
(desktop-save-mode 1)
(defun my-desktop-save ()
(interactive)
;; Don't call desktop-save-in-desktop-dir, as it prints a message.
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'my-desktop-save)
Errors:

Looking at the function definition for what's breaking, it seems that the error is that prj-file is NIL in line 492. (The other expand-filename call in the function shouldn't ever have a nil, since it's the car of a non-nil list of filenames).
Now, prj-file is the first filename in /home/shenyan/Test/memcached-1.4.11 matching the regexp "\\(Root\\)?ProjStep.ede" and presumably there isn't one. Since memcached presumably doesn't have an EDE project file, what's gone wrong must be that line 508's call to ede-project-p did something weird when called with this subdirectory of /home/shenyan/Test/.
I can't work out exactly why that happened, but you can debug things quite easily. First bring up your *scratch* buffer to type emacs lisp easily. To check my guess, insert the following code into the buffer
(ede-directory-project-p "/home/shenyan/Test/memcached-1.4.11")
and run it by hitting C-x C-e with cursor on the closing bracket. If it returns nil I was wrong. Otherwise, you've found the culprit and should probably debug it further by hunting through the bits of ede-directory-project-p in ede-files.el.
Probably what's going on is that your /home/shenyan/Test/ directory has something that tells EDE to search subdirectories (or maybe that's the default?) and then the memcached subdirectory has a file whose name makes EDE think it should be searched for a project file. If you work out exactly what happened, you might consider submitting a bug to the EDE developers: they probably shouldn't error out if the project file doesn't exist.

Related

emacs scratch not interactive mode

I updated a lot of packages that I had directly from github to the MELPA packages. Nonetheless something really weird happened to my *scratch* buffer. The default message is not appearing (the buffer is completely empty), and also the interactive elisp mode is not set (let's say I write (+ 2 2) and then hit C-j and it tells me invalid function). I have no idea why. I don't even know how to debug it to check where the error is. Any ideas?
Finally the problem was generated by flycheck-add-next-checker, for some reason, using the MELPA repositories is generating this error. I just commented the following part of my configuration file.
(eval-after-load 'flycheck
'(progn
;; Add Google C++ Style checker.
;; In default, syntax checked by Clang and Cppcheck.
(flycheck-add-next-checker 'c/c++-clang
'(warnings-only . c/c++-googlelint))))

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

Jump to next missing reference using auctex

I'm using emacs + auctex for all my TeXing needs and I'm very satisfied with the workflow. However, there's one thing bothering me. Whenver I compile a document (possible consisting of multiple files) and there's a missing reference auctex prints this annoying message
LaTeX Warning: Reference `fig:MyMissingLabel' on page 42 undefined on input line 37.
and that's it. No shortcut for jumping to the missing reference, nada!
I'm aware that I could enable debugging of warnings, however, this is not really suitable in case the document produces other warnings which I don't want to debugĀ¹.
I'd like to have a defun which cycles the point to the locations of the missing references. Thus I have not found anything online, maybe one of you guys can help?
Thanks in advance!
elemakil
[1] E.g. some packages report warnings when not loaded with a version number or something. I don't want to debug this. I'd like to correct my references!
The shorcuts in AUCTeX allow you to jump to an error.
The missing references are warnings.
You can activate your desired behavior by treating warnings as errors with TeX-toggle-debug-warnings which is bound to C-c C-t C-w.
This question is old, but here's my take. First, define the function
(defun my-ignore-TeX-warnings (type file line text &rest more)
(setq ref "LaTeX Warning: Reference")
(not (string-match-p ref text)))
Then customize the two variables TeX-ignore-warnings and TeX-suppress-ignored-warnings - e.g.,
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-ignore-warnings 'my-ignore-TeX-warnings)
'(TeX-suppress-ignored-warnings t))
Note: heed the warning above - i.e., you should only have one custom-set-variables.
Put the code into your ~/.emacs or similar file. Then, enable TeX-toggle-debug-warnings or through the menu Command->TeXing options->Debug warnings.
Cycling through errors with C-` will include undefined references. One could extend the code above to also select undefined citations.
Yours,
Christian

eval-when-compile not being honored?

I'm attempting to install ace-jump-mode for emacs 24.1.50.1.
I've installed it with M-x package-install, and calling M-x ace-jump-mode activates it and prompts for a letter, but upon entering a letter, I get the error:
Symbol's function definition is void: every
Running emacs -q (and then running (add-to-list 'load-path "~/.emacs.d/elpa") like I have in my .emacs file) allows me to load ace-jump-mode and it functions without an issue. Assuming thus that the error exists in my .emacs, I commented out everything in my .emacs, and reopened emacs regularly, but still get the error.
From some searching around, I think the issue is the code in ace-jump-mode.el
(eval-when-compile
(require 'cl))
is not working correctly when I don't use emacs -q. When I M-x load-library cl, everything works fine.
I imagine that since I can't find any references to this online, its not a common bug, so it must be an issue with my config. I know I could just load cl in my .emacs, but I don't see the need to load the entire package just for one function.
Does anyone know how to fix this? Or, how to load only one function from cl?
Thanks.
Emacs is self documenting, C-h f every will show you that this
function is defined in cl-extra not cl, but loading cl autoloads it, so
it does become available.
Some things with how cl is loaded may have changed with Emacs 24, which
broke this library, I'm not certain. Like you found out, the easiest fix is
to just
(require 'cl)
in your init file. This isn't as a big deal as you make it out. A lot of
libraries you might use will do this anyway, so it's likely you're just
changing the order things get loaded.
The alternative is to just submit a patch to the author of ace-jump-mode
that avoids using every, which is more inconvenient.
Finally, if you ever got ace-jump-mode to work it was because you loaded the
uncompiled ".el" file instead of the compiled ".elc" file, which would have
run (require 'cl), meaning that both cl and cl-seq will have been loaded
somewhere along the way. So there is no magic that can make this work
without loading those files.
(eval-when-compile <foo>) means that <foo> is only executed when compiling the file (or when running it uncompiled). So if you compile your file, the resulting file won't load cl, which is a problem since every is only defined when cl is loaded. (eval-when-compile <foo>) is used to load macros (such as ignore-errors), since these are only needed during compilation, but every is not a macro, hence your problem.

Trying to edit init.el to customize emacs

So I'm relatively new in trying to customize emacs. But I really need to customize is asap. Tabs are a pain in emacs as they are two spaces, and the text is all messed up when it is opened with any other editor after that.
Currently, I only have few lines in my ~/emacs.d/init.el file:
(setq load-path (concat (getenv "HOME") "/.emacs.d/"))
(set-scroll-bar-mode 'right)
(require 'linum)
(global-linum-mode t)
I get an error while starting up emacs:
Loading encoded-kb...done
An error has occurred while loading `/Users/mycomp/.emacs.d/init.el':
Symbol's function definition is void: set-scroll-bar-mode
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
I tried srtating it with the --debug-init option, but my lisp knowledge is not enough to help me figure out what's wrong. Any help on how to get this working or redirecting me to some GOOD tutorials on editing init.el files will be really helpful (yes i did google tutorials on editing the initialization file, but every one of them was terrible).
I'm assuming my code for getting line numbers on the left is also wrong. Could someone please help me with this? Thanks a lot.
I think this line may be the problem:
(setq load-path (concat (getenv "HOME") "/.emacs.d/"))
First of all, I don't think this is required to load ~/emacs.d/init.el. Secondly, if you do want to add a directory to your load-path, you should probably be doing it like this instead:
(add-to-list 'load-path "~/.emacs.d/")
This code adds the directory to the load-path, your code just clobbers it with the single directory.
Use 'M-x apropos' and 'M-x customize-apropos'. For now, those will make your life much easier when you want to customize things.
For instance, to customize things to do with scrolling, 'M-x customize-apropos RET scroll RET' will give you a list of all things that you can customize that have 'scroll' in them. You can look around and find the things that you want by searching the buffer. If you find a particular thing that you want, there's usually a group that it belongs to. You can click on that, and just customize those particular values. Make sure you save the settings.
It might take you a while to figure out what things are called. If you've got an idea, try the apropos search. If that doesn't turn up anything, google can probably sort it out for you.
For now, don't worry about hacking the elisp. This method will write values to your startup file (probably the .emacs?) and you can look and check the syntax later if you're really interested. I customize most of my stuff this way; I only bother actually modifying the file by hand when I'm trying to write my own hooks or functions.