aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2011-03-02 00:31:47 -0800
committerGlenn Morris2011-03-02 00:31:47 -0800
commit3ab7ebb9c598e33b1b90b3fe7adedf86c6ec8a48 (patch)
treec1eb4a7e4183581fe98d2660be10d86f203e092b
parent2777ccbfdea689327c54278ff6b5303c1fe8bac0 (diff)
downloademacs-3ab7ebb9c598e33b1b90b3fe7adedf86c6ec8a48.tar.gz
emacs-3ab7ebb9c598e33b1b90b3fe7adedf86c6ec8a48.zip
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.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/dired-x.el34
-rw-r--r--lisp/man.el56
3 files changed, 51 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 744b8dd5bac..6c91a30df54 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12011-03-02 Glenn Morris <rgm@gnu.org> 12011-03-02 Glenn Morris <rgm@gnu.org>
2 2
3 * man.el (Man-support-local-filenames): Also handle Red Hat's man.
4 * dired-x.el (Man-support-local-filenames): Autoload it.
5 (dired-guess-shell-alist-default): Also handle Red Hat's man.
6
3 * dired-x.el (dired-default-directory-alist, dired-default-directory): 7 * dired-x.el (dired-default-directory-alist, dired-default-directory):
4 Mark as obsolete. 8 Mark as obsolete.
5 (dired-smart-shell-command): Just call dired-current-directory. 9 (dired-smart-shell-command): Just call dired-current-directory.
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index a049bd00ccd..94398687d11 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -860,7 +860,7 @@ replace it with a dir-locals-file `./%s'"
860;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not 860;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not
861;; install GNU zip's version of zcat. 861;; install GNU zip's version of zcat.
862 862
863(declare-function Man-support-local-filenames "man" ()) 863(autoload 'Man-support-local-filenames "man")
864 864
865(defvar dired-guess-shell-alist-default 865(defvar dired-guess-shell-alist-default
866 (list 866 (list
@@ -953,20 +953,28 @@ replace it with a dir-locals-file `./%s'"
953 " " dired-guess-shell-znew-switches)) 953 " " dired-guess-shell-znew-switches))
954 954
955 ;; The following four extensions are useful with dired-man ("N" key) 955 ;; The following four extensions are useful with dired-man ("N" key)
956 (list "\\.\\(?:[0-9]\\|man\\)\\'" '(progn (require 'man) 956 ;; FIXME "man ./" does not work with dired-do-shell-command,
957 (if (Man-support-local-filenames) 957 ;; because there seems to be no way for us to modify the filename,
958 "man -l" 958 ;; only the command. Hmph. `dired-man' works though.
959 "cat * | tbl | nroff -man -h"))) 959 ;; `dired-man' does
960 (list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'" '(progn (require 'man) 960 (list "\\.\\(?:[0-9]\\|man\\)\\'" '(let ((loc (Man-support-local-filenames)))
961 (if (Man-support-local-filenames) 961 (cond ((eq loc 'man-db) "man -l")
962 "man -l" 962 ((eq loc 'man) "man ./")
963 "gunzip -qc * | tbl | nroff -man -h")) 963 (t
964 "cat * | tbl | nroff -man -h"))))
965 (list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'"
966 '(let ((loc (Man-support-local-filenames)))
967 (cond ((eq loc 'man-db)
968 "man -l")
969 ((eq loc 'man)
970 "man ./")
971 (t "gunzip -qc * | tbl | nroff -man -h")))
964 ;; Optional decompression. 972 ;; Optional decompression.
965 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) 973 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
966 (list "\\.[0-9]\\.Z\\'" '(progn (require 'man) 974 (list "\\.[0-9]\\.Z\\'" '(let ((loc (Man-support-local-filenames)))
967 (if (Man-support-local-filenames) 975 (cond ((eq loc 'man-db) "man -l")
968 "man -l" 976 ((eq loc 'man) "man ./")
969 "zcat * | tbl | nroff -man -h")) 977 (t "zcat * | tbl | nroff -man -h")))
970 ;; Optional conversion to gzip format. 978 ;; Optional conversion to gzip format.
971 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") 979 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
972 " " dired-guess-shell-znew-switches)) 980 " " dired-guess-shell-znew-switches))
diff --git a/lisp/man.el b/lisp/man.el
index 0b3ac537c5b..c8c2f8653e2 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -623,36 +623,32 @@ and the `Man-section-translations-alist' variables)."
623 (concat Man-specified-section-option section " " name)))) 623 (concat Man-specified-section-option section " " name))))
624 624
625(defun Man-support-local-filenames () 625(defun Man-support-local-filenames ()
626 "Check the availability of `-l' option of the man command. 626 "Return non-nil if the man command supports local filenames.
627This option allows `man' to interpret command line arguments 627Different man programs support this feature in different ways.
628as local filenames. 628The default Debian man program (\"man-db\") has a `--local-file'
629Return the value of the variable `Man-support-local-filenames' 629\(or `-l') option for this purpose. The default Red Hat man
630if it was set to nil or t before the call of this function. 630program has no such option, but interprets any name containing
631If t, the man command supports `-l' option. If nil, it doesn't. 631a \"/\" as a local filename. The function returns either `man-db'
632Otherwise, if the value of `Man-support-local-filenames' 632`man', or nil."
633is neither t nor nil, then determine a new value, set it 633 (if (eq Man-support-local-filenames 'auto-detect)
634to the variable `Man-support-local-filenames' and return 634 (setq Man-support-local-filenames
635a new value." 635 (with-temp-buffer
636 (if (or (not Man-support-local-filenames) 636 (let ((default-directory
637 (eq Man-support-local-filenames t)) 637 ;; Ensure that `default-directory' exists and is readable.
638 Man-support-local-filenames 638 (if (and (file-directory-p default-directory)
639 (setq Man-support-local-filenames 639 (file-readable-p default-directory))
640 (with-temp-buffer 640 default-directory
641 (and (equal (condition-case nil 641 (expand-file-name "~/"))))
642 (let ((default-directory 642 (ignore-errors
643 ;; Assure that `default-directory' exists 643 (call-process manual-program nil t nil "--help")))
644 ;; and is readable. 644 (cond ((search-backward "--local-file" nil 'move)
645 (if (and (file-directory-p default-directory) 645 'man-db)
646 (file-readable-p default-directory)) 646 ;; This feature seems to be present in at least ver 1.4f,
647 default-directory 647 ;; which is about 20 years old.
648 (expand-file-name "~/")))) 648 ;; I don't know if this version has an official name?
649 (call-process manual-program nil t nil "--help")) 649 ((looking-at "^man, versione? [1-9]")
650 (error nil)) 650 'man))))
651 0) 651 Man-support-local-filenames))
652 (progn
653 (goto-char (point-min))
654 (search-forward "--local-file" nil t))
655 t)))))
656 652
657 653
658;; ====================================================================== 654;; ======================================================================