Jump to next missing reference using auctex - emacs

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

Related

emacs doremi: to change color-themes

I'm trying to get doremi working in emacs. Specifically, at this stage, to allow me to quickly scroll through a condensed list of color-themes and see each theme as I go through it. For this I would use the 'M-x doremi-color-themes+' command.
What I've done:
Installed color-themes (successfull)
Installed doremi.el, doremi-cmd.el, ring+.el and added
(add-to-list 'loadpath "~/elisp/themes")
(add-to-list 'loadpath "~/elisp/doremi/")
(require 'color-theme)
(color-theme-initialize)
(color-theme-classic)
;; create a list of color themes to scroll through using 'doremi-cmd
(setq my-color-themes (list 'color-theme-classic
'color-theme-retro-green
'color-theme-gray30
'color-theme-subtle-hacker
'color-theme-jonadabian-slate))
(require 'doremi)
(require 'doremi-cmd)
(require 'ring+)
to the .emacs file.
What emacs does:
When I type the comand 'M-x doremi-color-themes+' into the mini-buffer it seems to accept that I've given it a valid command and tells me to use the and arrow keys to move through the list. But when I do that all that happens is the cursor moves up and down in the active window. No changing of color-themes.
Being somewhat new to emacs (and especially customising it) I'm sure I have missed a step or put something in the wrong place. Perhaps there's some sort of (setq 'bla-bla-bla (...)) I need to do?
Sorry for your trouble. Please state your Emacs version (M-x emacs-version), and your version of color-theme.el.
You do not need to require library ring+.el if you use Emacs 23 or later (its code was included in GnuEmacs 23.)
You do not need to use (color-theme-initialize) or (color-theme-classic). The former is done automatically by doremi-color-themes+.
Try starting from emacs -Q (i.e., no init file, ~/.emacs), to be sure there is no interference from stuff in your init file.
Your variable my-color-themes is not referenced anywhere. Instead of defining that variable, just customize user option doremi-color-themes. (Or leave its value nil, which means that all color themes will be cycled through.)
Feel free to contact me by email if you continue to have a problem. Or continue here, if you prefer.
[Just to be sure: you are using color-theme.el, right? There is a lot of confusion out there between Emacs "custom themes" and color themes. Do Re Mi supports both, but they are different critters.]
After a bit for back and forth with #Drew we found a solution to the problem.
It turned out the major problem was that I was using emacs in 'terminal mode' rather than as a GUI application. Bare in mind I'm using a mac.
In the context of Terminal, my arrow keys send escape sequences and so doremi cannot read the event as intended. So it just escapes and applies the message to the active buffer.
There is an answer.
By adding the following lines to my .emacs file (or whatever your init file for emacs is) I was able to redirect doremi to use two other keys. ie. not the up and down arrows.
(setq doremi-down-keys '(?n))
(setq doremi-up-keys '(?p))
Doing this tells doremi to use 'n' as the down key and 'p' as the up key. And all works just fine.
Because I am only new to the world of programming and computing I may often use incorrect terminology. If this is the case please let me know and I will edit accordingly for clarity and consistency.

Emacs desktop-save-mode startup error

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.

Setting up RefTeX Tab completion in emacs

I am trying to make Tab completion work with RefTeX. When typing C-c [ and selecting the type of reference I have then a prompt in the minibuffer. When I know the beginning of the bib key I want to enter, say for instance Campbell2006, I would like to type Camp Tab and get Campbell2006 [sole completion].
I have managed to set it up for some documents but I do not understand exactly why it works for them and not for others. I have noticed that for the documents that have proper Tab> completion, the following line is added to the file name_of_tex_file.el created in a auto subfolder:
(TeX-add-style-hook "name_of_tex_file"
(lambda ()
(LaTeX-add-bibliographies
"absolute_path_to_bib")))
I think I obtained this results by adding %%% reftex-default-bibliography: absolute_path_to_bib at the end of my files but this is kind of a nuisance, especially when editing the same file on several computers.
Note that RefTeX is working because when I type C-c [ Camp Ret, I get a list (sometime a bit odd) with the Campbell2006 entry.
I have tried to set the %BIBINPUTS% environment variables with no success.
Adding (setq reftex-bibpath-environment-variables '("c:/path_to_bib_file/")) seemed necessary for the C-c [ Camp Ret method to work.
It has somehow the same defects as adding a %%% reftex-default-bibliography: to the end of the file and did not provided the Tab completion.
I have tried various combinations of /, //, \\ and \ as file separators when specifying files but I do not know exact which I should use (I'm using emacs in a windows environment). The issue might be as simple as that but as there are lots of parameters to try I fail do determine where is the problem.
What is the step-by-step method to make RefTeX work smoothly with bibliography, including the Tab completion?
EDIT:
Completion is possible according to the Reftex manual entry about the command reftex-citation:
The regular expression uses an expanded syntax: &&' is interpreted as and. Thus,aaaa&&bbb' matches entries which contain both aaaa' andbbb'. While entering the regexp, completion on knows [sic] citation keys is possible. `=' is a good regular expression to match all entries in all files.
it does not provide precise guidance on how to make it work though.
Kindahero suggests setting a list of the bib entries and use the completing-read command. This sounds sensible, however I would like to generate this list automatically and it seems feasible because it works with some of my documents.
The documentation of reftex-citation is a bit confusing. It promises completion on known citation keys but I believe "known" refers to keys that have been used previously in this session rather than all keys in the appropriate bibliography. You can use the LaTeX-add-all-bibitems-from-bibtex command defined below to load all keys in your bibliography:
(defun get-bibtex-keys (file)
(with-current-buffer (find-file-noselect file)
(mapcar 'car (bibtex-parse-keys))))
(defun LaTeX-add-all-bibitems-from-bibtex ()
(interactive)
(mapc 'LaTeX-add-bibitems
(apply 'append
(mapcar 'get-bibtex-keys (reftex-get-bibfile-list)))))
Suggestions on appropriate hooks to make this happen automatically are welcome.

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.

Entering a minor mode with a major mode in Emacs

This question may be a duplicate of this question, but I can't get the following to work properly in my emacs.
I am trying to enter minor mode mlint-mode whenever I enter major mode matlab-mode (both modes available at their SourceForge page). I have the following in my .emacs file:
(add-hook 'matlab-mode-hook
(function (lambda()
(mlint-mode))))
which looks like the answer to the question I linked above. When opening a .m file, I get the following error:
File mode specification error: (void-function mlint-mode)
Could someone please assist in helping me write the correct hook to enter mlint-mode when I open a .m file? FWIW, I'm running emacs 23.1.50.1.
I think the correct name is mlint-minor-mode. Also, remember to ensure that all matlab stuff is known by Emacs, this can be done using:
(require 'matlab-load)
As a side note, it is typically a bad idea to use lambda functions in hooks. If you inspect the value of the hook you will see a lot of unrelated things. Also, if you modify your lambda expression and re-add it, both the old and the new version will be on the hook.
Instead, you can do something like:
(defun my-matlab-hook ()
(mlint-minor-mode 1))
(add-hook 'matlab-mode-hook 'my-matlab-hook)
The "1" is ensures that mlint mode is turned on or stay on if enabled earlier.