home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / interfaces / hyperbutton.shar / info-hyper.el < prev    next >
Encoding:
Text File  |  1991-07-03  |  2.7 KB  |  91 lines

  1. ;; ========================================================================
  2. ;; info-hyper.el -- Hyperbutton handling for Info
  3. ;; Author          : Mike Williams <mike-w@cs.aukuni.ac.nz>
  4. ;; Created On      : Thu Apr 18 11:50:03 1991
  5. ;; Last Modified By: Mike Williams
  6. ;; Last Modified On: Tue May 28 16:25:24 1991
  7. ;; RCS Info        : $Revision: 1.1 $ $Locker:  $
  8. ;; ========================================================================
  9. ;;
  10. ;; Based on info-mouse.el
  11. ;; by Bob Weiner <mailrus!uflorida!novavax!weiner@bbn.com>
  12. ;; 
  13. ;; In your Info-mode-hook:
  14. ;; 
  15. ;; (mapcar 'hyperbutton:add-local-handler
  16. ;;        '(Info-header-hyperbutton
  17. ;;          Info-menu-hyperbutton
  18. ;;          Info-note-hyperbutton))
  19.  
  20. (require 'info)
  21. (require 'hyperbutton)
  22. (require 'backquote)
  23.  
  24. (provide 'info-hyper)
  25.  
  26. ;;=========================================================================
  27.  
  28. (defun Info-header-hyperbutton ()
  29.   (interactive)
  30.   (let* ((first-line (1+ (count-lines 1 (point-min))))
  31.      (current-line (count-lines 1 (1+ (point)))))
  32.     (if (not (equal current-line first-line))
  33.     nil
  34.       (let ((nodename "Top") (filep nil))
  35.     (save-excursion
  36.       (if (and
  37.            (re-search-forward "[:, \t\n]" nil t)
  38.            (re-search-backward
  39.         "\\(File\\|Node\\|Up\\|Prev\\|Previous\\|Next\\)[: \t]" nil t))
  40.           (progn
  41.         (setq filep (string-equal
  42.                  "file"
  43.                  (downcase (buffer-substring
  44.                     (match-beginning 1)
  45.                     (match-end 1)))))
  46.         (if (re-search-forward (concat ":[ \n]\\([^,.\t\n"
  47.                            (if filep " ")
  48.                            "]*\\)") nil t)
  49.             (setq nodename (buffer-substring
  50.                     (match-beginning 1)
  51.                     (match-end 1)))))
  52.         (error "Node header not found.")))
  53.     (if filep (setq nodename (concat "(" nodename ")" "Top")))
  54.     (` (Info-goto-node (, nodename)))))))
  55.  
  56. (defun Info-note-hyperbutton ()
  57.   (interactive)
  58.   (let ((note-name nil) (bol nil))
  59.     (save-excursion
  60.       (if (re-search-forward "[:.\n]" nil t)
  61.       (progn
  62.         (save-excursion
  63.           (beginning-of-line)
  64.           (setq bol (point)))
  65.         (if (re-search-backward 
  66.          "\*\\(Note\\|Ref\\)[ \n]+\\([^:]*\\):" bol t)
  67.         (setq note-name (buffer-substring
  68.                  (match-beginning 2)
  69.                  (match-end 2)))))))
  70.     (if (not note-name)
  71.     nil
  72.       (` (Info-follow-reference (, note-name))))))
  73.  
  74. (defun Info-menu-hyperbutton ()
  75.   (interactive)
  76.   (let ((in-menu nil) (curr-point (point)))
  77.     (save-excursion
  78.       (goto-char (point-min))
  79.       (setq in-menu 
  80.         (and (re-search-forward "^\* Menu:" nil t)
  81.          (< (point) curr-point))))
  82.     (if (not in-menu)
  83.     nil
  84.       (forward-char) ; Pass '*' char if point is in front of
  85.       (if (re-search-backward "^\*" nil t)
  86.       (progn (forward-char 2)
  87.          (` (Info-goto-node (, (Info-extract-menu-node-name)))))))))
  88.  
  89. ;;=== END of info-hyper.el ================================================
  90.  
  91.