home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / man-enh.patch / text0000.txt < prev   
Encoding:
Text File  |  1990-07-22  |  6.1 KB  |  180 lines

  1. In article <9004052251.AA19736@zurich.ai.mit.edu> arthur@ZURICH.AI.MIT.EDU (Arthur Gleckler) writes:
  2.  
  3.    Here is a one-line change suggestion that would make M-x manual-entry
  4.    MUCH nicer:
  5.  
  6.    The line in the definition of manual-entry which reads
  7.  
  8.      (with-output-to-temp-buffer "*Manual Entry*"
  9.  
  10.    could be changed to
  11.  
  12.      (with-output-to-temp-buffer (concat "*" topic " Manual Entry*")
  13.  
  14. Along these lines are some modifications for man.el that I am using.  One
  15. of the fixes is to name manual buffers more nicely.  The other is a big
  16. improvement in removing excess nroff-produced headers and footers from
  17. manual pages.  I'm including these modifications after my signature.
  18.  
  19. -- 
  20. Joe Wells <jbw@bu.edu>
  21. jbw%bucsf.bu.edu@cs.bu.edu
  22. ...!harvard!bu-cs!bucsf!jbw
  23. ----------------------------------------------------------------------
  24. *** /usr14/gnu/dist-18.55/lisp/man.el    Tue Jul  4 20:27:21 1989
  25. --- man.el    Fri Apr  6 17:58:04 1990
  26. ***************
  27. *** 18,23 ****
  28. --- 18,33 ----
  29.   ;; file named COPYING.  Among other things, the copyright notice
  30.   ;; and this notice must be preserved on all copies.
  31.   
  32. + ;; Modifications by mdb (whoever that is!)
  33. + ;; More mods by Joe Wells <jbw@bu.edu>
  34. + ;; Added better choice of buffer name so we don't erase previous man page.
  35. + ;; Added better stripping of headers and footers.
  36. + (defconst manual-entry-prefix-topic t "\
  37. + *Non-nil means M-x manual-entry should output the manual entry for TOPIC into
  38. +  a buffer named *TOPIC Manual Entry*, otherwise, it should name the buffer
  39. +  *Manual Entry*.")
  40.   (defun manual-entry (topic &optional section)
  41.     "Display the Unix manual entry for TOPIC.
  42.   TOPIC is either the title of the entry, or has the form TITLE(SECTION)
  43. ***************
  44. *** 29,35 ****
  45.                        (match-end 2))
  46.           topic (substring topic (match-beginning 1)
  47.                      (match-end 1))))
  48. !   (with-output-to-temp-buffer "*Manual Entry*"
  49.       (buffer-flush-undo standard-output)
  50.       (save-excursion
  51.         (set-buffer standard-output)
  52. --- 39,49 ----
  53.                        (match-end 2))
  54.           topic (substring topic (match-beginning 1)
  55.                      (match-end 1))))
  56. ! ;; \(with-output-to-temp-buffer "*Manual Entry*" ;; original line
  57. !   (with-output-to-temp-buffer                    ;; added by mdb
  58. !       (if manual-entry-prefix-topic             ;; added by mdb
  59. !       (concat "*" topic " Manual Entry*")    ;; added by mdb
  60. !     "*Manual Entry*")                      ;; added by mdb
  61.       (buffer-flush-undo standard-output)
  62.       (save-excursion
  63.         (set-buffer standard-output)
  64. ***************
  65. *** 85,96 ****
  66.             (end-of-line)
  67.             (error (buffer-substring 1 (point)))))))
  68.   
  69. -       (message "Cleaning manual entry for %s..." topic)
  70. -       (nuke-nroff-bs)
  71.         (set-buffer-modified-p nil)
  72.         (message ""))))
  73.   
  74. ! ;; Hint: BS stands form more things than "back space"
  75.   (defun nuke-nroff-bs ()
  76.     (interactive "*")
  77.     ;; Nuke underlining and overstriking (only by the same letter)
  78. --- 99,108 ----
  79.             (end-of-line)
  80.             (error (buffer-substring 1 (point)))))))
  81.   
  82.         (set-buffer-modified-p nil)
  83.         (message ""))))
  84.   
  85. ! ;; Hint: BS stands for more things than "back space"
  86.   (defun nuke-nroff-bs ()
  87.     (interactive "*")
  88.     ;; Nuke underlining and overstriking (only by the same letter)
  89. ***************
  90. *** 108,135 ****
  91.            ;; \b_
  92.            (delete-region (1- (point)) (1+ (point)))))))
  93.   
  94. !   ;; Nuke headers: "MORE(1) UNIX Programmer's Manual MORE(1)"
  95.     (goto-char (point-min))
  96. !   (while (re-search-forward "^ *\\([A-Za-z][-_A-Za-z0-9]*([0-9A-Z]+)\\).*\\1$" nil t)
  97. !     (replace-match ""))
  98.     
  99. !   ;; Nuke footers: "Printed 12/3/85    27 April 1981    1"
  100. !   ;;    Sun appear to be on drugz:
  101. !   ;;     "Sun Release 3.0B  Last change: 1 February 1985     1"
  102. !   ;;    HP are even worse!
  103. !   ;;     "     Hewlett-Packard   -1- (printed 12/31/99)"  FMHWA12ID!!
  104. !   ;;    System V (well WICATs anyway):
  105. !   ;;     "Page 1              (printed 7/24/85)"
  106. !   ;;    Who is administering PCP to these corporate bozos?
  107.     (goto-char (point-min))
  108. !   (while (re-search-forward
  109. !        (cond ((eq system-type 'hpux)
  110. !           "^[ \t]*Hewlett-Packard\\(\\| Company\\)[ \t]*- [0-9]* -.*$")
  111. !          ((eq system-type 'usg-unix-v)
  112. !           "^ *Page [0-9]*.*(printed [0-9/]*)$")
  113. !          (t
  114. !           "^\\(Printed\\|Sun Release\\) [0-9].*[0-9]$"))
  115. !        nil t)
  116.       (replace-match ""))
  117.   
  118.     ;; Crunch blank lines
  119. --- 120,151 ----
  120.            ;; \b_
  121.            (delete-region (1- (point)) (1+ (point)))))))
  122.   
  123. !   ;; Zap headers and footers
  124. !   ;; Note: this handles all kinds of headers and footers.  It determines
  125. !   ;; where the page breaks are by checking for the man-page name in the
  126. !   ;; first column.  There is no longer any need to add code to handle
  127. !   ;; specific headers and footers.
  128.     (goto-char (point-min))
  129. !   (cond ((looking-at "\n*\\([A-Za-z][-_A-Za-z0-9.]*([0-9A-Z]+)\\)")
  130. !      (setq man-page-name (buffer-substring (match-beginning 1)
  131. !                            (match-end 1)))
  132. !      (setq target (concat "\n\n.+\n\n+" man-page-name ".*\n\n"))
  133. !      (while (re-search-forward target nil t)
  134. !        ;;(setq begin (match-beginning 0) end (match-end 0))
  135. !        (replace-match
  136. !         (progn
  137. !           (goto-char (1- (match-beginning 0)))
  138. !           (if (not (eq (char-after (point)) ?.))
  139. !           "\n"
  140. !         "\n\n"))
  141. !         t t))))
  142.     
  143. !   ;; Zap ESC7,  ESC8, and ESC9
  144. !   ;; This is for Sun man pages like "man 1 csh"
  145.     (goto-char (point-min))
  146. !   (while (re-search-forward "\e[789]" nil t)
  147.       (replace-match ""))
  148.   
  149.     ;; Crunch blank lines
  150. ***************
  151. *** 144,149 ****
  152. --- 160,166 ----
  153.   
  154.   
  155.   (defun insert-man-file (name)
  156. +   (narrow-to-region (point) (point))
  157.     ;; Insert manual file (unpacked as necessary) into buffer
  158.     (if (or (equal (substring name -2) ".Z")
  159.         (string-match "/cat[0-9][a-z]?\\.Z/" name))
  160. ***************
  161. *** 150,153 ****
  162.         (call-process "zcat" name t nil)
  163.       (if (equal (substring name -2) ".z")
  164.       (call-process "pcat" nil t nil name)
  165. !       (insert-file-contents name))))
  166. --- 167,173 ----
  167.         (call-process "zcat" name t nil)
  168.       (if (equal (substring name -2) ".z")
  169.       (call-process "pcat" nil t nil name)
  170. !       (insert-file-contents name)))
  171. !   (message "Cleaning manual entry for %s..." topic)
  172. !   (nuke-nroff-bs)
  173. !   (widen))
  174.  
  175.  
  176.