emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired-man can't deal with compressed pages


From: Juri Linkov
Subject: Re: dired-man can't deal with compressed pages
Date: Tue, 24 Feb 2004 01:36:00 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]