aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2004-03-23 07:33:39 +0000
committerJuri Linkov2004-03-23 07:33:39 +0000
commitaec2bd36f16c616957b684e7b60f7dba4b378554 (patch)
tree45c8472f655fac593b74d7c69a3959c76f05fe02
parentd4411cef6e5b6f955eed862cc465e3a0f5a2f46d (diff)
downloademacs-aec2bd36f16c616957b684e7b60f7dba4b378554.tar.gz
emacs-aec2bd36f16c616957b684e7b60f7dba4b378554.zip
(Man-width): New var.
(Man-getpage-in-background): Use it. (Man-support-local-filenames): New var and fun. (Man-build-man-command): Don't add a second %s. (Man-fontify-manpage): Clean up message. (Man-mode): Set outline-regexp, outline-level, imenu-generic-expression.
-rw-r--r--lisp/man.el72
1 files changed, 62 insertions, 10 deletions
diff --git a/lisp/man.el b/lisp/man.el
index 0e665af723e..7222c1bad15 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1,6 +1,6 @@
1;;; man.el --- browse UNIX manual pages -*- coding: iso-8859-1 -*- 1;;; man.el --- browse UNIX manual pages -*- coding: iso-8859-1 -*-
2 2
3;; Copyright (C) 1993, 1994, 1996, 1997, 2001, 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1996, 1997, 2001, 2003, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Barry A. Warsaw <bwarsaw@cen.com> 5;; Author: Barry A. Warsaw <bwarsaw@cen.com>
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -175,6 +175,17 @@ Any other value of `Man-notify-method' is equivalent to `meek'."
175 (const polite) (const quiet) (const meek)) 175 (const polite) (const quiet) (const meek))
176 :group 'man) 176 :group 'man)
177 177
178(defcustom Man-width nil
179 "*Number of columns for which manual pages should be formatted.
180If nil, the width of the window selected at the moment of man
181invocation is used. If non-nil, the width of the frame selected
182at the moment of man invocation is used. The value also can be a
183positive integer."
184 :type '(choice (const :tag "Window width" nil)
185 (const :tag "Frame width" t)
186 (integer :tag "Specific width" :value 65))
187 :group 'man)
188
178(defcustom Man-frame-parameters nil 189(defcustom Man-frame-parameters nil
179 "*Frame parameter list for creating a new frame for a manual page." 190 "*Frame parameter list for creating a new frame for a manual page."
180 :type 'sexp 191 :type 'sexp
@@ -317,6 +328,12 @@ make -a one of the switches, if your `man' program supports it.")
317 "") 328 "")
318 "Option that indicates a specified a manual section name.") 329 "Option that indicates a specified a manual section name.")
319 330
331(defvar Man-support-local-filenames 'auto-detect
332 "Internal cache for the value of the function `Man-support-local-filenames'.
333`auto-detect' means the value is not yet determined.
334Otherwise, the value is whatever the function
335`Man-support-local-filenames' should return.")
336
320;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 337;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321;; end user variables 338;; end user variables
322 339
@@ -486,13 +503,15 @@ This is necessary if one wants to dump man.el with Emacs."
486(defsubst Man-build-man-command () 503(defsubst Man-build-man-command ()
487 "Builds the entire background manpage and cleaning command." 504 "Builds the entire background manpage and cleaning command."
488 (let ((command (concat manual-program " " Man-switches 505 (let ((command (concat manual-program " " Man-switches
489 ; Stock MS-DOS shells cannot redirect stderr; 506 (cond
490 ; `call-process' below sends it to /dev/null, 507 ;; Already has %s
491 ; so we don't need `2>' even with DOS shells 508 ((string-match "%s" manual-program) "")
492 ; which do support stderr redirection. 509 ;; Stock MS-DOS shells cannot redirect stderr;
493 (if (not (fboundp 'start-process)) 510 ;; `call-process' below sends it to /dev/null,
494 " %s" 511 ;; so we don't need `2>' even with DOS shells
495 (concat " %s 2>" null-device)))) 512 ;; which do support stderr redirection.
513 ((not (fboundp 'start-process)) " %s")
514 ((concat " %s 2>" null-device)))))
496 (flist Man-filter-list)) 515 (flist Man-filter-list))
497 (while (and flist (car flist)) 516 (while (and flist (car flist))
498 (let ((pcom (car (car flist))) 517 (let ((pcom (car (car flist)))
@@ -555,6 +574,31 @@ and the Man-section-translations-alist variables)."
555 slist nil)))) 574 slist nil))))
556 (concat Man-specified-section-option section " " name)))) 575 (concat Man-specified-section-option section " " name))))
557 576
577(defun Man-support-local-filenames ()
578 "Check the availability of `-l' option of the man command.
579This option allows `man' to interpret command line arguments
580as local filenames.
581Return the value of the variable `Man-support-local-filenames'
582if it was set to nil or t before the call of this function.
583If t, the man command supports `-l' option. If nil, it don't.
584Otherwise, if the value of `Man-support-local-filenames'
585is neither t nor nil, then determine a new value, set it
586to the variable `Man-support-local-filenames' and return
587a new value."
588 (if (or (not Man-support-local-filenames)
589 (eq Man-support-local-filenames t))
590 Man-support-local-filenames
591 (setq Man-support-local-filenames
592 (with-temp-buffer
593 (and (equal (condition-case nil
594 (call-process manual-program nil t nil "--help")
595 (error nil))
596 0)
597 (progn
598 (goto-char (point-min))
599 (search-forward "--local-file" nil t))
600 t)))))
601
558 602
559;; ====================================================================== 603;; ======================================================================
560;; default man entry: get word under point 604;; default man entry: get word under point
@@ -679,7 +723,12 @@ all sections related to a subject, put something appropriate into the
679 ;; This isn't strictly correct, since we don't know how 723 ;; This isn't strictly correct, since we don't know how
680 ;; the page will actually be displayed, but it seems 724 ;; the page will actually be displayed, but it seems
681 ;; reasonable. 725 ;; reasonable.
682 (setenv "COLUMNS" (number-to-string (frame-width))))) 726 (setenv "COLUMNS" (number-to-string
727 (cond
728 ((and (integerp Man-width) (> Man-width 0))
729 Man-width)
730 (Man-width (frame-width))
731 ((window-width)))))))
683 (setenv "GROFF_NO_SGR" "1") 732 (setenv "GROFF_NO_SGR" "1")
684 (if (fboundp 'start-process) 733 (if (fboundp 'start-process)
685 (set-process-sentinel 734 (set-process-sentinel
@@ -757,7 +806,7 @@ See the variable `Man-notify-method' for the different notification behaviors."
757 "Convert overstriking and underlining to the correct fonts. 806 "Convert overstriking and underlining to the correct fonts.
758Same for the ANSI bold and normal escape sequences." 807Same for the ANSI bold and normal escape sequences."
759 (interactive) 808 (interactive)
760 (message "Please wait: making up the %s man page..." Man-arguments) 809 (message "Please wait: formatting the %s man page..." Man-arguments)
761 (goto-char (point-min)) 810 (goto-char (point-min))
762 (while (search-forward "\e[1m" nil t) 811 (while (search-forward "\e[1m" nil t)
763 (delete-backward-char 4) 812 (delete-backward-char 4)
@@ -976,6 +1025,9 @@ The following key bindings are currently in effect in the buffer:
976 (auto-fill-mode -1) 1025 (auto-fill-mode -1)
977 (use-local-map Man-mode-map) 1026 (use-local-map Man-mode-map)
978 (set-syntax-table man-mode-syntax-table) 1027 (set-syntax-table man-mode-syntax-table)
1028 (setq imenu-generic-expression (list (list nil Man-heading-regexp 0)))
1029 (set (make-local-variable 'outline-regexp) Man-heading-regexp)
1030 (set (make-local-variable 'outline-level) (lambda () 1))
979 (Man-build-page-list) 1031 (Man-build-page-list)
980 (Man-strip-page-headers) 1032 (Man-strip-page-headers)
981 (Man-unindent) 1033 (Man-unindent)