all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: jidanni@jidanni.org
Subject: Re: dired-man can't deal with compressed pages
Date: Tue, 24 Feb 2004 01:36:00 +0200	[thread overview]
Message-ID: <874qthe5cv.fsf@mail.jurta.org> (raw)
In-Reply-To: 87r7wolz6u.fsf@mail.jurta.org

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/

  parent reply	other threads:[~2004-02-23 23:36 UTC|newest]

Thread overview: 18+ 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
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 [this message]
2004-02-24  6:21   ` Eli Zaretskii
2004-02-24 22:03     ` Juri Linkov
2004-02-24 19:26   ` Dan Jacobson
  -- strict thread matches above, loose matches on Subject: below --
2003-09-12 22:45 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

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

  git send-email \
    --in-reply-to=874qthe5cv.fsf@mail.jurta.org \
    --to=juri@jurta.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 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.