home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / alt / lucidem / help / 151 < prev    next >
Encoding:
Text File  |  1992-07-27  |  8.3 KB  |  239 lines

  1. Newsgroups: alt.lucid-emacs.help
  2. Path: sparky!uunet!fornax!bremner
  3. From: bremner@cs.sfu.ca (David Bremner)
  4. Subject: patch for info-dg.el
  5. Message-ID: <1992Jul27.224215.17785@cs.sfu.ca>
  6. Summary: works for me.
  7. Keywords: quick and dirty
  8. Reply-To: bremner@cs.sfu.ca (David Bremner)
  9. Organization: CSS, Simon Fraser University, Burnaby, B.C., Canada
  10. Date: Mon, 27 Jul 1992 22:42:15 GMT
  11. Lines: 226
  12.  
  13.  
  14. What follows is my quick and dirty mashing together of Dave Gillespie's 
  15. enhanced info  mode, and the font and mouse stuff from lemacs 19.2.
  16.  
  17. Some  day when I have time I'll go through and clean it up so that 
  18. it works under both lucid and other gnu emacses.
  19.  
  20. In the mean time, here it is.
  21.  
  22. It is, in all senses of the word a derivative work, and I assert no
  23. additional copyright on MY twelve keystrokes :-)
  24.  
  25. Cheers,
  26.  
  27. David.
  28.  
  29. P.S. I may take a few weeks to  respond to bug reports.
  30. P.P.S. info-dg.el is available from
  31.  
  32. info-dg (1.05)      92-03-08
  33.      Dave Gillespie, <daveg@synaptics.com>
  34.      archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/modes/info.el.Z
  35.      Info reader with many enhancements; replaces standard info.el.
  36.  
  37. ---------------------------cut here-----------------------------------
  38. *** info-dg.orig    Mon Jul 27 15:22:52 1992
  39. --- info-dg.el    Fri Jul 24 11:06:08 1992
  40. ***************
  41. *** 529,535 ****
  42.             (setq thisfilepos (read (current-buffer)))
  43.             ;; read in version 19 stops at the end of number.
  44.             ;; Advance to the next line.
  45. !           ;; (forward-line 1)
  46.             (if (> thisfilepos nodepos)
  47.             (throw 'foo t))
  48.             (setq lastfilename thisfilename)
  49. --- 529,535 ----
  50.             (setq thisfilepos (read (current-buffer)))
  51.             ;; read in version 19 stops at the end of number.
  52.             ;; Advance to the next line.
  53. !           (forward-line 1)
  54.             (if (> thisfilepos nodepos)
  55.             (throw 'foo t))
  56.             (setq lastfilename thisfilename)
  57. ***************
  58. *** 1906,1910 ****
  59. --- 1906,2082 ----
  60.          (message "Tags may have changed.  Use Info-tagify if necessary")))
  61.   
  62.   (run-hooks 'Info-load-hook)
  63. + ;;; fontification and mousability for info
  64. + ;;; Copied from the Lucid Emacs 19.2 distribution
  65. + ;;; July 15, 1992
  66. + ;; Turn off Dave Gillespie's mouse support
  67. + (setq Info-mouse-support nil)
  68. + ;; Fontify the nodes 
  69. + (setq Info-select-hook 'Info-fontify-node)
  70. + ;; Bind the mouse buttons
  71. + (define-key Info-mode-map 'button2 'Info-follow-indicated-node)
  72. + (define-key Info-mode-map 'button3 'Info-select-node-menu)
  73. + (defvar Info-fontify t)
  74. + (defvar Info-footnote-tag "Note" 
  75. +   "If we are loading this file on top of something that does not define
  76. + Info-footnote-tag, set to the default")
  77. + ;; This should really quote Info-footnote-tag in case someone sets it to a 
  78. + ;; regexp
  79. + (defvar Info-xref-regexp (concat "\\*" 
  80. +                  (regexp-quote Info-footnote-tag)
  81. +                  "[ \n\t]*\\([^:]*\\):"))
  82. + (or (find-face 'info-node) (make-face 'info-node))
  83. + (or (find-face 'info-xref) (make-face 'info-xref))
  84. + (if purify-flag  ; being preloaded
  85. +     nil
  86. +   (or (face-differs-from-default-p 'info-node (selected-screen))
  87. +       (copy-face 'bold-italic 'info-node (selected-screen)))
  88. +   (or (face-differs-from-default-p 'info-xref (selected-screen))
  89. +       (copy-face 'bold 'info-xref (selected-screen))))
  90. + (defun Info-fontify-node ()
  91. +   (if Info-fontify
  92. +       (save-excursion
  93. +     (map-extents (function (lambda (x y) (delete-extent x)))
  94. +              (current-buffer) (point-min) (point-max) nil)
  95. +     (let ((case-fold-search t)
  96. +           extent)
  97. +       (goto-char (point-min))
  98. +       (if (looking-at "^File: [^,: \t]+,?[ \t]+")
  99. +           (progn
  100. +         (goto-char (match-end 0))
  101. +         (while
  102. +             (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
  103. +           (goto-char (match-end 0))
  104. +           (setq extent (make-extent (match-beginning 1) (match-end 1)))
  105. +           (set-extent-face extent 'info-xref)
  106. +           (set-extent-attribute extent 'highlight))))
  107. +       (goto-char (point-min))
  108. +       (while (re-search-forward Info-xref-regexp nil t)
  109. +         (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
  110. +         nil
  111. +           (setq extent (make-extent (match-beginning 0) (match-end 1)))
  112. +           (set-extent-face extent 'info-xref)
  113. +           (set-extent-attribute extent 'highlight)))
  114. +       (goto-char (point-min))
  115. +       (if (search-forward "\n* menu:" nil t)
  116. +           (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
  117. +         (setq extent (make-extent (match-beginning 0) (match-end 1)))
  118. +         (set-extent-face extent 'info-node)
  119. +         (set-extent-attribute extent 'highlight)))))))
  120. + (defun Info-indicated-node (event)
  121. +   (save-window-excursion
  122. +     (save-excursion
  123. +       (mouse-set-point event)
  124. +       (let* ((buffer (window-buffer (event-window event)))
  125. +          (p (event-point event))
  126. +          (extent (and p (extent-at p buffer 'highlight)))
  127. +          (text (and extent
  128. +             (save-excursion
  129. +               (set-buffer buffer)
  130. +               (buffer-substring
  131. +                (extent-start-position extent)
  132. +                (extent-end-position extent)))))
  133. +          (case-fold-search t)
  134. +          i)
  135. +     (cond ((null extent)
  136. +            nil)
  137. +           ((string-match  (concat "\\`" Info-xref-regexp "?\\'") text)
  138. +            ;; it's a cross-reference
  139. +            (setq text (substring text (match-beginning 1) (match-end 1)))
  140. +            (while (setq i (string-match "[ \n\t]+" text i))
  141. +          (setq text (concat (substring text 0 i) " "
  142. +                     (substring text (match-end 0))))
  143. +          (setq i (1+ i)))
  144. +            (list 'Info-follow-reference text))
  145. +           ((and (save-excursion (goto-char (extent-start-position extent))
  146. +                     (= ?\n (preceding-char)))
  147. +             (string-match "\\`\\* \\([^:\t\n]+\\):?\\'" text))
  148. +            ;; it's a menu entry
  149. +            (setq text (substring text (match-beginning 1) (match-end 1)))
  150. +            (list 'Info-menu text))
  151. +           (t
  152. +            ;; otherwise, it must be a node-name in the first line
  153. +            (list 'Info-goto-node text)))))))
  154. + (defun Info-follow-indicated-node (event)
  155. +   "Follow the crossreference or menu item at the click-location."
  156. +   (interactive "e")
  157. +   (mouse-set-point event)
  158. +   (eval (or (Info-indicated-node event)
  159. +         (error "click on a cross-reference to follow"))))
  160. + (defun Info-select-node-menu (event)
  161. +   "Pops up a menu of applicable Info commands."
  162. +   (interactive "e")
  163. +   (select-window (event-window event))
  164. +   (let ((case-fold-search t)
  165. +     up-p prev-p next-p menu
  166. +     i text xrefs subnodes in)
  167. +     (save-excursion
  168. +       (goto-char (point-min))
  169. +       (if (looking-at ".*\\bNext:") (setq next-p t))
  170. +       (if (looking-at ".*\\bPrev:") (setq prev-p t))
  171. +       (if (looking-at ".*Up:") (setq up-p t))
  172. +       (setq menu (nconc (list "" "Info Commands:" "----")
  173. +             (if (setq in (Info-indicated-node event))
  174. +                 (list (vector (car (cdr in)) in t)))
  175. +             (list
  176. +              ["Goto Info Top-level" Info-directory t]
  177. +              (vector "Next Node" 'Info-next next-p)
  178. +              (vector "Previous Node" 'Info-prev prev-p)
  179. +              (vector "Parent Node (Up)" 'Info-up up-p)
  180. +              ["Goto Node..." Info-goto-node t]
  181. +              ["Goto Last Visited Node" Info-last t])))
  182. +       (while (re-search-forward Info-xref-regexp nil t)
  183. +     (setq text (buffer-substring (match-beginning 1) (match-end 1)))
  184. +     (while (setq i (string-match "[ \n\t]+" text i))
  185. +       (setq text (concat (substring text 0 i) " "
  186. +                  (substring text (match-end 0))))
  187. +       (setq i (1+ i)))
  188. +     (setq xrefs (cons text xrefs)))
  189. +       (setq xrefs (nreverse xrefs))
  190. +       (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more)))
  191. +       (goto-char (point-min))
  192. +       (if (search-forward "\n* menu:" nil t)
  193. +       (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
  194. +         (setq text (buffer-substring (match-beginning 1) (match-end 1)))
  195. +         (setq subnodes (cons text subnodes))))
  196. +       (setq subnodes (nreverse subnodes))
  197. +       (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more)))
  198. +       )
  199. +     (if xrefs
  200. +     (nconc menu (list "----" "Cross-References:" "----")
  201. +            (mapcar (function (lambda (xref)
  202. +                    (if (eq xref 'more)
  203. +                        "...more..."
  204. +                      (vector xref
  205. +                          (list 'Info-follow-reference xref)
  206. +                          t))))
  207. +                xrefs)))
  208. +     (if subnodes
  209. +     (nconc menu (list "----" "Sub-Nodes:" "----")
  210. +            (mapcar (function (lambda (node)
  211. +                    (if (eq node 'more)
  212. +                        "...more..."
  213. +                      (vector node (list 'Info-menu node)
  214. +                          t))))
  215. +                subnodes)))
  216. +     (popup-menu menu)))
  217.   
  218.   ;;; End.
  219. -- 
  220. bremner@cs.sfu.ca                           ubc-cs!fornax!bremner
  221.