]> git.eshelyaron.com Git - emacs.git/commitdiff
* man.el (Man-build-man-command): Don't leave a pipe symbol at the
authorJim Blandy <jimb@redhat.com>
Tue, 6 Jul 1993 06:59:31 +0000 (06:59 +0000)
committerJim Blandy <jimb@redhat.com>
Tue, 6 Jul 1993 06:59:31 +0000 (06:59 +0000)
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.

lisp/man.el

index 38f158beff03b41fd275b6e13936a432062e7c9d..38937e0c43f81efb893153cf1512b7e3b4586869 100644 (file)
@@ -254,7 +254,7 @@ This regular expression should start with a `^' character.")
 
 (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 @@ This regular expression should start with a `^' character.")
        (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 @@ the current column instead of character position."
 
 (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 @@ default section number is selected from `Man-auto-section-alist'."
       ;; 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)))
         
 \f
 ;; ======================================================================
@@ -421,13 +405,10 @@ Universal argument ARG, is passed to `Man-getpage-in-background'."
         (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 @@ Universal argument ARG, is passed to `Man-getpage-in-background'."
 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