unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* dired-man can't deal with compressed pages
@ 2004-02-22  0:45 Juri Linkov
  2004-02-22  6:31 ` Eli Zaretskii
  2004-02-23 23:36 ` Juri Linkov
  0 siblings, 2 replies; 17+ messages in thread
From: Juri Linkov @ 2004-02-22  0:45 UTC (permalink / raw)
  Cc: Dan Jacobson

> From: Dan Jacobson <jidanni@jidanni.org>
> To: bug-gnu-emacs@gnu.org
> Date: Sat, 13 Sep 2003 06:45:22 +0800
>
> dired-man can't deal with resolvconf.8.gz etc. compressed man pages.

I think this problem can be fixed by invoking man with the -l option
and letting it to handle man files properly instead of calling the
current "nroff -man -h", i.e. to decompress the manual page files,
to format the nroff source more correctly: preprocess it thought tbl,
use correct switches, etc. all what man program does.

2004-02-22  Juri Linkov  <juri@jurta.org>

	* dired-x.el (dired-man): Replace manual-program by Man-switches.

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 00:41:04 -0000
***************
*** 1279,1285 ****
    (interactive)
    (require 'man)
    (let ((file (dired-get-filename))
!         (manual-program "nroff -man -h"))
      (Man-getpage-in-background file)))
  
  ;;; Run Info on files.
--- 1279,1285 ----
    (interactive)
    (require 'man)
    (let ((file (dired-get-filename))
!         (Man-switches (concat Man-switches " -l")))
      (Man-getpage-in-background file)))
  
  ;;; Run Info on files.

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

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

* Re: dired-man can't deal with compressed pages
  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
  2004-02-23 23:36 ` Juri Linkov
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-22  6:31 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Sun, 22 Feb 2004 02:45:13 +0200
> 
> > From: Dan Jacobson <jidanni@jidanni.org>
> > To: bug-gnu-emacs@gnu.org
> > Date: Sat, 13 Sep 2003 06:45:22 +0800
> >
> > dired-man can't deal with resolvconf.8.gz etc. compressed man pages.
> 
> I think this problem can be fixed by invoking man with the -l option
> and letting it to handle man files properly instead of calling the
> current "nroff -man -h", i.e. to decompress the manual page files,
> to format the nroff source more correctly: preprocess it thought tbl,
> use correct switches, etc. all what man program does.

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.

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.

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.

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.

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

* Re: dired-man can't deal with compressed pages
  2004-02-22  6:31 ` Eli Zaretskii
@ 2004-02-22 19:03   ` Juri Linkov
  2004-02-22 20:59     ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2004-02-22 19:03 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

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/

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

* Re: dired-man can't deal with compressed pages
  2004-02-22 19:03   ` Juri Linkov
@ 2004-02-22 20:59     ` Eli Zaretskii
  2004-02-22 21:59       ` Juri Linkov
                         ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-22 20:59 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Sun, 22 Feb 2004 21:03:02 +0200
> 
> 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.

The canonical Emacs solution to such situations is to try running
`man' with the -l switch and see if it barfs.

> I think it's better not to duplicate what man already does.

`man' doesn't do what we want except where it supports -l.

> Users can construct the command line as they want.

FWIW, I wouldn't give up on users without "man -l" so easily, but
that's me.

> Blindly running the file through all preprocessors will fail if some
> preprocessor is not installed.

??? Is that even possible?  I thought all the preprocessors we need
(eqn, tbl, refer, and soelim) are always installed as part of the
standard Troff/Groff/man packages.  How else would users be able to
format the pages they have?

> > 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.

Then perhaps dired-x should suggest using it on systems which don't
support "man -l", if the file at point requires that.

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

* Re: dired-man can't deal with compressed pages
  2004-02-22 20:59     ` Eli Zaretskii
@ 2004-02-22 21:59       ` Juri Linkov
  2004-02-23  6:09         ` Eli Zaretskii
  2004-02-23  3:42       ` Juri Linkov
  2004-02-23 15:28       ` Stefan Monnier
  2 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2004-02-22 21:59 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

"Eli Zaretskii" <eliz@elta.co.il> writes:
>> From: Juri Linkov <juri@jurta.org>
>> Date: Sun, 22 Feb 2004 21:03:02 +0200
>> 
>> 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.
>
> The canonical Emacs solution to such situations is to try running
> `man' with the -l switch and see if it barfs.

Seeing how man barfs will not help to construct an alternative
command line.

>> I think it's better not to duplicate what man already does.
>
> `man' doesn't do what we want except where it supports -l.

This is why I suggested that the user should be able to specify
how to uncompress compressed man files (guznip, uncompress, etc.)

>> Blindly running the file through all preprocessors will fail if some
>> preprocessor is not installed.
>
> ??? Is that even possible?  I thought all the preprocessors we need
> (eqn, tbl, refer, and soelim) are always installed as part of the
> standard Troff/Groff/man packages.  How else would users be able to
> format the pages they have?

Could you assure that all these preprocessors are available for all
man versions?

>> > 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.
>
> Then perhaps dired-x should suggest using it on systems which don't
> support "man -l", if the file at point requires that.

That would be good.

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

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

* Re: dired-man can't deal with compressed pages
  2004-02-22 20:59     ` Eli Zaretskii
  2004-02-22 21:59       ` Juri Linkov
@ 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
  2 siblings, 2 replies; 17+ messages in thread
From: Juri Linkov @ 2004-02-23  3:42 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

I have another argument for allowing users to specify command lines
they want for dired-man.  Recently there was a request on
bug-gnu-emacs for making perldoc to work on .pod files:

http://mail.gnu.org/archive/html/bug-gnu-emacs/2004-02/msg00073.html

But suggested addition of ("\\.pod\\'" "perldoc") entry to
dired-guess-shell-alist-user will not be useful because the output of
this command goes into the "*Shell command*" buffer where it is hardly
readable.

Instead of this I tried to place point on a .pod file, pressed "N" and
at the prompt displayed by the latest patch I typed "perldoc" RET,
and the buffer "*Man perlfaq.pod*" came nicely formatted in Man-mode.
This is because perldoc actually processes .pod files by a command
like "pod2man | nroff -man".

This means that reading a command for dired-man from the user is a
useful thing.

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

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

* Re: dired-man can't deal with compressed pages
  2004-02-22 21:59       ` Juri Linkov
@ 2004-02-23  6:09         ` Eli Zaretskii
  2004-02-23 19:07           ` Kevin Rodgers
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-23  6:09 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Sun, 22 Feb 2004 23:59:29 +0200
> 
> > The canonical Emacs solution to such situations is to try running
> > `man' with the -l switch and see if it barfs.
> 
> Seeing how man barfs will not help to construct an alternative
> command line.

One obvious choice is to fall back on what we have in dired-x now, if
no one comes up with a better alternative.

> >> I think it's better not to duplicate what man already does.
> >
> > `man' doesn't do what we want except where it supports -l.
> 
> This is why I suggested that the user should be able to specify
> how to uncompress compressed man files (guznip, uncompress, etc.)

I think Emacs can decide that by itself.  It does for Info files.

> > ??? Is that even possible?  I thought all the preprocessors we need
> > (eqn, tbl, refer, and soelim) are always installed as part of the
> > standard Troff/Groff/man packages.  How else would users be able to
> > format the pages they have?
> 
> Could you assure that all these preprocessors are available for all
> man versions?

I think having `man' installed guarantees that, but I don't regard
myself as an expert on this issue.  Does anyone know if the 4
preprocessors mentioned above are guaranteed to be installed with
`man'?

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

* Re: dired-man can't deal with compressed pages
  2004-02-23  3:42       ` Juri Linkov
@ 2004-02-23  6:12         ` Eli Zaretskii
  2004-02-23 18:57         ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-23  6:12 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Mon, 23 Feb 2004 05:42:38 +0200
> 
> This means that reading a command for dired-man from the user is a
> useful thing.

Perhaps as an option, e.g. when given a numeric argument.  But it
would be nice if Emacs could make a reasonably good guess on the
correct command given the file's file-name extension, for example.
That way, invoking the command without an argument would DTRT in most
cases.

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

* Re: dired-man can't deal with compressed pages
  2004-02-22 20:59     ` Eli Zaretskii
  2004-02-22 21:59       ` Juri Linkov
  2004-02-23  3:42       ` Juri Linkov
@ 2004-02-23 15:28       ` Stefan Monnier
  2004-02-23 18:57         ` Eli Zaretskii
  2 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2004-02-23 15:28 UTC (permalink / raw)
  Cc: Juri Linkov, emacs-devel, jidanni

> ??? Is that even possible?  I thought all the preprocessors we need
> (eqn, tbl, refer, and soelim) are always installed as part of the
> standard Troff/Groff/man packages.  How else would users be able to
> format the pages they have?

Last time I used Irix (it was several years ago, admittedly) it came with
a minimal man+nroff but not troff which was sold as a separate package.


        Stefan

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

* Re: dired-man can't deal with compressed pages
  2004-02-23 15:28       ` Stefan Monnier
@ 2004-02-23 18:57         ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-23 18:57 UTC (permalink / raw)
  Cc: juri, emacs-devel, jidanni

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: 23 Feb 2004 10:28:18 -0500
> 
> Last time I used Irix (it was several years ago, admittedly) it came with
> a minimal man+nroff but not troff which was sold as a separate package.

IIRC, Irix by default has only the formatted man pages.  So the
preprocessors are not needed there.

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

* Re: dired-man can't deal with compressed pages
  2004-02-23  3:42       ` Juri Linkov
  2004-02-23  6:12         ` Eli Zaretskii
@ 2004-02-23 18:57         ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: Richard Stallman @ 2004-02-23 18:57 UTC (permalink / raw)
  Cc: eliz, emacs-devel, jidanni

I'm not very interested in dired-x.el, and nobody is maintaining it,
so do what you like.

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

* Re: dired-man can't deal with compressed pages
  2004-02-23  6:09         ` Eli Zaretskii
@ 2004-02-23 19:07           ` Kevin Rodgers
  2004-02-23 19:51             ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Kevin Rodgers @ 2004-02-23 19:07 UTC (permalink / raw)



Eli Zaretskii wrote:
 >>From: Juri Linkov <juri@jurta.org>
 >>Date: Sun, 22 Feb 2004 23:59:29 +0200
...
 >>>??? Is that even possible?  I thought all the preprocessors we need
 >>>(eqn, tbl, refer, and soelim) are always installed as part of the
 >>>standard Troff/Groff/man packages.  How else would users be able to
 >>>format the pages they have?
 >>
 >>Could you assure that all these preprocessors are available for all
 >>man versions?
 >
 > I think having `man' installed guarantees that, but I don't regard
 > myself as an expert on this issue.  Does anyone know if the 4
 > preprocessors mentioned above are guaranteed to be installed with
 > `man'?

I don't think so, because some systems come with pre-processed man pages
which their `man` command finds in directories like /usr/man/cat1 or
/usr/man/sman1.  That's simply to speed things up and doesn't imply that
the troff preprocessors aren't also installed, but it certainly seems
possible that they could be missing on such systems.

-- 
Kevin Rodgers

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

* Re: dired-man can't deal with compressed pages
  2004-02-23 19:07           ` Kevin Rodgers
@ 2004-02-23 19:51             ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-23 19:51 UTC (permalink / raw)
  Cc: emacs-devel

> From: Kevin Rodgers <ihs_4664@yahoo.com>
> Date: Mon, 23 Feb 2004 12:07:24 -0700
>  >
>  > I think having `man' installed guarantees that, but I don't regard
>  > myself as an expert on this issue.  Does anyone know if the 4
>  > preprocessors mentioned above are guaranteed to be installed with
>  > `man'?
> 
> I don't think so, because some systems come with pre-processed man pages

Yes, Irix is one of them, for example.

But on those systems, the dired-x feature we are discussing doesn't
work already, right?

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

* Re: dired-man can't deal with compressed pages
  2004-02-22  0:45 dired-man can't deal with compressed pages Juri Linkov
  2004-02-22  6:31 ` Eli Zaretskii
@ 2004-02-23 23:36 ` Juri Linkov
  2004-02-24  6:21   ` Eli Zaretskii
  2004-02-24 19:26   ` Dan Jacobson
  1 sibling, 2 replies; 17+ messages in thread
From: Juri Linkov @ 2004-02-23 23:36 UTC (permalink / raw)
  Cc: jidanni

With all the comments so far I don't see a better solution than using
the existing dired extension mechanism for shell command guessing.
This means adding new entries to the predefined set of rules for shell
commands in `dired-guess-shell-alist-default' and using the
`dired-guess-shell-command' function in `dired-man' to ask user for a
shell command, whose output is displayed in Man-mode.  So, adding
these entries to `dired-guess-shell-alist-default' will have a twofold
usage: after pressing `!' on a file and selecting an appropriate
command its output is redirected to the *Shell Command Output* (this
is not very useful for man output).  Pressing `N' on a file will have
the same user interface for selecting a command, but its output will
be processed by man.el and displayed in Man-mode.  The user can
redefine his own set of shell commands guesses in .emacs, for example:

(setq dired-guess-shell-alist-user
      (list
       ;; Irix by default has only the formatted man pages
       (list "\\.[0-9]$" "cat")
       (list "\\.[0-9]\\.g?z$" "gunzip -qc")
       ;; Under HP-UX, "col -x" should be added
       (list "\\.pod$" "pod2man * | nroff -man | col -x")))

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	23 Feb 2004 22:12:19 -0000
***************
*** 915,938 ****
--- 915,973 ----
           '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                    " " dired-guess-shell-znew-switches))
  
+    ;; The following four extensions are useful with dired-man ("N" key)
+    '("\\.[0-9]$" "man -l" "cat * | tbl | nroff -man -h")
+    (list "\\.[0-9]\\.g?z$" "man -l" "gunzip -qc * | tbl | nroff -man -h"
+          ;; Optional decompression.
+          '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
+    (list "\\.[0-9]\\.Z$" "man -l" "zcat * | tbl | nroff -man -h"
+          ;; Optional conversion to gzip format.
+          '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
+                   " " dired-guess-shell-znew-switches))
+    '("\\.pod$" "perldoc" "pod2man * | nroff -man")
+ 
     '("\\.dvi$" "xdvi" "dvips")          ; preview and printing
     '("\\.au$" "play")                   ; play Sun audiofiles
     '("\\.mpg$" "mpeg_play")
***************
*** 1278,1285 ****
  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.
--- 1319,1328 ----
  Uses ../lisp/man.el of \\[manual-entry] fame."
    (interactive)
    (require 'man)
!   (let* ((file (dired-get-filename))
!          (manual-program (replace-regexp-in-string "\\*" "%s"
!                           (dired-guess-shell-command
!                            "Man command: " (list file)))))
      (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	23 Feb 2004 22:12:19 -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/

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

* Re: dired-man can't deal with compressed pages
  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
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2004-02-24  6:21 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Tue, 24 Feb 2004 01:36:00 +0200
> 
> So, adding
> these entries to `dired-guess-shell-alist-default' will have a twofold
> usage: after pressing `!' on a file and selecting an appropriate
> command its output is redirected to the *Shell Command Output* (this
> is not very useful for man output).  Pressing `N' on a file will have
> the same user interface for selecting a command, but its output will
> be processed by man.el and displayed in Man-mode.

FWIW, I like this approach, but I suggest that "man -l" be offered
only if Emacs can tell that the -l switch is supported.

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

* Re: dired-man can't deal with compressed pages
  2004-02-23 23:36 ` Juri Linkov
  2004-02-24  6:21   ` Eli Zaretskii
@ 2004-02-24 19:26   ` Dan Jacobson
  1 sibling, 0 replies; 17+ messages in thread
From: Dan Jacobson @ 2004-02-24 19:26 UTC (permalink / raw)


OK, I trust this bug is now in good hands, so you can take me off the CC list.
P.S. $ man ./file.1.gz always works here on debian. OK, never mind.
I now return to looking for fresh bugs.

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

* Re: dired-man can't deal with compressed pages
  2004-02-24  6:21   ` Eli Zaretskii
@ 2004-02-24 22:03     ` Juri Linkov
  0 siblings, 0 replies; 17+ messages in thread
From: Juri Linkov @ 2004-02-24 22:03 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

Eli Zaretskii <eliz@elta.co.il> writes:
> FWIW, I like this approach, but I suggest that "man -l" be offered
> only if Emacs can tell that the -l switch is supported.

Yes, it would be good:

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	24 Feb 2004 21:54:09 -0000
***************
*** 915,938 ****
--- 915,982 ----
           '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                    " " dired-guess-shell-znew-switches))
  
+    ;; The following four extensions are useful with dired-man ("N" key)
+    (list "\\.[0-9]$" '(progn (require 'man)
+                              (if (Man-support-local-filenames)
+                                  "man -l"
+                                "cat * | tbl | nroff -man -h")))
+    (list "\\.[0-9]\\.g?z$" '(progn (require 'man)
+                                    (if (Man-support-local-filenames)
+                                        "man -l"
+                                      "gunzip -qc * | tbl | nroff -man -h"))
+          ;; Optional decompression.
+          '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
+    (list "\\.[0-9]\\.Z$" '(progn (require 'man)
+                                  (if (Man-support-local-filenames)
+                                      "man -l"
+                                    "zcat * | tbl | nroff -man -h"))
+          ;; Optional conversion to gzip format.
+          '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
+                   " " dired-guess-shell-znew-switches))
+    '("\\.pod$" "perldoc" "pod2man * | nroff -man")
+ 
     '("\\.dvi$" "xdvi" "dvips")          ; preview and printing
     '("\\.au$" "play")                   ; play Sun audiofiles
     '("\\.mpg$" "mpeg_play")
***************
*** 1278,1285 ****
  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.
--- 1328,1337 ----
  Uses ../lisp/man.el of \\[manual-entry] fame."
    (interactive)
    (require 'man)
!   (let* ((file (dired-get-filename))
!          (manual-program (replace-regexp-in-string "\\*" "%s"
!                           (dired-guess-shell-command
!                            "Man command: " (list file)))))
      (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	24 Feb 2004 21:54:10 -0000
***************
*** 317,322 ****
--- 331,343 ----
      "")
    "Option that indicates a specified a manual section name.")
  
+ (defvar Man-support-local-filenames 'auto-detect
+   "If t, `man' supports `-l' option and can interpret command
+ line arguments as local filenames.  If nil, it don't support
+ `-l'.  The default value of this variable is set up by
+ `Man-support-local-filenames' function.  Use this function to
+ get the value of `Man-support-local-filenames' variable.")
+ 
  ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ;; end user variables
  \f
***************
*** 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)))
--- 507,521 ----
  (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)))
***************
*** 555,560 ****
--- 578,599 ----
  		  slist nil))))
        (concat Man-specified-section-option section " " name))))
  
+ (defun Man-support-local-filenames ()
+   "Check the availability of `-l' option."
+   (if (or (not Man-support-local-filenames)
+           (eq Man-support-local-filenames t))
+       Man-support-local-filenames
+     (setq Man-support-local-filenames
+           (with-temp-buffer
+             (and (equal (condition-case nil
+                             (call-process manual-program nil t nil "--help")
+                           (error nil))
+                         0)
+                  (progn
+                    (goto-char (point-min))
+                    (search-forward "--local-file" nil t))
+                  t)))))
+ 
  \f
  ;; ======================================================================
  ;; default man entry: get word under point

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

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

end of thread, other threads:[~2004-02-24 22:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).