0

I'm using Emacs and trying to edit some *.xml files of FreeBSD Documentation Project. (https://www.freebsd.org/docproj/)

It requires *.xml files to conform following conditions:

  • Word wrap set to 70 characters.
  • Tab stops set to 2.
  • Replace each group of 8 leading spaces with a single tab.

So I added several lines in ~/.emacs as the instruction says:

(defun local-sgml-mode-hook
    (setq fill-column 70
      indent-tabs-mode nil
      next-line-add-newlines nil
      standard-indent 4
      sgml-indent-data t)
  (auto-fill-mode t)
  (setq sgml-catalog-files '("/usr/local/share/xml/catalog")))
(add-hook 'psgml-mode-hook
      '(lambda () (local-psgml-mode-hook)))

However, it seems not working correctly. When I open *.xml file of FDP in Emacs, sgml-mode is not automatically detected.

I manually enabled this mode via M-x sgml-mode. In this mode, tab stops set to 2 and 8 leading spaces->single tab worked fine, while word wrap set to 70 chars seems not working(this means when I exceeded the limit, there isn't any highlight I can recognize).

So the problems are:

  1. Not entering sgml-mode automatically
  2. Word wrap set to 70 chars doesn't working

I'm using Vim right now, but I prefer Emacs for my text editing. What should I do to edit files appropriately(make documents conform to FDP guidelines) with Emacs?

Thanks.

p.s. I posted about this on freebsd-doc mailing list and FreeBSD forum, but my problem is not solved--so I'm asking here.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
hwong
  • 78
  • 7
  • 1
    You seem be to missing the (empty) parameter list, should be `(defun local-sgml-mode-hook ()`, is that just a typo in posting? Or... – npostavs Jul 11 '15 at 18:13
  • 3
    This doesn't have anything to do with your problem, but it might be worth investingating `nxml-mode` instead of using `sgml-mode` for working with XML. In my opinion it is vastly superior. – ChrisGPT was on strike Jul 11 '15 at 18:25
  • @npostavs I copied that code directly from FreeBSD's suggestion: https://www.freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/editor-config-emacs.html – hwong Jul 11 '15 at 18:52
  • @Chris Thank you for advice! I'll give it a try. – hwong Jul 11 '15 at 18:55
  • @hwong: I see. Then it's a typo in FreeBDS's suggestion. I sent an email to the `freebsd-doc` address listed at the bottom. – npostavs Jul 12 '15 at 04:01
  • @npostavs Oh, I see. Thank you for feedback :) – hwong Jul 12 '15 at 04:48
  • 1
    Actually, I just noticed this is for *p*sgml-mode, not Emacs' builtin `sgml-mode`. Its [emacswiki page](http://www.emacswiki.org/emacs/PsgmlMode) says you can get a 24.x compatible version from [marmalade](https://marmalade-repo.org/packages/psgml), but since it hasn't really been updated since 2005, @Chris' suggestion of `nxml-mode` is likely a better idea. – npostavs Jul 12 '15 at 12:20
  • @npostavs Okay, I'm currently looking for configuration in `nxml-mode`. I'll add a comment here as soon as I find proper one. Thanks again! – hwong Jul 12 '15 at 13:32
  • `auto-fill-mode` with `nxml-mode` would be close to the answer. – hwong Jul 18 '15 at 22:21

0 Answers0