all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How do I decode an NROFF file for viewing?
@ 2008-07-19 18:08 Alan Mackenzie
  2008-07-19 20:39 ` Xah
  2008-07-23  1:01 ` Kevin Ryde
  0 siblings, 2 replies; 3+ messages in thread
From: Alan Mackenzie @ 2008-07-19 18:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hallo, world!

The M-x man command does 2 things:
(i) It finds the pertinent file using complicated, difficult, and
  obscure algorithms;
(ii) It converts the markup stuff in the file to a readable form and
  displays it.

I have an Nroff file, mount.8, loaded into Emacs.  How do I do part
(ii) of the above, and get it nicely displayed?

TIA!

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: How do I decode an NROFF file for viewing?
  2008-07-19 18:08 How do I decode an NROFF file for viewing? Alan Mackenzie
@ 2008-07-19 20:39 ` Xah
  2008-07-23  1:01 ` Kevin Ryde
  1 sibling, 0 replies; 3+ messages in thread
From: Xah @ 2008-07-19 20:39 UTC (permalink / raw)
  To: help-gnu-emacs

Alan Mackenzie wrote:

> The M-x man command does 2 things:
> (i) It finds the pertinent file using complicated, difficult, and
>   obscure algorithms;
> (ii) It converts the markup stuff in the file to a readable form and
>   displays it.
>
> I have an Nroff file, mount.8, loaded into Emacs.  How do I do part
> (ii) of the above, and get it nicely displayed?

possibly others have elisp answers on the spot. But here's what i
know:

you can use WoMan to read man pages in emacs. The manual-entry command
calls shell tool to do its job. WoMan is written entirely in elisp.
So, this means you could lookup WoMan's source code to see what it
does if you need it.

Alternative solution is to call shell command to process it first then
display the result plain text file in emacs. Here's some tips i wrote
some 10 years ago:

• How to get a text output of a man page?

“man ls | col -b”. The “col -b” formats the man page to plain text
(rid of control chars).

• How to read a non-compressed man page without the “man” command?

“nroff -man n43921.man | col -b”

• This is convenient when you need to read a man-page file once
without adding the dir to your $MANPATH.

• How to read a compressed man page without the “man” command?

“cat n43921.1 | compress -cd - | nroff -man | col -b”

• How to read a unformatted man page?

a possible solution: “nroff -man ftpshut.8”

The “man” command is essentially “nroff -e -man file_name | more -s”.


http://xahlee.org/UnixResource_dir/unix_tips.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How do I decode an NROFF file for viewing?
  2008-07-19 18:08 How do I decode an NROFF file for viewing? Alan Mackenzie
  2008-07-19 20:39 ` Xah
@ 2008-07-23  1:01 ` Kevin Ryde
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Ryde @ 2008-07-23  1:01 UTC (permalink / raw)
  To: help-gnu-emacs

Alan Mackenzie <acm@colin2.muc.de> writes:
>
> I have an Nroff file, mount.8, loaded into Emacs.  How do I do part
> (ii) of the above, and get it nicely displayed?

I use a bit as simple as a "man -l filename" for files:

(defun my-man-preview ()
  (interactive)
  (my-save-current-buffer-maybe)
  (setq Man-notify-method 'pushy)
  (man (concat "-l " (buffer-file-name))))

(defun my-save-current-buffer-maybe ()
  "Use `save-some-buffers' to save the current buffer, if it's modified."
  (interactive)
  (let ((my-save-current-buffer-maybe--target (current-buffer)))
    (save-some-buffers nil
                       (lambda ()
                         (equal my-save-current-buffer-maybe--target
                                (current-buffer))))))


I had a similar bit with woman (below) in the past, trying to get it to
preserve the window position in a re-preview (might be slightly broken),
but I think I ended up preferring plain man plus
(setq Man-switches "-Tlatin1").

My perl-pod-preview.el has some hairier stuff preserving the window
position and working from a buffer (from pod2man in its case) instead of
a file.  The guts of it is a call-process-region with "man -Tlatin1 -l -"
then Man-fontify-manpage and Man-mode.


(defun my-man-preview-woman ()
  (interactive)
  (my-save-current-buffer-maybe)
  (my-woman-find-or-revert (buffer-file-name)))

(defun my-woman-find-or-revert (filename)
  (let ((bufname
         (concat "*WoMan "
                 (file-name-extension filename)
                 " "
                 (file-name-sans-extension (file-name-nondirectory filename))
                 "*")))
    (if (get-buffer bufname)
        (progn
          (switch-to-buffer bufname)
          (let* ((point-column (current-column))
                 (point-line   (progn
                                 (beginning-of-line)
                                 (1+ (count-lines (point-min) (point)))))
                 (start-line   (count-lines (point-min) (window-start))))
            (kill-buffer (current-buffer))
            (woman-find-file filename)
            (goto-line start-line)
            (set-window-start (selected-window) (point))
            (goto-line point-line)
            (move-to-column point-column)))
      (woman-find-file filename))))




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

end of thread, other threads:[~2008-07-23  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-19 18:08 How do I decode an NROFF file for viewing? Alan Mackenzie
2008-07-19 20:39 ` Xah
2008-07-23  1:01 ` Kevin Ryde

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.