7

I'm translating man pages, and have run in to a few problems with Emacs.

  1. How do you specify language? (With man, it looks like this man -Lsv shutdown for the Swedish "sv" subdirectory, if available.)

  2. In the Emacs man mode, you can use N or P to jump forward or backward according to headers (in roff, they look like this: .SH). But, this doesn't work if the header includes one (or more) of the three special Swedish characters: Å, Ä, and Ö. It doesn't matter if I escape them (like this \(:A). (But they are correctly displayed.)

  3. To view a work in project, I use for example M-x man RET ./ls.1 (that is, the absolute path). This is great, because it is the same man mode as for viewing "real" manpages (those in /usr/share/man). Only, when I do some changes in the document, how do I refresh the manpage? revert-buffer says the buffer is not associated with a file (not true, but OK, I get it); M-x load-file RET seems to have lost track of the file; ... Ideas?

By the way, translating is a lot of fun!

EDIT: (see the first comment) Table

Glorfindel
  • 815
  • 2
  • 10
  • 19
Emanuel Berg
  • 6,903
  • 8
  • 44
  • 65
  • 5
    Woman Mode could be worth a try (M-x woman for ls, M-x woman-find-file for ls.1s absolute path); it has a woman-locale variable that might help with 1.. (As far as I could find out it fails to solve 2. and 3.; has some more features, though.) – sr_ Aug 09 '12 at 07:36
  • @sr_: Oh, didn't even know there was a second way! Certainly worth exploring. But, take a look at the dump above, Woman doesn't seem to draw tables. I think the easiest way to solve 3. is to write a small Elisp function that is specific for the man page you currently work on. That's not pretty but it is OK since it takes some time translating even a short man page. – Emanuel Berg Aug 09 '12 at 10:05
  • Tables in man pages? I wasn't even aware of that possibility. Quite nice, thought. – sr_ Aug 09 '12 at 11:21
  • 1
    As for 1., (setq Man-switches "-Lsv") – Emanuel Berg Aug 09 '12 at 23:44

1 Answers1

3

How to update the man page in man page mode while editing the roff source:

;;;; MAN / man
(defvar *curr-man* "~/mansv/ls.1")

(defun edman ()
  "edit the current work-in-progress man page"
  (interactive)
  (find-file *curr-man*) )

(defun upman () ; edit: better version of this function below
  "update the current work-in-progress man page"
  (interactive)
  (buffer-menu)
  (revert-buffer)
  (with-temp-buffer
    (progn
      (insert-buffer-substring "*Buffer List*")
      (beginning-of-buffer)
        (let ((man-buffer (format "*Man %s*" *curr-man*)))
          (if (word-search-forward man-buffer (point-max) t) ; t = nil on fail
            (kill-buffer man-buffer) ))
      (man *curr-man*)
      (edman)
      (kill-buffer "*Buffer List*") )))

EDIT

This version of upman is hopefully more stable. Note the introducton of a new global.

(defun upman ()
  "update the current work-in-progress man page"
  (interactive)
  (if (get-buffer *curr-man-file*) (save-buffer))
  (let ((man-buffer (format "*Man %s*" *curr-man*)))
    (if (get-buffer man-buffer) (kill-buffer man-buffer))
    (man *curr-man*)
    (edman) ))
Emanuel Berg
  • 6,903
  • 8
  • 44
  • 65