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.

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
    Commented Jul 11, 2015 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.
    – Chris
    Commented Jul 11, 2015 at 18:25
  • @npostavs I copied that code directly from FreeBSD's suggestion: freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/…
    – hwong
    Commented Jul 11, 2015 at 18:52
  • @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
    Commented Jul 12, 2015 at 4:01
  • 1
    Actually, I just noticed this is for psgml-mode, not Emacs' builtin sgml-mode. Its emacswiki page says you can get a 24.x compatible version from marmalade, but since it hasn't really been updated since 2005, @Chris' suggestion of nxml-mode is likely a better idea.
    – npostavs
    Commented Jul 12, 2015 at 12:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.