When I launch the ConTeXt command from AucTEX Command menu (or with C-c C-c), AucTEX calls for texexec and compilation fails since texexec relies on ruby dependencies that are not installed under my Windows account. This piece of code may be somehow outdated: AFAIK, texexec is rather designed for MkII. Moreover, it would be good to be free to choose context or contextjit.

Of course under Emacs everything can be configured. I looked for a way to change the texexec variable to context in my .emacs. All I could find is that TeX-command-default, when set to 'ConTeXt', launches texexec. I do not know how to change this.

Any idea ?


To switch to MKIV in Emacs, set ConTeXt-Mark-version

(setq ConTeXt-Mark-version "IV")

in your .emacs. By default the ConTeXt command in Emacs executes context --once. I don't like this and want to take advantage of the automatic multipass compilation of ConTeXt, so I switch to ConTeXt Full by default.

(add-hook 'ConTeXt-mode-hook
            (setq TeX-command-default "ConTeXt Full")))

If you are like me and do not save ConTeXt files with a .tex extension but rather .mkiv or even .mkvi, then you also need the following part, such that ConTeXt is enabled when you open these files and that AUCTeX knows the extension when compiling:

(add-to-list 'auto-mode-alist '("\\.mkiv\\'" . ConTeXt-mode))
(add-to-list 'auto-mode-alist '("\\.mkvi\\'" . ConTeXt-mode))
(with-eval-after-load "context"
  (add-to-list 'TeX-file-extensions "mkvi" t)
  (add-to-list 'TeX-file-extensions "mkiv" t))
  • Thanks. I once searched AucTeX wiki for all occurences of ConTeXt but didn't figured out that a switch to MkIV would solve it, because I read it when I was still thinking that texexec worked on both mkii and mkiv. – sztruks Jul 27 '17 at 7:38
  • may i paste your solution to emacswiki's AUCTeX page? – sztruks Jul 27 '17 at 11:35
  • @sztruks Sure, but I am no Emacs expert. Surely, there is a way to do this more concise. – Henri Menke Jul 27 '17 at 11:55

Henri's answer is thorough.

On any AUCTeX precompiled package from a GNU/Linux distribution out there you can have:

 (load "context.el" nil t t) 

on your init file instead, as long as you modify II with IV on context.el. Save and exit.

 ;; Define before first use.
 (defcustom ConTeXt-Mark-version "IV"
   "ConTeXt Mark version used for running ConTeXt."
   :type 'string
   :group 'TeX-command)
 (make-variable-buffer-local 'ConTeXt-Mark-version)
 (put 'ConTeXt-Mark-version 'safe-local-variable 'stringp)

The file context.el may be found at /usr/share/emacs/site-lisp/auctex directory

There are other questions that deal with a standalone ConTeXt such as https://emacs.stackexchange.com/questions/33879. For those cases which deal with PATH start all over.

  • You suggest that one should modify context.el? – Arash Esbati Jan 24 '18 at 9:01
  • @ArashEsbati hehehe, the source says to define defcustom. Defcustom was suggested by my dear fellow Tassilo at one point, and I think the no less than great Mose expanded upon it. I've personally changed it in the past until I came across lists.gnu.org/archive/html/auctex/2016-09/msg00002.html but for some reason I' d always forget what the variable name was. Then I wanted to "run" only "pre-compiled" packages. Auctex 12.1-1 was on the community repository and it was viable to do so without having to remember such variable. But I'm wondering, isn't your end goal to merge with Emacs? – doed Jan 24 '18 at 11:57
  • The source says to define ConTeXt-Mark-version before first use of the variable in order to silence the compiler. See this patch where the code was relocated within context.el. I don't know what you mean by "pre-complied" packages, but please do not advertise to modify original lisp files. Reg. Emacs integration: I wouldn't hold my breath for that. My personal opinion is that ELPA releases are a good choice for AUCTeX. – Arash Esbati Jan 24 '18 at 13:35
  • @ArashEsbati "Do not advertise to modify original lisp files"... I have no idea what you implied or imagined... I can't advertise, for there is nothing to advertise, but as long as I'm not being imposed to compile ffrom source (which you clearly didn't suggested to), or use ELPA for every other need, I have to, out of necessity, make modifications to any lisp file that's on the way. Ahem.. can I for example, change some parts of the context-en.el that have been poorly implemented? Or should I post my concern on the mailing list? – doed Jan 24 '18 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.