unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: jidanni@jidanni.org, emacs-devel@gnu.org
Subject: Re: dired-man can't deal with compressed pages
Date: Sun, 22 Feb 2004 21:03:02 +0200	[thread overview]
Message-ID: <87d687vtgp.fsf@mail.jurta.org> (raw)
In-Reply-To: uptc7eic9.fsf@elta.co.il

Eli Zaretskii <eliz@elta.co.il> writes:
> I'm not sure this is the right way of solving the problem.  For
> starters, the "-l" switch is not portable: most versions of `man'
> don't support it.  And after thinking for a while, I don't see any way
> of forcing those versions of `man' who don't have "-l" to format a
> specific file.  I presume this is the reason why dired-x runs nroff
> directly.

I agree that this will not work for man who don't have the -l option.
On the other hand, man with the -l option should take the advantage of
this option.  So I think a good solution is to let users to choose
the command line they want, like in the patch below.

> If the only problem with the current code is that it doesn't support
> compressed man pages, perhaps we could detect compressed files and
> decompress them on the fly.

I think it's better not to duplicate what man already does.  Users
can construct the command line as they want.

> As for preprocessors, I don't know.  If this is important, we could
> blindly run the file through all of them, for example, or have a user
> option to do that.

Blindly running the file through all preprocessors will fail if some
preprocessor is not installed.  But having a user option will allow
the user to specify the command line with needed preprocessors.

> Yet another possible solution is to use functions from woman.el, which
> IIRC has a special command to format a single file.  However, I don't
> remember how well it supports various preprocessors.

There is already a dired binding to `W' key in woman.el.
So users desiring a woman can get her with this key.

Index: emacs/lisp/dired-x.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dired-x.el,v
retrieving revision 1.52
diff -c -r1.52 dired-x.el
*** emacs/lisp/dired-x.el	28 Sep 2003 09:03:45 -0000	1.52
--- emacs/lisp/dired-x.el	22 Feb 2004 18:29:00 -0000
***************
*** 1273,1285 ****
  
  ;;; Run man on files.
  
  (defun dired-man ()
    "Run man on this file.  Display old buffer if buffer name matches filename.
  Uses ../lisp/man.el of \\[manual-entry] fame."
    (interactive)
    (require 'man)
    (let ((file (dired-get-filename))
!         (manual-program "nroff -man -h"))
      (Man-getpage-in-background file)))
  
  ;;; Run Info on files.
--- 1273,1293 ----
  
  ;;; Run man on files.
  
+ (defvar dired-man-command "man -l"
+   "*Default man command.  If your man don't support the -l option,
+ then to display compressed man files you can set this variable to
+ a string like \"gzip -dc %s | tbl | nroff -man -h\" where %s
+ is a placeholder for the man file name.")
+ 
  (defun dired-man ()
    "Run man on this file.  Display old buffer if buffer name matches filename.
  Uses ../lisp/man.el of \\[manual-entry] fame."
    (interactive)
    (require 'man)
    (let ((file (dired-get-filename))
!         (manual-program (read-from-minibuffer
!                          "Man command: " dired-man-command nil nil
!                          'dired-shell-command-history)))
      (Man-getpage-in-background file)))
  
  ;;; Run Info on files.
Index: emacs/lisp/man.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/man.el,v
retrieving revision 1.132
diff -c -r1.132 man.el
*** emacs/lisp/man.el	16 Feb 2004 18:20:31 -0000	1.132
--- emacs/lisp/man.el	22 Feb 2004 18:29:01 -0000
***************
*** 486,498 ****
  (defsubst Man-build-man-command ()
    "Builds the entire background manpage and cleaning command."
    (let ((command (concat manual-program " " Man-switches
! 			 ; Stock MS-DOS shells cannot redirect stderr;
! 			 ; `call-process' below sends it to /dev/null,
! 			 ; so we don't need `2>' even with DOS shells
! 			 ; which do support stderr redirection.
! 			 (if (not (fboundp 'start-process))
! 			     " %s"
! 			   (concat " %s 2>" null-device))))
  	(flist Man-filter-list))
      (while (and flist (car flist))
        (let ((pcom (car (car flist)))
--- 500,514 ----
  (defsubst Man-build-man-command ()
    "Builds the entire background manpage and cleaning command."
    (let ((command (concat manual-program " " Man-switches
!                          (cond
!                           ;; Already has %s
!                           ((string-match "%s" manual-program) "")
!                           ;; Stock MS-DOS shells cannot redirect stderr;
!                           ;; `call-process' below sends it to /dev/null,
!                           ;; so we don't need `2>' even with DOS shells
!                           ;; which do support stderr redirection.
!                           ((not (fboundp 'start-process)) " %s")
!                           ((concat " %s 2>" null-device)))))
  	(flist Man-filter-list))
      (while (and flist (car flist))
        (let ((pcom (car (car flist)))

-- 
http://www.jurta.org/emacs/

  reply	other threads:[~2004-02-22 19:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-22  0:45 dired-man can't deal with compressed pages Juri Linkov
2004-02-22  6:31 ` Eli Zaretskii
2004-02-22 19:03   ` Juri Linkov [this message]
2004-02-22 20:59     ` Eli Zaretskii
2004-02-22 21:59       ` Juri Linkov
2004-02-23  6:09         ` Eli Zaretskii
2004-02-23 19:07           ` Kevin Rodgers
2004-02-23 19:51             ` Eli Zaretskii
2004-02-23  3:42       ` Juri Linkov
2004-02-23  6:12         ` Eli Zaretskii
2004-02-23 18:57         ` Richard Stallman
2004-02-23 15:28       ` Stefan Monnier
2004-02-23 18:57         ` Eli Zaretskii
2004-02-23 23:36 ` Juri Linkov
2004-02-24  6:21   ` Eli Zaretskii
2004-02-24 22:03     ` Juri Linkov
2004-02-24 19:26   ` Dan Jacobson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d687vtgp.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).