Better Emacs support?

6 views
Skip to first unread message

Michael Shulman

unread,
Dec 17, 2025, 12:27:58 PM (3 days ago) Dec 17
to PreTeXt support
Hi,

After resisting for a long time I have finally started experimenting with PreTeXt, and I've been pleasantly surprised at how well it compares to writing in LaTeX.  In particular, Emacs nXML-mode is pretty good at reducing the amount of XML boilerplate I have to type, which was one of my biggest worries.  However, I still miss several features from AUCTeX and particularly RefTeX, such as a table of contents for navigating the whole document and commands and menus for easily inserting labels and cross-references.  Before I spend some time coding those features in Emacs Lisp myself, I was wondering if anyone else has done something similar already?  I'd be interested to hear experiences even if you don't have any code to share publicly.

Thanks,
Mike

Mitch Keller

unread,
Dec 17, 2025, 12:46:18 PM (3 days ago) Dec 17
to pretext...@googlegroups.com
As a longtime Emacs user, I moved over to VS Code somewhat reluctantly about a year and a half ago. I do not regret it at all. Oscar’s got a lot of things built in already for inserting cross references (although I think it makes some assumptions about file structure that need some updating). I’d suggest jumping on the VS code bandwagon. 

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/cb1866a0-8aac-4cae-a210-9a7d0c695e21n%40googlegroups.com.


Eugene Boman

unread,
Dec 17, 2025, 12:58:50 PM (3 days ago) Dec 17
to pretext...@googlegroups.com

Hi Mike,

I've written a pretext-mode for myself that I'd be happy to share if you are interested. 

It will come with a couple of caveats:

  •  It is very lightly documented cuz I wrote it for myself and I already know what I want the functions to do.
  • It is buggy. I tend not to fix little bugs until they annoy me enough.

My pretext-mode  recognizes s"<" as the beginning of a tag, prompts for the tag and try to do something intelligent with it. For example, if I type "<section" it prompts for an xml:id label and a title then inserts the following: 

<section xml:id="SECTIONLabel">
  <title>
    This Was Typed In Response to a Prompt
  </title>
  <p>

  </p>
</section>

and leaves the cursor between <p> and </p>. It works similarly for most other tags. It is a work in progress so some of these work better than others. 

Also it recognizes when you are inside a <math> </math> construct and switches to LaTeX mode to access the AucTeX capabilities. 

I miss RefTeX too so I made a stab at it but my efforts were less than satisfactory.

Happy to share if you are interested. Let me know.

-- Bud

Michael Shulman

unread,
Dec 17, 2025, 1:05:50 PM (3 days ago) Dec 17
to pretext...@googlegroups.com
I've used VS Code for other things before (e.g. Lean), and overall I have not found the experience up to Emacs, particularly in the plethora of time-saving shortcut commands, the user-customizability, and the integration with everything else I do in Emacs.  Perhaps if I put more work into getting used to it I would be happier with it.  But if I can instead put that same time into developing or improving a pretext-mode for Emacs...

Bud, I'd love to see your code, thanks for offering!

You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/YMarLweG2RM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/44153df2-8e16-414c-9d53-8feed371c107%40gmail.com.


--
Michael Shulman
University of San Diego

"The role of the intellectual cannot be to excuse the violence of one
side and condemn that of the other."
        -- Albert Camus

Eugene Boman

unread,
Dec 17, 2025, 2:49:55 PM (2 days ago) Dec 17
to 'Michael Shulman' via PreTeXt support

Mike,

I've tarred up all of the pertinent files and attached the tarball to this email. It's only about 600KB so I don't expect any problems but if there are let me know and we'll try another method.

I did this by modifying James Clark's xml-mode. I ran "query-replace xml ptx" on them. Otherwise I haven't touched most of them them. Probably some of them aren't even necessary but I haven't investigated that. 

The two files you're interested in are ptx-tags.el and ptx-mode.el. ptx-tags.el is pretty self-explanatory. ptx-mode.el is where ptx-mode and all of its supporting functions are defined.

Like I said the documentation is sparse. 

To insert a PreTeXt tag just type "<" and respond to any prompts. Functions that insert a tag are usually named ptx-insert-<whatever> but not always. I had already written a few such functions when I decided to standardize. 

It does a pretty good job of detecting whether the point is inside or outside of a <math> </math> construct and switching to LaTeX mode when inside. But sometimes it gets confused so C-xt is bound to ptx-toggle-mode.

I hope you find it useful. There are undoubtedly quirks that are tied to the way I write PreTeXt which you'll find confusing and/or mysterious. Don't hesitate to contact me if you have questions.

If you want to contact me directly my email is: budb...@gmail.com

-- Bud

ptxmode.tar
Reply all
Reply to author
Forward
0 new messages