1

I’ve installed psgml 1.4.0-9 and psgml-html-mode for DTD-aware editing of HTML.* But the built-in sgml-mode/html-mode seems to be causing some problems: some tags are highlighted in font-lock-function-name-face (as the built-in sgml-mode does), some in font-lock-type-face (as PSGML does), and they get recoloured depending on what I do (scrolling generally causes font-lock-type-face to take over, but the initial screen full of code is in font-lock-function-name-face). Most annoyingly, aiui PSGML is supposed to offer SGML-correct indenting taking account of omitted close tags, but afaict sgml-mode is taking control of indentation, meaning when I indent-region etc, what happens is not DTD-aware. I also have two SGML entries in my menu bar: the first (the one on the left) is from PSGML, the second from sgml-mode.

Given that sgml-mode.elc and sgml-mode.el.gz are inside my system Emacs installation (which I am reluctant to go hacking around inside by deleting or changing files), how can I completely disable all their behaviour and everything that they’re loading?

* Yes, I’m aware that HTML is not technically an SGML application any more, but the syntax is close enough, and no other HTML editing mode I’m aware of (including html-mode, html-helper-mode, and the HTML server for lsp-mode) is properly aware of implicit close tags in HTML — they think <p>hello <p>world creates two nested p elements, rather than two consecutive ones. PSGML gets it right.

Edit: My setup for PSGML etc, if it helps, is here. Everything else needed should also be in the same repo.

10
  • Your links claim that psgml provides a major mode, so unless that mode derives from sgml-mode, the latter won't be having any unintended effects. If it does derive, then the effects are intentional. – phils Mar 6 at 12:27
  • Oh, crazy... psgml.el defines a sgml-mode -- indeed everything is in the sgml- name space, not a psgml- name space. So I think you're just being misled by that. – phils Mar 6 at 12:30
  • No, describe-function sgml-indent-line explicitly tells me that it’s picking up the version in sgml-mode.el in my Emacs system installation, and not the version defined in psgml-edit.el. – dpk Mar 6 at 12:36
  • As you are using (require 'psgml) the standard sgml-mode won't be getting a look in at all, unless something calls html-mode (which would autoload sgml-mode.el, clobbering sgml-mode in the process), or sgml-mode is otherwise directly loaded. – phils Mar 6 at 12:37
  • I can't advise the best thing to do, because I have no idea whether psgml's sgml-mode is compatible with the standard mode. It's very unusual to see a library stepping on top of another's name like this. Perhaps they were under development at the same time, though. – phils Mar 6 at 12:41
1

nxml-mode, which implicitly loads the built-in sgml-mode for a small number of things, is loaded before PSGML. This means a number of names get clobbered before PSGML loads and it can’t properly claim them.

Loading PSGML before nxml-mode fixes the problem since Emacs will think sgml-mode is already there when nxml-mode loads, but nxml-mode will no longer work since the definitions it needs from the built-in sgml-mode are no longer there.

Solution: Load sgml-mode-fix, which defines the features and variables from sgml-mode which nxml-mode depends on, but no others. Since none of these names clash with PSGML, there should be no problem with using PSGML for HTML/other non-XML SGML files and nXML for XML files.

(require 'sgml-mode-fix)
(require 'nxml-mode)
;; configure nxml-mode here …

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.