/[emacs]/emacs/lisp/man.el
ViewVC logotype

Diff of /emacs/lisp/man.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.108 by miles, Mon Aug 27 12:55:22 2001 UTC revision 1.109 by monnier, Fri Nov 30 09:13:21 2001 UTC
# Line 81  Line 81 
81  ;;   footer).  A different algorithm should be used.  It is easy to  ;;   footer).  A different algorithm should be used.  It is easy to
82  ;;   compute how many blank lines there are before and after the page  ;;   compute how many blank lines there are before and after the page
83  ;;   headers, and after the page footer.  But it is possible to compute  ;;   headers, and after the page footer.  But it is possible to compute
84  ;;   the number of blank lines before the page footer by euristhics  ;;   the number of blank lines before the page footer by heuristics
85  ;;   only.  Is it worth doing?  ;;   only.  Is it worth doing?
86  ;; - Allow a user option to mean that all the manpages should go in  ;; - Allow a user option to mean that all the manpages should go in
87  ;;   the same buffer, where they can be browsed with M-n and M-p.  ;;   the same buffer, where they can be browsed with M-n and M-p.
# Line 351  make -a one of the switches, if your `ma Line 351  make -a one of the switches, if your `ma
351    (define-key Man-mode-map "q"    'Man-quit)    (define-key Man-mode-map "q"    'Man-quit)
352    (define-key Man-mode-map "m"    'man)    (define-key Man-mode-map "m"    'man)
353    (define-key Man-mode-map "\r"   'man-follow)    (define-key Man-mode-map "\r"   'man-follow)
354      (define-key Man-mode-map [mouse-2]   'man-follow-mouse)
355    (define-key Man-mode-map "?"    'describe-mode)    (define-key Man-mode-map "?"    'describe-mode)
356    )    )
357    
# Line 418  This is necessary if one wants to dump m Line 419  This is necessary if one wants to dump m
419             )))             )))
420  )  )
421    
 (defsubst Man-match-substring (&optional n string)  
   "Return the substring matched by the last search.  
 Optional arg N means return the substring matched by the Nth paren  
 grouping.  Optional second arg STRING means return a substring from  
 that string instead of from the current buffer."  
   (if (null n) (setq n 0))  
   (if string  
       (substring string (match-beginning n) (match-end n))  
     (buffer-substring (match-beginning n) (match-end n))))  
   
422  (defsubst Man-make-page-mode-string ()  (defsubst Man-make-page-mode-string ()
423    "Formats part of the mode line for Man mode."    "Formats part of the mode line for Man mode."
424    (format "%s page %d of %d"    (format "%s page %d of %d"
# Line 471  and the Man-section-translations-alist v Line 462  and the Man-section-translations-alist v
462      (cond      (cond
463       ;; "chmod(2V)" case ?       ;; "chmod(2V)" case ?
464       ((string-match (concat "^" Man-reference-regexp "$") ref)       ((string-match (concat "^" Man-reference-regexp "$") ref)
465        (setq name (Man-match-substring 1 ref)        (setq name (match-string 1 ref)
466              section (Man-match-substring 2 ref)))              section (match-string 2 ref)))
467       ;; "2v chmod" case ?       ;; "2v chmod" case ?
468       ((string-match (concat "^\\(" Man-section-regexp       ((string-match (concat "^\\(" Man-section-regexp
469                              "\\) +\\(" Man-name-regexp "\\)$") ref)                              "\\) +\\(" Man-name-regexp "\\)$") ref)
470        (setq name (Man-match-substring 2 ref)        (setq name (match-string 2 ref)
471              section (Man-match-substring 1 ref))))              section (match-string 1 ref))))
472      (if (string= name "")      (if (string= name "")
473          ref                             ; Return the reference as is          ref                             ; Return the reference as is
474        (if Man-downcase-section-letters-flag        (if Man-downcase-section-letters-flag
# Line 517  This guess is based on the text surround Line 508  This guess is based on the text surround
508                word                word
509                (if (looking-at                (if (looking-at
510                     (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))                     (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
511                    (format "(%s)" (Man-match-substring 1))                    (format "(%s)" (match-string 1))
512                  "")))))                  "")))))
513    
514    
# Line 547  all sections related to a subject, put s Line 538  all sections related to a subject, put s
538                          (format "Manual entry%s: "                          (format "Manual entry%s: "
539                                  (if (string= default-entry "")                                  (if (string= default-entry "")
540                                      ""                                      ""
541                                    (format " (default %s)" default-entry))))))                                    (format " (default %s)" default-entry)))
542                            nil nil default-entry)))
543             (if (string= input "")             (if (string= input "")
544                 (if (string= default-entry "")                 (error "No man args given")
                    (error "No man args given")  
                  default-entry)  
545               input))))               input))))
546    
547    ;; Possibly translate the "subject(section)" syntax into the    ;; Possibly translate the "subject(section)" syntax into the
# Line 569  all sections related to a subject, put s Line 559  all sections related to a subject, put s
559        (error "No item under point")        (error "No item under point")
560      (man man-args)))      (man man-args)))
561    
562    (defun man-follow-mouse (e)
563      "Get a Un*x manual page of the item under the mouse and put it in a buffer."
564      (interactive "e")
565      (save-excursion
566        (mouse-set-point e)
567        (call-interactively 'man-follow)))
568    
569  (defun Man-getpage-in-background (topic)  (defun Man-getpage-in-background (topic)
570    "Use TOPIC to build and fire off the manpage and cleaning command."    "Use TOPIC to build and fire off the manpage and cleaning command."
571    (let* ((man-args topic)    (let* ((man-args topic)
# Line 713  Same for the ANSI bold and normal escape Line 710  Same for the ANSI bold and normal escape
710    (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t)    (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t)
711      (replace-match "+")      (replace-match "+")
712      (put-text-property (1- (point)) (point) 'face 'bold))      (put-text-property (1- (point)) (point) 'face 'bold))
713      (goto-char (point-min))
714      ;; Try to recognize common forms of cross references.
715      (while (re-search-forward "\\w+([0-9].?)" nil t)
716        (put-text-property (match-beginning 0) (match-end 0)
717                           'mouse-face 'highlight))
718    (Man-softhyphen-to-minus)    (Man-softhyphen-to-minus)
719    (message "%s man page made up" Man-arguments))    (message "%s man page made up" Man-arguments))
720    
# Line 886  The following key bindings are currently Line 888  The following key bindings are currently
888              (while (and (not (eobp)) (/= (point) runningpoint))              (while (and (not (eobp)) (/= (point) runningpoint))
889                (setq runningpoint (point))                (setq runningpoint (point))
890                (if (re-search-forward Man-hyphenated-reference-regexp end t)                (if (re-search-forward Man-hyphenated-reference-regexp end t)
891                    (let* ((word (Man-match-substring 0))                    (let* ((word (match-string 0))
892                           (len (1- (length word))))                           (len (1- (length word))))
893                      (if hyphenated                      (if hyphenated
894                          (setq word (concat hyphenated word)                          (setq word (concat hyphenated word)
# Line 912  The following key bindings are currently Line 914  The following key bindings are currently
914      (while (not (eobp))      (while (not (eobp))
915        (setq header        (setq header
916              (if (looking-at Man-page-header-regexp)              (if (looking-at Man-page-header-regexp)
917                  (Man-match-substring 1)                  (match-string 1)
918                nil))                nil))
919        ;; Go past both the current and the next Man-first-heading-regexp        ;; Go past both the current and the next Man-first-heading-regexp
920        (if (re-search-forward Man-first-heading-regexp nil 'move 2)        (if (re-search-forward Man-first-heading-regexp nil 'move 2)

Legend:
Removed from v.1.108  
changed lines
  Added in v.1.109

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26