# HG changeset patch # User Jim Blandy # Date 741941971 0 # Node ID 511feb3c2874eb10a4ad6c018aebc77ea7c0ae6b # Parent 20abae0de304929708c2c01edf63d83a69543a8c * man.el (Man-build-man-command): Don't leave a pipe symbol at the end of the command list if Man-filter-list is nil. (Man-default-man-args): Don't write out assq and mapconcat. (Man-default-man-entry): Don't default to section 2 for C-mode. Call Man-default-man-args, and let people use Man-auto-section-alist if this is what they want. (manual-entry): Call Man-translate-references, instead of writing it out. (Man-getpage-in-background): Don't apply Man-default-man-args here; manual-entry has already run it, and Man-follow-manual-reference provides the sections itself. diff -r 20abae0de304 -r 511feb3c2874 lisp/man.el --- a/lisp/man.el Tue Jul 06 06:57:49 1993 +0000 +++ b/lisp/man.el Tue Jul 06 06:59:31 1993 +0000 @@ -254,7 +254,7 @@ (defun Man-build-man-command () "Builds the entire background manpage and cleaning command." - (let ((command (concat "man " Man-switches " %s 2>&1 | ")) + (let ((command (concat "man " Man-switches " %s 2>&1")) (flist Man-filter-list)) (while flist (let ((pcom (car (car flist))) @@ -263,11 +263,9 @@ (if (or (not (stringp pcom)) (not (listp pargs))) (error "malformed Man-filter-list.")) - (setq command (concat command pcom + (setq command (concat command " | " pcom (mapconcat '(lambda (phrase) phrase) - pargs " ")))) - (if flist - (setq command (concat command " | " )))) + pargs " "))))) command)) (defun Man-downcase (man-args) @@ -342,29 +340,19 @@ (defun Man-default-man-args (manword) "Build the default man args from MANWORD and buffer's major mode." - (let ((mode major-mode) - (slist Man-auto-section-alist)) - (while (and slist - (not (eq (car (car slist)) mode))) - (setq slist (cdr slist))) - (if (not slist) - manword - (let ((sections (cdr (car slist)))) - (if (not (listp sections)) - (concat sections " " manword) - (let ((manarg "")) - (while sections - (setq manarg (concat manarg " " (car sections) " " manword)) - (setq sections (cdr sections))) - manarg) - ))))) + (let ((sections (cdr (assq major-mode Man-auto-section-alist)))) + (cond + ((null sections) manword) + ((consp sections) + (mapconcat (lambda (n) (concat n " " manword)) sections " ")) + (t + (concat sections " " manword))))) (defun Man-default-man-entry () "Make a guess at a default manual entry. This guess is based on the text surrounding the cursor, and the default section number is selected from `Man-auto-section-alist'." - (let ((default-section nil) - default-title) + (let (default-title) (save-excursion ;; Default man entry title is any word the cursor is on, @@ -383,20 +371,16 @@ ;; section number in default-entry (if (looking-at "[ \t]*([ \t]*[0-9][a-zA-Z]?[ \t]*)") (progn (skip-chars-forward "^0-9") - (setq default-section - (buffer-substring - (point) - (progn - (skip-chars-forward "0-9a-zA-Z") - (point))))) - - ;; Otherwise, assume section number to be 2 if we're - ;; in C code - (and (eq major-mode 'c-mode) - (setq default-section "2"))) - (if default-section - (format "%s %s" default-section default-title) - default-title)))) + (setq default-title + (concat (buffer-substring + (point) + (progn + (skip-chars-forward "0-9a-zA-Z") + (point))) + " " + default-title))) + (setq default-title (Man-default-man-args default-title))) + default-title))) ;; ====================================================================== @@ -421,13 +405,10 @@ (if (string= default-entry "") (error "No man args given.") (setq man-args default-entry))) + ;; Recognize the subject(section) syntax. - (if (string-match "^[ \t]*\\([^( \t]+\\)[ \t]*(\\([^)]+\\))[ \t]*$" - man-args) - (setq man-args - (concat (substring man-args (match-beginning 2) (match-end 2)) - " " - (substring man-args (match-beginning 1) (match-end 1))))) + (setq man-args (Man-translate-references man-args)) + (if Man-downcase-section-letters-p (setq man-args (Man-downcase man-args))) (Man-getpage-in-background man-args (consp arg)) @@ -438,7 +419,7 @@ Optional OVERRIDE-REUSE-P, when non-nil, means to start a background process even if a buffer already exists and `Man-reuse-okay-p' is non-nil." - (let* ((man-args (Man-default-man-args TOPIC)) + (let* ((man-args TOPIC) (bufname (concat "*man " man-args "*")) (buffer (get-buffer bufname))) (if (and Man-reuse-okay-p