all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* turning on SGML mode
@ 2020-03-12 21:01 Ulrich Deiters
  2020-03-12 22:12 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ulrich Deiters @ 2020-03-12 21:01 UTC (permalink / raw)
  To: help-gnu-emacs

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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book SYSTEM "$ATXHOME/xml/book.dtd">
<article>
…

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)

to the configuration file, but that does not turn on
the SGML mode. What am I doing wrong?

Kind regards,

Ulrich

-- 
Prof. i.R. Dr. Ulrich K. Deiters ______________________________________
Institut f. Physikalische Chemie \ Greinstr. 4–6, D-50939 Köln
Universitaet zu Köln   /\/\...    \ Tel. +49 (0)2232 932964
_______________________L|L|__|_____\ http://www.uni-koeln.de/deiters/



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: turning on SGML mode
  2020-03-12 21:01 turning on SGML mode Ulrich Deiters
@ 2020-03-12 22:12 ` Stefan Monnier
  2020-03-13  0:12   ` Ulrich Deiters
  2020-03-13  0:26 ` Perry Smith
  2020-03-13  8:38 ` tomas
  2 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2020-03-12 22:12 UTC (permalink / raw)
  To: help-gnu-emacs

> 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),

FWIW, Emacs comes with `nxml-mode` which offers somewhat similar
functionality (it can't read DTDs, OTOH: it requires RelaxNG Compact
descriptions instead, some of which come with Emacs).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: turning on SGML mode
  2020-03-12 22:12 ` Stefan Monnier
@ 2020-03-13  0:12   ` Ulrich Deiters
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Deiters @ 2020-03-13  0:12 UTC (permalink / raw)
  To: help-gnu-emacs

Am 12.03.20 um 23:12 schrieb Stefan Monnier:
> FWIW, Emacs comes with `nxml-mode` which offers somewhat similar
> functionality (it can't read DTDs,

… unfortunately, I must rely on DTDs.

-- 
Prof. i.R. Dr. Ulrich K. Deiters ______________________________________
Institut f. Physikalische Chemie \ Greinstr. 4–6, D-50939 Köln
Universitaet zu Köln   /\/\...    \ Tel. +49 (0)2232 932964
_______________________L|L|__|_____\ http://www.uni-koeln.de/deiters/



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: turning on SGML mode
  2020-03-12 21:01 turning on SGML mode Ulrich Deiters
  2020-03-12 22:12 ` Stefan Monnier
@ 2020-03-13  0:26 ` Perry Smith
  2020-03-13 16:06   ` Ulrich Deiters
  2020-03-13  8:38 ` tomas
  2 siblings, 1 reply; 6+ messages in thread
From: Perry Smith @ 2020-03-13  0:26 UTC (permalink / raw)
  To: Ulrich Deiters; +Cc: help-gnu-emacs

I think the mode is buffer specific and if the file you are editing has a suffix that matches a well known suffix, that will trigger the major mode for that buffer.

Your command doesn’t specify a file to edit but I doubt if you are staying within the *scratch* buffer.

I think, one option is to replace the setq-default with just (sgml-mode) but, again, that will be just for the buffer that happens to be the current buffer when that gets executed.  I think you could also add an -f argument to your command line such as -f '(sgml-mode)'

All this to ask / say: what is an example file name of what you are editing or … do you actually just say within the *scratch* buffer?

> On Mar 12, 2020, at 4:01 PM, Ulrich Deiters <ulrich.deiters@uni-koeln.de> 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
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE book SYSTEM "$ATXHOME/xml/book.dtd">
> <article>
> …
> 
> 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)
> 
> to the configuration file, but that does not turn on
> the SGML mode. What am I doing wrong?
> 
> Kind regards,
> 
> Ulrich
> 
> -- 
> Prof. i.R. Dr. Ulrich K. Deiters ______________________________________
> Institut f. Physikalische Chemie \ Greinstr. 4–6, D-50939 Köln
> Universitaet zu Köln   /\/\...    \ Tel. +49 (0)2232 932964
> _______________________L|L|__|_____\ http://www.uni-koeln.de/deiters/
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: turning on SGML mode
  2020-03-12 21:01 turning on SGML mode Ulrich Deiters
  2020-03-12 22:12 ` Stefan Monnier
  2020-03-13  0:26 ` Perry Smith
@ 2020-03-13  8:38 ` tomas
  2 siblings, 0 replies; 6+ messages in thread
From: tomas @ 2020-03-13  8:38 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2744 bytes --]

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
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE book SYSTEM "$ATXHOME/xml/book.dtd">
> <article>
> …
> 
> 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 "...<DOCTYPE book-..."
seems pretty distinctive. Just ask here if you need more support
on that.

Thirdly, you can match the file name (not just the "ending", or
"suffix") to a pattern and decide on that (cf. "auto-mode-alist".
Personally I don't very much care for this way of doing things,
which is a relict from Good Old DOS (TM): not every file called
"foo.xml" on your system will want the same treatment. But this
(anti-) pattern is widespread enough that people expect it to
work. I feel strongly about this, but hey, that's just me :-)

The first choice mentioned above has a very powerful sister,
which is the "file variables" thing: you can hide, at the
end of the file, a whole parameter block which not only
specifies which mode to use -- but other stuff (like how
to call your SGML processor or what not). Somewhat advanced,
but incredibly powerful. Just ask.

Cheers
[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html#Choosing-Modes
-- tomás

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: turning on SGML mode
  2020-03-13  0:26 ` Perry Smith
@ 2020-03-13 16:06   ` Ulrich Deiters
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Deiters @ 2020-03-13 16:06 UTC (permalink / raw)
  To: help-gnu-emacs

Am 13.03.20 um 01:26 schrieb Perry Smith:
> All this to ask / say: what is an example file name of what you are
editing or … do you actually just say within the*scratch*  buffer?

No – I need to open two files at the same time, namely the main
document and an auxiliary XML file containing style settings.
I do that with (find-file "…") commands in the configuration file
cfg_emacs.el .


I put the line
	(sgml-mode)
at the end of the configuration file, and now it works!

Thank you for your advice.

Ulrich

-- 
Prof. i.R. Dr. Ulrich K. Deiters ______________________________________
Institut f. Physikalische Chemie \ Greinstr. 4–6, D-50939 Köln
Universitaet zu Köln   /\/\...    \ Tel. +49 (0)2232 932964
_______________________L|L|__|_____\ http://www.uni-koeln.de/deiters/



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-13 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-12 21:01 turning on SGML mode Ulrich Deiters
2020-03-12 22:12 ` Stefan Monnier
2020-03-13  0:12   ` Ulrich Deiters
2020-03-13  0:26 ` Perry Smith
2020-03-13 16:06   ` Ulrich Deiters
2020-03-13  8:38 ` tomas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.