4

After some research we determined this is a problem inherent to lualatex. If you have a solution for this problem in LuaLaTeX please post it below and I will accept you answer.

When compiling a file with LaTeX (and others), if there is an error one has the option to edit the file at the line of the error (or near) by pressing e + Enter.

For example, if one has this file

\documentclass{article}
\begin{document}
\badcommand
\end{document}

I get this

...
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (./main.aux)
! Undefined control sequence.
l.3 \badcommand
?

However, in my current configuration TeXLive 2015 (Fedora), nothing happens. I only get this message:

You want to edit file ./main.tex at line 81
 297 words of node memory still in use:
   3 hlist, 1 rule, 48 glue_spec, 1 write, 1 dir, 1 pdf_colorstack nodes
   avail lists: 2:12,3:1,6:2,9:1
No pages of output.
Transcript written on document.log.
prompt $_

How can I configure the editor? in particular Gedit.

(I am suspecting it tries to open emacs which is not installed, but still I would like to use Gedit instead).

alfC
  • 14,350
  • On a unix-like system, including macosx, just set the TEXEDIT environment variable in your shell (e.g. in the appropriate one of .bashrc, .bash_profile, .cshrc, .zshrc etc). For example, I have export TEXEDIT="/usr/bin/gvim +%d %s" in .bash_profile. –  Apr 19 '16 at 02:46
  • It doesn't work. Maybe there is some security option that disables execution from LaTeX. – alfC Apr 19 '16 at 03:04
  • You need to source the file or restart your shell before it takes effect. –  Apr 19 '16 at 12:03
  • It probably tries to open vi. At least, that's what upstream's TeX does by default. I don't use Fedora's TL packages (even though I use Fedora on one machine), but I can't especially see why they'd change it to emacs. – cfr Apr 19 '16 at 12:07
  • @Andrew, I did that, also export TEXEDIT=... before running LaTeX. – alfC Apr 19 '16 at 18:15
  • @cfr, I said emacs because, contrary to emacs, vi was installed and LaTeX didn't call any program after e. I think it is not working from any program. – alfC Apr 19 '16 at 18:17
  • It is vi in upstream's configuration - it is hard-coded in texmf-dist/web2c/texmf.cnf which sets the installation's default. (But you shouldn't edit this file or try to change the value here. Instead, you use the local texmf.cnf which, for upstream, is at the root of the TeX installation, normally, /usr/local/texlive/YYYY/texmf.cnf. If it tries to use emacs on your system, I guess Fedora change the default. – cfr Apr 19 '16 at 21:00
  • 1
    Note that it seems to think the error is in color.cfg. If so, it will fail because you can't edit that file as you don't have permission. In reality, that is not where the error is, but the compiler is not always able to work this out. Try with a simple example with a simple syntax error such that TeX clearly knows that the error is in your .tex file. – cfr Apr 19 '16 at 21:10
  • @Andrew, your solution worked but only with pdflatex and not with lualatex. It seems that lualatex has some additional security measure. – alfC Apr 20 '16 at 01:25
  • Well, there's a first time for everything ;). Generally LuaTeX is much less secure. – cfr Apr 20 '16 at 01:56
  • 2
    Have you looked through web2c/texmfcnf.lua? Near the end, it says, -- In an edit cycle it can be handy to launch an editor. The -- preferred one can be set here. but then it gives no indication *how* to set it. The next line concerns the PDF viewer and the previous one the OTF font loader. – cfr Apr 24 '16 at 01:34
  • @cfr, 1) perhaps we can guess the name of the option. ["editor.method"]? (also 2) It would be interesting to know how luatex can benefit from know the PDF viewer, ["pdfview.method"] = "okular", – alfC Apr 24 '16 at 20:01
  • The trouble is I know absolutely nothing about Lua. But editor.method seems a reasonable guess. See if you can copy the configuration file to your working directory and have kpsewhich recognise it. If so, you can play around with it safely for testing purposes rather than messing around modifying the original. I'm also not sure if we're really meant to modify that file or not. It seems to say to, but won't it get overwritten on update? I expected an equivalent of the texmf.cnf strategy i.e. a separate file for local customisations. – cfr Apr 24 '16 at 20:16
  • Although this file seems to be only for ConTeXt ... But doesn't context call luatex ... ? There is a custom version of the file in the same directory as the custom texmf.cnf. And ConTeXt reads it. But LuaTeX doesn't seem to read anything ... – cfr Apr 24 '16 at 22:05

1 Answers1

4

If you are happy setting this system wide, you can edit the customisation into texmf.cnf but it is important to pick the correct texmf.cnf. Probably kpsewhich texmf.cnf should return the correct file. On my system, for TeX Live 2015, this is /usr/local/texlive/2015/texmf.cnf. Wherever it is, the file should be almost empty with just some explanatory comments at the top. Here's mine after adding the configuration line for the editor:

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TEXEDIT = /usr/bin/vim +%d '%s'

You will need to add an appropriately modified

TEXEDIT = /usr/bin/vim +%d '%s'

to your file, as I just added this line to mine. After doing so, I can edit the file using e.

I am not sure why the default is not to use the system or user value of EDITOR. TeX simply ignores this on my system and tries to use an editor which doesn't exist, with inevitably unsatisfactory results. What it should do is use EDITOR if that's configured, but I can't even get the file to use the value of a shell variable, so probably this is a hopeless enterprise. Hence, I hard-coded it as shown above, which does work even though the solution is not really a satisfying one.

cfr
  • 198,882
  • Thanks, but I put kpsewhich texmf.cnfwhich gives /usr/share/texlive/texmf-dist/web2c/texmf.cnf, edit the file and put line TEXEDIT = gedit +%d '%s' around line 656. Still it does nothing after I press e + Enter. Same thing happens with setting the environment variable. (also I have no /usr/local/texlive) – alfC Apr 19 '16 at 03:02
  • Editing that file isn't good. As I said, the file should be almost empty. I assume you're using your distro's packages for TeX Live and that complicates things. Apparently, they do not include the empty-but-for-comments copy of texmf.cnf which upstream provide. Probably you'd have to create it. (Maybe in /etc.) But likely the environment variable is a better option in this case. Try it first with a command-line editor to rule out issues opening an X11 window. – cfr Apr 19 '16 at 12:03
  • /usr/share/texlive/texmf-dist/web2c/texmf.cnf should be fine. It worked in the past for other options: http://tex.stackexchange.com/a/198631/1871 – alfC Apr 19 '16 at 18:19
  • The way TeX Live is currently configured, local changes are supposed to go into a different texmf.cnf file. Unless Fedora have changed this, you shouldn't put your changes into that file. – cfr Apr 19 '16 at 21:01
  • Read the comments at the top of the file you are editing. *It tells you explicitly not to make changes here.* Nothing terrible will happen, but your changes will be lost when your installation is updated. The same was true for the 2014 edition. Again, these files tell you where to make changes - and where not to - quite explicitly. – cfr Apr 19 '16 at 21:06
  • ok, I think the problem is that I was using lualatex and not pdflatex. It is lualatex that has problems opening the file. – alfC Apr 20 '16 at 01:24
  • 1
    @alfC You're right. Same here. I don't think it is security: I think it is probably a bug. As you probably know, LuaTeX is much buggier, in general, than pdfTeX because it is changing a lot more. (Well, that's one reason. There are others....) The bug might be the text message - i.e. it isn't meant to offer the option - or it might be the behaviour - i.e. it is supposed to honour the option. – cfr Apr 20 '16 at 02:05