X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/6e7e47f6e18bc53a0445fa920724444888995748..a5743acc05a500b9746f8815dd4d3c6bddf2c931:/lisp/man.el diff --git a/lisp/man.el b/lisp/man.el index 52645b6151..719b12ee9d 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -3,8 +3,8 @@ ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. ;; Author: Barry A. Warsaw -;; Last-Modified: $Date: 1994/10/24 15:34:50 $ -;; Version: $Revision: 1.55 $ +;; Last-Modified: $Date: 1994/11/09 12:38:31 $ +;; Version: $Revision: 1.59 $ ;; Keywords: help ;; Adapted-By: ESR, pot @@ -83,9 +83,8 @@ ;; headers, and after the page footer. But it is possible to compute ;; the number of blank lines before the page footer by euristhics ;; only. Is it worth doing? -;; - Allow the Man-reuse-okay-flag to be set to 'always, meaning that all -;; the manpages should go in the same buffer, where they can be browsed -;; with M-n and M-p. +;; - Allow a user option to mean that all the manpages should go in +;; the same buffer, where they can be browsed with M-n and M-p. ;; - Allow completion on the manpage name when calling man. This ;; requires a reliable list of places where manpages can be found. The ;; drawback would be that if the list is not complete, the user might @@ -145,13 +144,6 @@ Any other value of `Man-notify-method' is equivalent to `meek'.") (defvar Man-frame-parameters nil "*Frame parameter list for creating a new frame for a manual page.") -(defvar Man-reuse-okay-flag t - "*Reuse a manpage buffer if possible. -If non-nil, and a manpage buffer already exists with the same -invocation, man just indicates the manpage is ready according to the -value of `Man-notify-method'. When nil, it always fires off a -background process,putting the results in a uniquely named buffer.") - (defvar Man-downcase-section-letters-flag t "*Letters in sections are converted to lower case. Some Un*x man commands can't handle uppercase letters in sections, for @@ -266,6 +258,7 @@ This regular expression should start with a `^' character.") /\b/ { s/_\b//g s/\b_//g s/o\b+/o/g + s/+\bo/o/g :ovstrk s/\\(.\\)\b\\1/\\1/g t ovstrk @@ -277,6 +270,7 @@ This regular expression should start with a `^' character.") /\b/ { s/_\b//g\\ s/\b_//g\\ s/o\b+/o/g\\ + s/+\bo/o/g\\ :ovstrk\\ s/\\(.\\)\b\\1/\\1/g\\ t ovstrk\\ @@ -503,31 +497,25 @@ default section number is selected from `Man-auto-section-alist'." (defalias 'manual-entry 'man) ;;;###autoload -(defun man (man-args prefix-arg) +(defun man (man-args) "Get a Un*x manual page and put it in a buffer. This command is the top-level command in the man package. It runs a Un*x command to retrieve and clean a manpage in the background and places the results in a Man mode (manpage browsing) buffer. See variable `Man-notify-method' for what happens when the buffer is ready. -Normally, if a buffer already exists for this man page, it will display -immediately; either a prefix argument or a nil value to `Man-reuse-okay-flag' -overrides this and forces the man page to be regenerated." +If a buffer already exists for this man page, it will display immediately." (interactive - (list - ;; first argument - (let* ((default-entry (Man-default-man-entry)) - (input (read-string - (format "Manual entry%s: " - (if (string= default-entry "") - "" - (format " (default %s)" default-entry)))))) - (if (string= input "") - (if (string= default-entry "") - (error "No man args given") - default-entry) - input)) - ;; second argument - current-prefix-arg)) + (list (let* ((default-entry (Man-default-man-entry)) + (input (read-string + (format "Manual entry%s: " + (if (string= default-entry "") + "" + (format " (default %s)" default-entry)))))) + (if (string= input "") + (if (string= default-entry "") + (error "No man args given") + default-entry) + input)))) ;; Init the man package variables, if not already done. (Man-init-defvars) @@ -536,20 +524,15 @@ overrides this and forces the man page to be regenerated." ;; "section subject" syntax and possibly downcase the section. (setq man-args (Man-translate-references man-args)) - (Man-getpage-in-background man-args (consp prefix-arg))) + (Man-getpage-in-background man-args)) -(defun Man-getpage-in-background (topic &optional override-reuse-p) - "Uses TOPIC to build and fire off the manpage and cleaning command. -Optional OVERRIDE-REUSE-P, when non-nil, means to -start a background process even if a buffer already exists and -`Man-reuse-okay-flag' is non-nil." +(defun Man-getpage-in-background (topic) + "Uses TOPIC to build and fire off the manpage and cleaning command." (let* ((man-args topic) (bufname (concat "*Man " man-args "*")) (buffer (get-buffer bufname))) - (if (and Man-reuse-okay-flag - (not override-reuse-p) - buffer) + (if buffer (Man-notify-when-ready buffer) (require 'env) (message "Invoking %s %s in the background" manual-program man-args) @@ -564,8 +547,7 @@ start a background process even if a buffer already exists and (set-process-sentinel (start-process manual-program buffer "sh" "-c" (format (Man-build-man-command) man-args)) - 'Man-bgproc-sentinel)) - ))) + 'Man-bgproc-sentinel))))) (defun Man-notify-when-ready (man-buffer) "Notify the user when MAN-BUFFER is ready. @@ -636,8 +618,8 @@ Same for the ANSI bold and normal escape sequences." (replace-match "\\1") (put-text-property (1- (point)) (point) 'face Man-overstrike-face)) (goto-char (point-min)) - (while (search-forward "o\b+" nil t) - (backward-delete-char 2) + (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) + (replace-match "o") (put-text-property (1- (point)) (point) 'face 'bold)) (goto-char (point-min)) (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) @@ -662,7 +644,7 @@ Same for the ANSI bold and normal escape sequences." (goto-char (point-min)) (while (re-search-forward "\e\\[[0-9]+m" nil t) (replace-match "")) (goto-char (point-min)) - (while (search-forward "o\b+" nil t) (backward-delete-char 2)) + (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) (replace-match "o")) )) (goto-char (point-min)) (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) (replace-match "+")) @@ -679,44 +661,43 @@ Same for the ANSI bold and normal escape sequences." (save-excursion (set-buffer Man-buffer) - (save-match-data - (let ((case-fold-search nil)) - (goto-char (point-min)) - (cond ((or (looking-at "No \\(manual \\)*entry for") - (looking-at "[^\n]*: nothing appropriate$")) - (setq err-mess (buffer-substring (point) - (progn - (end-of-line) (point))) - delete-buff t)) - ((not (and (eq (process-status process) 'exit) - (= (process-exit-status process) 0))) - (setq err-mess - (concat (buffer-name Man-buffer) - ": process " - (let ((eos (1- (length msg)))) - (if (= (aref msg eos) ?\n) - (substring msg 0 eos) msg)))) - (goto-char (point-max)) - (insert (format "\nprocess %s" msg)) - )) - (if delete-buff - (kill-buffer Man-buffer) - (if Man-fontify-manpage-flag - (Man-fontify-manpage) - (Man-cleanup-manpage)) - (run-hooks 'Man-cooked-hook) - (Man-mode) - (set-buffer-modified-p nil) - )) - ;; Restore case-fold-search before calling - ;; Man-notify-when-ready because it may switch buffers. - - (if (not delete-buff) - (Man-notify-when-ready Man-buffer)) - - (if err-mess - (error err-mess)) - ))))) + (let ((case-fold-search nil)) + (goto-char (point-min)) + (cond ((or (looking-at "No \\(manual \\)*entry for") + (looking-at "[^\n]*: nothing appropriate$")) + (setq err-mess (buffer-substring (point) + (progn + (end-of-line) (point))) + delete-buff t)) + ((not (and (eq (process-status process) 'exit) + (= (process-exit-status process) 0))) + (setq err-mess + (concat (buffer-name Man-buffer) + ": process " + (let ((eos (1- (length msg)))) + (if (= (aref msg eos) ?\n) + (substring msg 0 eos) msg)))) + (goto-char (point-max)) + (insert (format "\nprocess %s" msg)) + )) + (if delete-buff + (kill-buffer Man-buffer) + (if Man-fontify-manpage-flag + (Man-fontify-manpage) + (Man-cleanup-manpage)) + (run-hooks 'Man-cooked-hook) + (Man-mode) + (set-buffer-modified-p nil) + )) + ;; Restore case-fold-search before calling + ;; Man-notify-when-ready because it may switch buffers. + + (if (not delete-buff) + (Man-notify-when-ready Man-buffer)) + + (if err-mess + (error err-mess)) + )))) ;; ====================================================================== @@ -744,7 +725,6 @@ The following variables may be of some use. Try \"\\[describe-variable] RET\" for more information: Man-notify-method What happens when manpage formatting is done. -Man-reuse-okay-flag Reuse already formatted buffer. Man-downcase-section-letters-flag Force section letters to lower case. Man-circular-pages-flag Treat multiple manpage list as circular. Man-auto-section-alist List of major modes and their section numbers. @@ -969,15 +949,13 @@ Actually the section moved to is described by `Man-see-also-regexp'." (error (concat "No " Man-see-also-regexp " section found in the current manpage")))) -(defun Man-follow-manual-reference (arg reference) +(defun Man-follow-manual-reference (reference) "Get one of the manpages referred to in the \"SEE ALSO\" section. -Specify which reference to use; default is based on word at point. -Prefix argument ARG is passed to `Man-getpage-in-background'." +Specify which reference to use; default is based on word at point." (interactive (if (not Man-refpages-alist) (error "There are no references in the current man page") - (list current-prefix-arg - (let* ((default (or + (list (let* ((default (or (car (all-completions (save-excursion (skip-syntax-backward "w()") @@ -1001,8 +979,7 @@ Prefix argument ARG is passed to `Man-getpage-in-background'." (error "Can't find any references in the current manpage") (aput 'Man-refpages-alist reference) (Man-getpage-in-background - (Man-translate-references (aheadsym Man-refpages-alist)) - arg))) + (Man-translate-references (aheadsym Man-refpages-alist))))) (defun Man-kill () "Kill the buffer containing the manpage."