emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r103477: Add some dired-x support for


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103477: Add some dired-x support for local filenames with Red Hat's man.
Date: Wed, 02 Mar 2011 00:31:47 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103477
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Wed 2011-03-02 00:31:47 -0800
message:
  Add some dired-x support for local filenames with Red Hat's man.
  
  * lisp/man.el (Man-support-local-filenames): Also handle Red Hat's man.
  
  * lisp/dired-x.el (Man-support-local-filenames): Autoload it.
  (dired-guess-shell-alist-default): Also handle Red Hat's man.
modified:
  lisp/ChangeLog
  lisp/dired-x.el
  lisp/man.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-03-02 07:59:02 +0000
+++ b/lisp/ChangeLog    2011-03-02 08:31:47 +0000
@@ -1,5 +1,9 @@
 2011-03-02  Glenn Morris  <address@hidden>
 
+       * man.el (Man-support-local-filenames): Also handle Red Hat's man.
+       * dired-x.el (Man-support-local-filenames): Autoload it.
+       (dired-guess-shell-alist-default): Also handle Red Hat's man.
+
        * dired-x.el (dired-default-directory-alist, dired-default-directory):
        Mark as obsolete.
        (dired-smart-shell-command): Just call dired-current-directory.

=== modified file 'lisp/dired-x.el'
--- a/lisp/dired-x.el   2011-03-02 07:59:02 +0000
+++ b/lisp/dired-x.el   2011-03-02 08:31:47 +0000
@@ -860,7 +860,7 @@
 ;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files.  Some do not
 ;; install GNU zip's version of zcat.
 
-(declare-function Man-support-local-filenames "man" ())
+(autoload 'Man-support-local-filenames "man")
 
 (defvar dired-guess-shell-alist-default
   (list
@@ -953,20 +953,28 @@
                  " " dired-guess-shell-znew-switches))
 
    ;; The following four extensions are useful with dired-man ("N" key)
-   (list "\\.\\(?:[0-9]\\|man\\)\\'" '(progn (require 'man)
-                                          (if (Man-support-local-filenames)
-                                              "man -l"
-                                            "cat * | tbl | nroff -man -h")))
-   (list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'" '(progn (require 'man)
-                                                (if 
(Man-support-local-filenames)
-                                                    "man -l"
-                                                  "gunzip -qc * | tbl | nroff 
-man -h"))
+   ;; FIXME "man ./" does not work with dired-do-shell-command,
+   ;; because there seems to be no way for us to modify the filename,
+   ;; only the command.  Hmph.  `dired-man' works though.
+   ;; `dired-man'  does
+   (list "\\.\\(?:[0-9]\\|man\\)\\'" '(let ((loc 
(Man-support-local-filenames)))
+                                        (cond ((eq loc 'man-db) "man -l")
+                                              ((eq loc 'man) "man ./")
+                                              (t
+                                               "cat * | tbl | nroff -man 
-h"))))
+   (list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'"
+         '(let ((loc (Man-support-local-filenames)))
+            (cond ((eq loc 'man-db)
+                   "man -l")
+                  ((eq loc 'man)
+                   "man ./")
+                  (t "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"))
+   (list "\\.[0-9]\\.Z\\'" '(let ((loc (Man-support-local-filenames)))
+                              (cond ((eq loc 'man-db) "man -l")
+                                    ((eq loc 'man) "man ./")
+                                    (t "zcat * | tbl | nroff -man -h")))
         ;; Optional conversion to gzip format.
         '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
                  " " dired-guess-shell-znew-switches))

=== modified file 'lisp/man.el'
--- a/lisp/man.el       2011-01-26 08:36:39 +0000
+++ b/lisp/man.el       2011-03-02 08:31:47 +0000
@@ -623,36 +623,32 @@
       (concat Man-specified-section-option section " " name))))
 
 (defun Man-support-local-filenames ()
-  "Check the availability of `-l' option of the man command.
-This option allows `man' to interpret command line arguments
-as local filenames.
-Return the value of the variable `Man-support-local-filenames'
-if it was set to nil or t before the call of this function.
-If t, the man command supports `-l' option.  If nil, it doesn't.
-Otherwise, if the value of `Man-support-local-filenames'
-is neither t nor nil, then determine a new value, set it
-to the variable `Man-support-local-filenames' and return
-a new value."
-  (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
-                           (let ((default-directory
-                                   ;; Assure that `default-directory' exists
-                                   ;; and is readable.
-                                   (if (and (file-directory-p 
default-directory)
-                                            (file-readable-p 
default-directory))
-                                       default-directory
-                                     (expand-file-name "~/"))))
-                             (call-process manual-program nil t nil "--help"))
-                          (error nil))
-                        0)
-                 (progn
-                   (goto-char (point-min))
-                   (search-forward "--local-file" nil t))
-                 t)))))
+  "Return non-nil if the man command supports local filenames.
+Different man programs support this feature in different ways.
+The default Debian man program (\"man-db\") has a `--local-file'
+\(or `-l') option for this purpose.  The default Red Hat man
+program has no such option, but interprets any name containing
+a \"/\" as a local filename.  The function returns either `man-db'
+`man', or nil."
+  (if (eq Man-support-local-filenames 'auto-detect)
+      (setq Man-support-local-filenames
+            (with-temp-buffer
+              (let ((default-directory
+                      ;; Ensure that `default-directory' exists and is 
readable.
+                      (if (and (file-directory-p default-directory)
+                               (file-readable-p default-directory))
+                        default-directory
+                        (expand-file-name "~/"))))
+                (ignore-errors
+                  (call-process manual-program nil t nil "--help")))
+              (cond ((search-backward "--local-file" nil 'move)
+                     'man-db)
+                    ;; This feature seems to be present in at least ver 1.4f,
+                    ;; which is about 20 years old.
+                    ;; I don't know if this version has an official name?
+                    ((looking-at "^man, versione? [1-9]")
+                     'man))))
+    Man-support-local-filenames))
 
 
 ;; ======================================================================


reply via email to

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