I have upgraded to Fedora 20 and suddenly latex-mode/auctex is broken. I receive an error whenever trying to go into latex mode:
command-execute: Symbol's value as variable is void: latex-mode
Using toggle-debug-on-error I see:
Debugger entered--Lisp error: (void-variable latex-mode)
byte-code("\301\302\303\304\305\306\307\310\307\311& \210\312\313\303\314\315\316\307\302&\210\312\317\303\320\315\316\307\302&\210\312\321\303\322\315\316\307\302&\210\312\323\324\325\315\316\307\302&\210\312\326\303\327\315\330\307\310&\210\331!\210\332\333\334\"\207" [latex-mode custom-declare-group LaTeX-macro nil "Special support for LaTeX macros in AUCTeX." :prefix "TeX-" :group LaTeX TeX-macro custom-declare-variable TeX-arg-cite-note-p "*If non-nil, ask for optional note in citations." :type boolean TeX-arg-footnote-number-p "*If non-nil, ask for optional number in footnotes." TeX-arg-item-label-p "*If non-nil, always ask for optional label in items.\nOtherwise, only ask in description environments." TeX-arg-right-insert-p t "*If non-nil, always insert automatically the corresponding \\right.\nThis happens when \\left is inserted." LaTeX-mode-hook "A hook run in LaTeX mode buffers." hook TeX-abbrev-mode-setup add-to-list auto-mode-alist ("\\.drv\\'" . latex-mode)] 10)
command-execute(latex-mode record)
execute-extended-command(nil "latex-mode")
call-interactively(execute-extended-command nil nil)
Help please!What broke my LaTeX mode and how can I fix it?
Running
GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.9.10) of 2013-08-14 on buildvm-17.phx2.fedoraproject.org
Following https://github.com/bbatsov/prelude/issues/407 I re-installed AucTex. That seems to have done the trick. I used list-packages and then deleted AuxTex then reinstalled. I can now use LaTeX mode.
Related
I'm facing a very bizarre behaviour. No matter how I set ac-auto-start, be it through customization, by evaluating (setq ac-auto-start 2), (setq-default ac-auto-start 2) or (setq-local ac-auto-start 2) immediately after I do it, the variable is set to nil.
I've looked through the source of auto-complete mode and the ac-slime in my case, but none of these does nothing to this variable. I am at a loss as to how to deal with this.
The effective consequences of this malfunction is that completion combobox doesn't appear on its own, unless I force it to by doing M-x auto-complete. This behaviour is consistent in all modes where auto-complete minor mode is enabled.
EDIT
This seems to be an issue with latest Emacs. Now it fails to modify variables values, no matter what variable it is. So, say, after running it with -Q I've now discovered that I can't evaluate the code that uses (setq ...) forms as it has no effect. :/ So, please, hold on, I'll try to investigate this...
This was due to the typo, but the original problem is still there.
Emacs version is 24.3.50.1 pulled from trunk about a week ago.
auto-complete is version 1.4 installed from MELPA.
I'm setting the variable by moving the point to the REPL buffer, then M-:. I check its value in the same way.
EDIT2
OK, I finally found the reason: I had enzyme package installed, and it had an earlier version of auto-complete inside of it, for some reason parts of the auto-complete code were loaded from there and other parts from the one installed from MELPA. After disabling enzyme it all works well now.
EDIT3
This still happens after I run (auto-complete-mode 1) in the REPL buffer. The variable will become impossible to set. I've searched through various autocomplete timers that may be setting something, but no luck so far.
There is indeed something strange going on with the setting of auto-complete-mode.
(I'm using the ELPA version in a GNU Emacs 24.3.1)
This is set up by customize-group RET auto-complete :
'(ac-auto-show-menu t)
'(ac-auto-start t)
At this point if you M-x auto-complete-mode you get a [no match] right in the minibuffer. Only after you try to M-x auto-complete, yelding a "auto-complete-mode is not enabled" weird error, will you be able to M-x auto-complete-mode (but without command completion... Hm) and then be in the mode.
If you put this in your init file (.emacs)
(require 'auto-complete)
(auto-complete-mode t)
It will be effective only if you re-eval it after startup (?!?).
The same with something like
(if (auto-complete)
(auto-complete-mode t))
The only way that I found to get auto-complete-mode to load at startup is to :
(eval-and-compile
(require 'auto-complete nil 'noerror))
(The above customize options are now effective)
We use an internal scripting language (let's call it pkc), which allows for embedding C++ code. The C++ code segments are delimited by {{{ and }}} markers.
I create an emacs mode for this language, using Generic Mode and mmm-mode.
Here is what I got (stripped down non-essential parts for posting here):
(require 'generic-x)
(setq pkc-imenu-generic-expression
'(("macros" "^[ \t]*macro[ \n\t]+\\([a-zA-Z0-9_]+\\)" 1)
("functions" "function[ \n\t]+\\([a-zA-Z0-9_]+\\)" 1)
))
(require 'cc-mode) ;; for c++-mode
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(define-generic-mode
'pkc-mode ;; name of the mode to create
'("//" ("/*" . "*/")) ;; comments are same C++ comments
'( ... ) ;; some keywords
'("\\.pkc$") ;; files for which to activate this mode
;; other functions to call
'((lambda ()
(mmm-mode 1)
(setq mmm-submode-decoration-level 2)
(setq imenu-generic-expression pkc-imenu-generic-expression)
(which-function-mode 1)
(c-initialize-cc-mode t)
(c-init-language-vars-for 'c++-mode)
(c-common-init 'c++-mode)
(c-update-modeline)
(message "pkc-mode[mmm] is on")))
"A mode for pkc source files" ;; doc string for this mode
)
(mmm-add-classes
'((embedded-c++
:submode c++-mode
:face mmm-default-submode-face
:front "{{{"
:front-offset -1
:back "}}}"
:back-offset 1)))
(mmm-add-mode-ext-class 'pkc-mode nil 'embedded-c++)
When I load the source file with embedded C++ code segments, they are highlighted somewhat less than what would have been if C++ mode was the major mode (that's not my problem, however). When the cursor in C++ code, the modeline changes to pkc/l[C++/l] (as expected).
The problem is, whenever I press TAB to indent a line, I get the error Wrong type argument: stringp, nil. When I turned on debugger, this is the stack trace I see:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
c-syntactic-skip-backward(nil nil t)
c-looking-at-decl-block(nil t)
c-guess-basic-syntax()
c-indent-line()
#[nil \302>\203)\212\303 \210\304\305x\210\303 \210\306 )i\306 X\203\"\307 !\202'\212\307 !))\20 \207" [indent-line-function column (indent-relative indent-relative-maybe) beginning-of-line "\n " nil current-indentation indent-line-to] 2 1908700 nil]()
c-indent-command(nil)
c-indent-line-or-region(nil nil)
call-interactively(c-indent-line-or-region nil nil)
Looking at the definition of c-looking-at-decl-block and particularly the call to `c-syntactic-skip-backward, I find:
(c-syntactic-skip-backward c-block-prefix-charset limit t)
Examining the first argument c-block-prefix-charset reveals that its value is nil. Doing the same from a plain C++ buffer shows a non-nil value. So, I suspect that C++-mode requires some initialization that's not being properly done.
So, my questions are:
What am I missing in the C++-mode initialization section in my implementation?
Am I using the right approach (combining generic-x and mmm-mode)? Is there a better approach?
I also see another error (File mode specification error) when I load the file, but I suspect the problem is the same or something similar.
Thanks for your time.
(Rewritten after the discussion in the comments, for any later visitors).
The setup in the question is basically fine, but to work with current c++-mode you need to use an updated version of mmm-mode. It's available at the GitHub project page and also at Melpa.
The relevant patches (one, two, three) added new entries to the value of mmm-save-local-variables, which mmm-mode uses to decide which local variables to save or restore when leaving or entering a submode region.
From what I understand, a future update to cc-mode can add more such vars, so the list may need to be updated from time to time.
Extra tip: to have better indentation in the subregions, you may want to wrap the submode's indent-line-function with some code that will narrow the buffer before calling it (example here). Depending on the indentation function (and whether it calls widen), it may or may not help.
Following this pdf document I added the following to my ~/.emacs file:
(load "auctex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t) ;; .pdf statt .dvi per default:
;;Zeilenumbruch
;;(add-hook ’LaTeX-mode-hook ’turn-on-auto-fill)
;;Syntax Higlight
(add-hook ’LaTeX-mode-hook ’turn-on-font-lock)
;; Mathe Modus
(add-hook ’LaTeX-mode-hook ’LaTeX-math-mode)
;; Reftex einflechten und laden
(setq reftex-plug-into-AUCTeX t)
(add-hook ’LaTeX-mode-hook ’turn-on-reftex)
;; Satzende ". " statt ". ". " fuer M-k: loeschen bis Satzende usw.
;;(setq sentence-end "[.?!][]\"’)}]*\\($\\| \\| \\)[
;;]*") ;; Da ist ein "Newline in der Zeile!"
;;(setq sentence-end-double-space nil)
;;direkte Rechtschreib Korrektur:
;;(add-hook ’LaTeX-mode-hook ’flyspell-mode)
;; Nur benutzen falls Auctex > 11.81 mit preview-latex:
(load "preview-latex.el" nil t t)
;; aspell ist besser als ispell.
;; Zeile kommentieren, falls nicht installiert:
(setq-default ispell-program-name "aspell")
;; Deutsche Rechtschreibung falls \usepackage{ngerman}
;; oder german benutzt wird
(add-hook ’TeX-language-de-hook
(function (lambda () (ispell-change-dictionary "german8"))))
Unfortunately emacs doesn't start now, instead it gives the error
Warning (initialization): An error occurred while loading `/home/../.emacs':
Symbol's value as variable is void: ’LaTeX-mode-hook
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.
When starting with --debug-init it gives the following information
Debugger entered--Lisp error: (void-variable ’LaTeX-mode-hook)
(add-hook ’LaTeX-mode-hook ’turn-on-font-lock)
eval-buffer(#<buffer *load*> nil "/home/../.emacs" nil t) ; Reading at buffer position 812
load-with-code-conversion("/home/../.emacs" "/home/../.emacs" t t)
load("~/.emacs" t t)
...
I tried using latex-mode-hook instead. I searched for a solution, but I seem to be the only one having exactly this problem.
I'm using Ubuntu 12.04 with the latest Emacs and Auctex. If required I'll post version information, but I rather think that something has to be added into the configuration or any package has to be installed instead.
How can I get emacs work with that configuration?
Are you using the wrong single quote character? it seems to be some kind of a backward quote instead of a plain single quote. Try
'LaTeX-mode-hook
instead of
’LaTeX-mode-hook
(and likewise for all other occurrences of that character).
As Thomas also said, the back quote is not the character you want to use there, it should be the single straight quote. But, in general, if you get "symbol's value as variable is void" error, it means the same as NPE (null pointer exception) in other languages. The way to check what went wrong is like so:
Move point to the variable that gives the problem and C-h v (or M-x describe-variable [name of the variable without quote]). You can use TAB to complete the variable name as you type to see if you by chance didn't mistype it.
Once you see the buffer that describes the variable - you know you've fixed the error.
Now, if you have LaTeX mode set through auctex.el, then latex-mode-hook must exist. However, you need to make sure that auctex.el actually loads and requires latex-mode. The way it does so isn't an idiomatic way for Emacs to do it, most of the time you add the source files for the mode to the load-path variable and then (require 'mode-name) or load the mode conditionally once Emacs opens the type of the file associated with it (makes startup time for Emacs shorter) through autoload as described here: Emacs: Best-practice for lazy loading modes in .emacs? .
However, whenever you see a variable called [something]-mode-hook it means that this is a list of functions you want to call when [something] mode loads up. If the [something] mode at all exists, there's a 99.99% chance that variable exists too (can't be void). So, if it is void - you need to make sure that the mode it belongs to at all loads.
I'm trying to set some keybindings to use the Shift key to highlight text. I could use pc-selection-mode, but that doesn't offer all the key bindings I want. For example, I'd like to be able to shift-mark an entire paragraph by pressing Shift-Ctrl-down which I can do in most MS text editors, but pc-selection-mode doesn't allow you to do this.
I found this website which has a shift_mark.el file I can use to set all the key bindings I want. I've put in my .xemacs/init.el file to load shift_mark.el.
This is the error:
Warning (initialization): An error occurred while loading `/home/theory/phrkaj/\
.xemacs/init.el':
Wrong type argument: arrayp, (shift right)
So I've run Emacs with --debug-init to try and find the problem. This is what the debugger came up with:
Debugger entered--Lisp error: (wrong-type-argument arrayp (shift right))
signal(wrong-type-argument (arrayp (shift right)))
global-set-key((shift right) shift-mark-forward-char)
eval-buffer(#<buffer *load*<3>> nil "/home/theory/phrkaj/shift_mark.el" nil t) ; Reading at buffer position 1476
load-with-code-conversion("/home/theory/phrkaj/shift_mark.el" "/home/theory/phrkaj/shift_mark.el" nil nil)
load("~/shift_mark.el")
eval-buffer(#<buffer *load*<2>> nil "/home/theory/phrkaj/.xemacs/init.el" nil t) ; Reading at buffer position 25
load-with-code-conversion("/home/theory/phrkaj/.xemacs/init.el" "/home/theory/phrkaj/.xemacs/init.el" nil nil)
load("/home/theory/phrkaj/.xemacs/init.el" nil nil t)
load-file("/home/theory/phrkaj/.xemacs/init.el")
eval-buffer(#<buffer *load*> nil "/home/theory/phrkaj/.emacs" nil t) ; Reading at buffer position 253
load-with-code-conversion("/home/theory/phrkaj/.emacs" "/home/theory/phrkaj/.emacs" t t)
load("~/.emacs" t t)
#[nil "^H\205\264^# \306=\203^Q^#\307^H\310Q\2027^# \311=\2033^#\312\307\313\314#\203#^#\315\2027^#\312\307\313\316#\203/^#\317\2027^#\315\2027^#\307^H\320Q^Z\321^S\322\n\321\211#\210^K\321=\203_^#\323\324\325\307^H\326Q!\"^\\322\f\$
command-line()
normal-top-level()
Here's part of the shift_mark.el file which defines the highlighting of one char forward:
(defun shift-mark-forward-char ()
(interactive)
(shift-mark 'forward-char))
(global-set-key '(shift right) 'shift-mark-forward-char)
Any help is appreciated.
Under GNU Emacs, the key binding should look like
(global-set-key [(shift right)] 'shift-mark-forward-char)
([…] constructs a literal array). But I suspect you're going at this the wrong way. Are you running GNU Emacs, XEmacs, or both? What versions? Unless you're running extremely old versions, pc-selection-mode should do what you want under GNU Emacs, and no setup should be required under XEmacs. If you run both GNU Emacs and XEmacs, you can use the following code in your .emacs:
(defvar running-xemacs (string-match "XEmacs" emacs-version))
(if (not running-xemacs)
(pc-selection-mode 1))
C-hv shift-select-mode RET
shift-select-mode is a variable defined in `simple.el'.
Its value is nil
Documentation:
When non-nil, shifted motion keys activate the mark momentarily.
While the mark is activated in this way, any shift-translated point
motion key extends the region, and if Transient Mark mode was off, it
is temporarily turned on. Furthermore, the mark will be deactivated
by any subsequent point motion key that was not shift-translated, or
by any action that normally deactivates the mark in Transient Mark mode.
See `this-command-keys-shift-translated' for the meaning of
shift-translation.
You can customize this variable.
This variable was introduced in GNU Emacs 23.1:
** Temporarily active regions
* The new variable shift-select-mode, non-nil by default, controls
shift-selection. When Shift Select mode is on, shift-translated
motion keys (e.g. S-left and S-down) activate and extend a temporary
region, similar to mouse-selection.
* Temporarily active regions, created using shift-selection or
mouse-selection, are not necessarily deactivated in the next command.
They are only deactivated after point motion commands that are not
shift-translated, or after commands that would ordinarily deactivate
the mark in Transient Mark mode (e.g., any command that modifies the
buffer).
I would like to use latexmk to compile my LaTeX documents in Emacs. Especially I need the Emacs functionality next-error, which is typically called with C-x `, and jumps to the next LaTeX error in the document.
I would like to call latexmk either using C-x compile or the AUCTeX C-c C-c.
First, I set latexmk to use
$pdflatex = 'pdflatex -interaction=nonstopmode';
Option 1: C-x compile
I press C-x compile and type latexmk -pdf foo, which runs pdflatex. But next-error will not jump to the errors, even if the *compilation* buffer contains errors:
! Paragraph ended before \author was complete.
<to be read again>
\par
l.48
[...]
Compilation exited abnormally with code 12
How can I automatically jump to this error in line 48?
Note that this question of parsing the latex output has nothing to do with latexmk directly. The same problem occurs when I just do C-x compile pdflatex -interaction=nonstopmode foo.
Option 2: AUCTeX
How can I set AUCTeX to call latexmk -pdf instead of pdflatex on my .tex file? Of course, I want next-error to work here too.
UPDATE: I started a bounty because if this worked it would be a great tool for many people. I consider the question answered if a solution is given that lets me easily compile my LaTeX document using latexmk in Emacs and jump to the errors using next-error (of course, the errors might be in included .tex files, not necessarily in the master file or the current buffer).
UPDATE: Thanks to Ivan (and Chris) for making AUCTeX+Latexmk work. In the meantime, I found that using Rubber to compile LaTeX is also an excellent choice. It will display error messages in the format used by gcc and other compilers, so it naturally works with Emacs C-x compile, e.g. C-x compile rubber --pdf foo, and the error messages are parsed correctly.
Sorry I don't have the ability to comment, or I would just add this as a comment. Chris Conway's answer works, except that it should use TeX-run-TeX instead of TeX-run-command so that AucTeX knows to process the error messages.
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run Latexmk on file")
TeX-command-list)))
It might also be wise to add something like
'("%(-PDF)"
(lambda ()
(if (and (not TeX-Omega-mode)
(or TeX-PDF-mode TeX-DVI-via-PDFTeX))
"-pdf" "")))
to TeX-expand-list and use "latexmk %(-PDF) %s" so that it will work in both pdf and dvi mode. Personally, I find it easier to use customize especially when you are experimenting.
It's relatively easy to get AucTeX to run latexmk with C-c C-c. The following will add a Latexmk choice to the list of TeX commands:
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Latexmk" "latexmk -pdf %s" TeX-run-command nil t
:help "Run Latexmk on file")
TeX-command-list)))
The trick is getting next-error to work. If you dig around in the AucTeX sources, you can probably find the regex it uses on TeX output buffers; it's not automatically applied to the buffer created by TeX-run-command. (You might also be able to convince compile mode to use this regex.)
Another approach is to redefine the variable LaTeX-command. This is a bit iffy because I think a lot of AucTeX functions assume they can tack command-line options onto this string and execute the result.
Adding %(mode) gives latexmk some more options like noninteractive if it is set so in auctex.
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Latexmk" "latexmk -pdf %(mode) %s" TeX-run-TeX nil t
:help "Run Latexmk on file")
TeX-command-list)))