On Thu, Mar 12, 2020 at 10:01:14PM +0100, Ulrich Deiters wrote: > Dear all, > > I abuse Emacs for my typesetting, i.e., I use Emacs with the psgml > extension to edit XML documents (where Emacs gives me context-dependent > menus and automatic syntax checks), translate the XML file to LaTeX, > and convert the outcome to PDF. > > My XML file starts with > > > >
> … > > and I invoke Emacs by > > emacs -l $ATXHOME/interface/cfg_emacs.el -geometry +0+0 > > where cfg_emacs.el contains definitions of menu points etc. > > My problem: Whenever I start Emacs, I need to enter > > ESC x sgml-mode > > manually. I tried to add > > (setq-default major-mode 'sgml-mode) Since Emacs is made to edit many different kinds of files, there's no "one major mode" to be in. But there's a way to decide which major mode to set depending on a multitude of factors. See the chapter "Choosing File Modes" in your Emacs manual for all the gory details, which you can find online around here [1]. In a nutshell, Emacs looks at the content of the file's first line(s) for a hint on what this file is; failing that it looks then at the file name. You have a few choices here: the "first line tag", i.e. sneaking "-*- mode: psgml -*-" whithin the first line seems out (or at least somewhat ugly) because the first line is already taken up by the XML "cookie". Secondly, you might want to customize your variable "magic-mode-alist", which is a list of pairs associating a regular expression (to match the file's beginning) to a major mode. This looks like a good candidate, since your second line "...