home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / hyperbole / hyperbole.el < prev    next >
Encoding:
Text File  |  1995-08-26  |  18.5 KB  |  437 lines

  1. ;;!emacs
  2. ;;
  3. ;; LCD-ENTRY:    See "hversion.el".
  4. ;;
  5. ;; FILE:         hyperbole.el
  6. ;; SUMMARY:      Sets up Hyperbole for autoloading and use.
  7. ;; USAGE:        GNU Emacs Lisp Library
  8. ;; KEYWORDS:     hypermedia
  9. ;;
  10. ;; AUTHOR:       Bob Weiner
  11. ;; ORG:          Motorola, Inc., PWDG
  12. ;;
  13. ;; ORIG-DATE:     6-Oct-92 at 11:52:51
  14. ;; LAST-MOD:     25-Aug-95 at 02:13:08 by Bob Weiner
  15. ;;
  16. ;; This file is part of Hyperbole.
  17. ;; Available for use and distribution under the same terms as GNU Emacs.
  18. ;;
  19. ;; Copyright (C) 1992-1995, Free Software Foundation, Inc.
  20. ;; Developed with support from Motorola Inc.
  21. ;;
  22. ;; DESCRIPTION:  
  23. ;;
  24. ;;   See the "README" file for installation instructions.
  25. ;;
  26. ;;   There is no need to manually edit this file unless there are specific
  27. ;;   customizations you would like to make, such as changes to the Hyperbole
  28. ;;   key bindings.  (Mouse bindings are loaded from "hmouse-key.el".)
  29. ;;
  30. ;;   Other site-specific customizations belong in "hsite.el" which is created
  31. ;;   from "hsite-ex.el" by the person who installs Hyperbole at your site.
  32. ;;   
  33. ;; DESCRIP-END.
  34.  
  35. ;;; ************************************************************************
  36. ;;; Hyperbole directory setting
  37. ;;; ************************************************************************
  38.  
  39. ;; Defines hyperb:window-system, hyperb:kotl-p and
  40. ;; (hyperb:path-being-loaded), which are used below.
  41. ;; The Hyperbole distribution directory must either already be in
  42. ;; load-path or an explicit load of "hversion" must have been
  43. ;; done already or else the following line will fail to load hversion.
  44. ;; This is all documented in the Hyperbole installation instructions.
  45. (require 'hversion)
  46.  
  47. ;; Reinitialize hyperb:dir on reload if initialization failed for any reason.
  48. (and (boundp 'hyperb:dir) (null hyperb:dir) (makunbound 'hyperb:dir))
  49.  
  50. (defvar hyperb:dir (if (fboundp 'backtrace-frame) (hyperb:path-being-loaded))
  51.   "Directory where the Hyperbole executable code is kept.")
  52. (if (stringp hyperb:dir)
  53.     (setq hyperb:dir (file-name-directory hyperb:dir))
  54.   (error
  55.    "(hyperbole.el): Failed to set hyperb:dir.  Try setting it manually."))
  56.  
  57. ;;; ************************************************************************
  58. ;;; Other required Elisp libraries
  59. ;;; ************************************************************************
  60.  
  61. (require 'set (expand-file-name "set" hyperb:dir))
  62.  
  63. ;; Add hyperb:dir and kotl subdirectory to load-path so other
  64. ;; Hyperbole libraries can be found.
  65. (setq load-path (set:add hyperb:dir load-path))
  66. (if hyperb:kotl-p
  67.     (setq load-path (set:add (expand-file-name "kotl/" hyperb:dir) load-path)))
  68.  
  69. (require 'hvar)  ;; Defines var:append function.
  70.  
  71. ;;; ************************************************************************
  72. ;;; Public key bindings
  73. ;;; ************************************************************************
  74.  
  75. ;;; Setup so Hyperbole can be autoloaded from a key.
  76. ;;; Choose a key on which to place the Hyperbole menus.
  77. ;;; For most people this key binding will work and will be equivalent
  78. ;;; to {C-h h}.
  79. ;;;
  80. (or (where-is-internal 'hyperbole)
  81.     (where-is-internal 'hui:menu)
  82.     (define-key help-map "h" 'hyperbole))
  83.  
  84. ;;; Provides a site standard way of emulating most Hyperbole mouse drag
  85. ;;; commands from the keyboard.  This is most useful for rapidly creating
  86. ;;; Hyperbole link buttons from the keyboard without invoking the Hyperbole
  87. ;;; menu.  Only works if Emacs is run under a window system.
  88. ;;;
  89. (or (not hyperb:window-system)
  90.     (global-key-binding "\M-o")
  91.     (where-is-internal 'hkey-operate)
  92.     (global-set-key "\M-o" 'hkey-operate))
  93.  
  94. ;;; Provides a site standard way of performing explicit button
  95. ;;; renames without invoking the Hyperbole menu.
  96. ;;;
  97. (or (global-key-binding "\C-c\C-r")
  98.     (where-is-internal 'hui:ebut-rename)
  99.     (global-set-key "\C-c\C-r" 'hui:ebut-rename))
  100.  
  101. ;;; The following operations are now available through the Hyperbole Win/
  102. ;;; menu.  In earlier versions of Hyperbole, each of these operations had its
  103. ;;; own keybindings.  Uncomment the following code lines if you still want
  104. ;;; to use those key bindings.
  105. ;;; Key bindings for window configuration save/restore ring, like kill-ring
  106. ;;; except holds the configuration of windows within a frame.
  107. ;;; {C-x 4 w} to save config; {C-x 4 y} to restore successive
  108. ;;; saves; {C-x 4 DEL} to delete successive saves.
  109. ;;;
  110. ;; (or (global-key-binding "\C-x4w")
  111. ;;     (global-set-key "\C-x4w" 'wconfig-ring-save))
  112. ;; (or (global-key-binding "\C-x4y")
  113. ;;     (global-set-key "\C-x4y" 'wconfig-yank-pop))
  114. ;; (or (global-key-binding "\C-x4\177")
  115. ;;     (global-set-key "\C-x4\177" 'wconfig-delete-pop))
  116.  
  117. ;;; Provides a site standard way to easily switch between the Hyperbole mouse
  118. ;;; bindings and a set of personal mouse bindings.  You may instead show
  119. ;;; users how to bind this to a key via 'hyperb:init-hook' (see
  120. ;;; Hyperbole Manual).
  121. ;;;
  122. (or (global-key-binding "\C-ct")
  123.     (where-is-internal 'hmouse-toggle-bindings)
  124.     (global-set-key "\C-ct" 'hmouse-toggle-bindings))
  125.  
  126. (defun hkey-either (arg)
  127.   "Executes `action-key' or with non-nil ARG executes `assist-key'."
  128.   (interactive "P")
  129.   (if arg (assist-key) (action-key)))
  130.  
  131. ;;; A value of t for 'hkey-init' below will cause the Hyperbole
  132. ;;; context-sensitive keys to be bound to keyboard keys, in addition to any
  133. ;;; mouse key bindings.  Comment it out or set it to nil if you don't want
  134. ;;; these bindings.  Or change the bindings in the succeeding lines.
  135. ;;;
  136. (or (boundp 'hkey-init) (setq hkey-init t))
  137. (and hkey-init
  138.      (not (global-key-binding "\M-\C-m"))
  139.      (global-set-key "\M-\C-m" 'hkey-either))
  140. ;;
  141. ;; Bind a key, {C-h A}, for Action Key help and {C-u C-h A} for Assist key
  142. ;; help.
  143. (and hkey-init
  144.      (not (where-is-internal 'hkey-help))
  145.      (define-key help-map "A" 'hkey-help))
  146.  
  147. ;;;
  148. ;;; Hyperbole key bindings for many non-edit modes.
  149. ;;; Set both to nil if unwanted.
  150. ;;;
  151. (defvar action-key-read-only "\C-m"
  152.   "Local Action Key binding for special read-only modes.")
  153. (defvar assist-key-read-only "\M-\C-m"
  154.   "Local Assist Key binding for special read-only modes.")
  155.  
  156. ;;; ************************************************************************
  157. ;;; You shouldn't need to modify anything below here.
  158. ;;; ************************************************************************
  159.  
  160. (defun hkey-read-only-bindings ()
  161.   "Binds Action and Assist Keys in many read-only modes.
  162. Uses values of `action-key-read-only' and `assist-key-read-only'.  Does
  163. nothing if either variable is nil."
  164.   (if (not (and action-key-read-only assist-key-read-only))
  165.       nil
  166.     (if (and (boundp 'Buffer-menu-mode-map)
  167.          (keymapp Buffer-menu-mode-map))
  168.     (progn
  169.       (define-key Buffer-menu-mode-map action-key-read-only 'action-key)
  170.       (define-key Buffer-menu-mode-map assist-key-read-only
  171.         'hkey-either)))
  172.     (if (and (boundp 'calendar-mode-map)
  173.          (keymapp calendar-mode-map))
  174.     (progn
  175.       (define-key calendar-mode-map action-key-read-only 'action-key)
  176.       (define-key calendar-mode-map assist-key-read-only
  177.         'hkey-either)))
  178.     (if (and (boundp 'dired-mode-map)
  179.          (keymapp dired-mode-map))
  180.     (progn
  181.       (define-key dired-mode-map action-key-read-only 'action-key)
  182.       (define-key dired-mode-map assist-key-read-only
  183.         'hkey-either)))
  184.     (if (and (boundp 'gnus-group-mode-map)
  185.          (keymapp gnus-group-mode-map))
  186.     (progn
  187.       (define-key gnus-group-mode-map action-key-read-only 'action-key)
  188.       (define-key gnus-group-mode-map assist-key-read-only
  189.         'hkey-either)))
  190.     (if (and (boundp 'gnus-summary-mode-map)
  191.          (keymapp gnus-summary-mode-map))
  192.     (progn
  193.       (define-key gnus-summary-mode-map action-key-read-only 'action-key)
  194.       (define-key gnus-summary-mode-map assist-key-read-only
  195.         'hkey-either)))
  196.     (if (and (boundp 'Info-mode-map)
  197.          (keymapp Info-mode-map))
  198.     (progn
  199.       (define-key Info-mode-map action-key-read-only 'action-key)
  200.       (define-key Info-mode-map assist-key-read-only
  201.         'hkey-either)))
  202.     (if (and (boundp 'oo-browse-mode-map)
  203.          (keymapp oo-browse-mode-map))
  204.     (progn 
  205.       (define-key oo-browse-mode-map action-key-read-only 'action-key)
  206.       (define-key oo-browse-mode-map assist-key-read-only
  207.         'hkey-either)))
  208.     (if (and (boundp 'rmail-mode-map)
  209.          (keymapp rmail-mode-map))
  210.     (progn
  211.       (define-key rmail-mode-map action-key-read-only 'action-key)
  212.       (define-key rmail-mode-map assist-key-read-only
  213.         'hkey-either)))
  214.     (if (and (boundp 'rmail-summary-mode-map)
  215.          (keymapp rmail-summary-mode-map))
  216.     (progn
  217.       (define-key rmail-summary-mode-map action-key-read-only 'action-key)
  218.       (define-key rmail-summary-mode-map assist-key-read-only
  219.         'hkey-either)))
  220.     (if (and (boundp 'unix-apropos-map)
  221.          (keymapp unix-apropos-map))
  222.     (progn
  223.       (define-key unix-apropos-map action-key-read-only 'action-key)
  224.       (define-key unix-apropos-map assist-key-read-only
  225.         'hkey-either)))
  226.     ))
  227.  
  228. (hkey-read-only-bindings)
  229.  
  230. ;;; ************************************************************************
  231. ;;; Setup Hyperbole mouse bindings
  232. ;;; ************************************************************************
  233.  
  234. (require 'hmouse-key)
  235. (hmouse-setup)
  236.  
  237. ;;; Permits restore of the prior window configuration after any help buffer
  238. ;;; is shown by pressing either the Action or Assist Key at the end of the
  239. ;;; help buffer.  (Help buffer names end with "Help*".)
  240. ;;;
  241. (setq temp-buffer-show-hook 'hkey-help-show
  242.       temp-buffer-show-function temp-buffer-show-hook)
  243.  
  244. ;;; ************************************************************************
  245. ;;; Autoloads
  246. ;;; ************************************************************************
  247.  
  248. ;;; Menu items could call this function before Info is loaded.
  249. (autoload 'Info-goto-node   "info"       "Jump to specific Info node."  t)
  250.  
  251. ;;; Hyperbole user interface entry points that trigger loading of the full
  252. ;;; Hyperbole system.
  253.  
  254. ;; Action type definitions.
  255. (autoload 'defact           "hsite"
  256.   "Creates an action TYPE (an unquoted symbol) with PARAMS, described by DOC."
  257.   nil 'macro)
  258. ;; Implicit button type definitions.
  259. (autoload 'defib            "hsite"
  260.   "Creates implicit button TYPE (unquoted sym) with PARAMS, described by DOC."
  261.   nil 'macro)
  262.  
  263. (autoload 'ebut:map          "hsite"      "Map over Hyperbole buffer buttons." nil)
  264. (autoload 'hui:ebut-rename   "hsite"      "Rename a Hyperbole button."     t)
  265. (autoload 'hyperbole         "hsite"      "Hyperbole info manager menus."  t)
  266.  
  267. (autoload 'action-key        "hsite"
  268.   "Context-sensitive Action Key command."                                  t)
  269. (autoload 'hkey-help         "hsite"
  270.   "Display help for the Action Key command in current context.
  271. With optional ASSIST-FLAG non-nil, display help for the Assist Key command.
  272. Returns non-nil iff associated help documentation is found."               t)
  273. (autoload 'assist-key-help   "hsite"
  274.   "Display help for the Assist Key command in current context."            t)
  275. (autoload 'hkey-help-hide    "hsite"
  276.   "Restores frame to configuration prior to help buffer display."        nil)
  277. (autoload 'hkey-help-show    "hsite"
  278.   "Saves prior frame configuration if BUFFER displays help."             nil)
  279. (autoload 'assist-key        "hsite"
  280.   "Context-sensitive Assist Key command."                                  t)
  281. (autoload 'action-mouse-key  "hsite"
  282.   "Context-sensitive Action Mouse Key command."                            t)
  283. (autoload 'assist-mouse-key  "hsite"
  284.   "Context-sensitive Assist Mouse Key command."                            t)
  285. (autoload 'hkey-operate      "hsite"      "Emulate Hyperbole mouse key drags." t)
  286. (autoload 'symset:add        "hsite"      "Adds ELT to SYMBOL's PROP set." nil)
  287. (autoload 'hact              "hsite"      "Performs action formed from rest of ARGS."
  288.   nil)
  289. (autoload 'actypes::exec-window-cmd "hsite"
  290.       "Executes an external window-based SHELL-CMD string asynchronously." nil)
  291. (autoload 'hpath:absolute-to "hsite"
  292.       "Make PATH absolute from optional DEFAULT-DIRS." nil)
  293. (autoload 'hpath:find        "hsite"
  294.       "Edit file FILENAME, possibly using a special command." t)
  295. (autoload 'hpath:find-other-window "hsite"
  296.       "Edit file FILENAME in other window, possibly using a special command." t)
  297.  
  298. ;;; Hyperbole entry points that trigger loading part of the system.
  299.  
  300. (autoload 'hypb:functionp    "hypb"       "Return t iff OBJ is a function." nil)
  301.  
  302. ;;; Hyperbole msg reader autoloads.
  303. (autoload 'Rmail-init "hrmail" "Initializes Hyperbole Rmail support." t)
  304. (autoload 'Mh-init    "hmh"    "Initializes Hyperbole Mh support." t)
  305. (autoload 'Vm-init    "hvm"    "Initializes Hyperbole Vm support." t)
  306. (autoload 'Pm-init    "hpm"    "Initializes Hyperbole PIEmail support." t)
  307. (autoload 'Gnus-init  "hgnus"  "Initializes Hyperbole Gnus support." t)
  308.  
  309. ;;; Hyperbole msg composer autoloads.
  310. (autoload 'hmail:compose "hmail"
  311.   "Compose mail with ADDRESS and evaluation of EXPR." t)
  312.  
  313. ;;; Hyperbole outliner main entry points.
  314. (if (not hyperb:kotl-p)
  315.     nil
  316.   (autoload 'kfile:find           "kfile" "Edit an autonumbered outline." t)
  317.   (autoload 'kfile:is-p           "kfile" "Is an unformatted outline?" nil)
  318.   (autoload 'kfile:view           "kfile"
  319.     "View an autonumbered outline in read-only mode." t)
  320.   (autoload 'kotl-mode            "kfile" "Autonumbered outlining mode."  t)
  321.   (autoload 'kimport:aug-post-outline "kimport" "Import Augment files." t)
  322.   (autoload 'kimport:star-outline "kimport" "Import * outline files." t)
  323.   ;;
  324.   ;; Entry points from Hyperbole Otl/ menu.
  325.   (autoload 'klink:create         "klink" "Insert an implicit link at point." t)
  326.   (autoload 'kotl-mode:is-p       "kfile" "Test if within a Hyperbole outline.")
  327.   (autoload 'kotl-mode:hide-tree  "kfile" "Hide sublevels of current tree." t)
  328.   (autoload 'kotl-mode:overview   "kfile"  "Show first line of each cell." t)
  329.   (autoload 'kotl-mode:show-all   "kfile" "Expand all outline cells." t)
  330.   (autoload 'kotl-mode:show-tree  "kfile" "Expand current tree cells." t)
  331.   (autoload 'kotl-mode:top-cells  "kfile" "Hide all but top-level cells." t)
  332.   ;;
  333.   ;; Functions required from outline.el library.
  334.   (autoload 'show-all             "outline" "Show all of the text in the buffer." t)
  335.   )
  336.  
  337. ;;; Hyperbole rolodex main entry points.
  338. (autoload 'rolo-add              "wrolo"      "Add an entry to rolodex"       t)
  339. (autoload 'rolo-display-matches  "wrolo"      "Redisplay previous rolodex matches" t)
  340. (autoload 'rolo-edit             "wrolo"      "Edit an existing rolodex entry" t)
  341. (autoload 'rolo-fgrep            "wrolo"      "Rolodex string search"         t)
  342. (autoload 'rolo-grep             "wrolo"      "Rolodex regexp search"         t)
  343. (autoload 'rolo-kill             "wrolo"      "Delete an existing rolodex entry" t)
  344. (autoload 'rolo-logic            "wrolo-logic" "Logical rolodex search filters." t)
  345. (autoload 'rolo-sort             "wrolo"      "Sort rolodex entries" t)
  346. (autoload 'rolo-word             "wrolo"      "Rolodex string search for a word" t)
  347. (autoload 'rolo-yank             "wrolo"      "Insert a rolodex entry into current buffer" t)
  348.  
  349. ;;; Hyperbole Key autoloads.
  350. (autoload 'Info-handle-in-note "hmous-info"
  351.           "Follows Info documentation references.")
  352. (autoload 'smart-info "hmous-info" "Follows Info documentation references." t)
  353. (autoload 'smart-info-assist "hmous-info"
  354.           "Follows Info documentation references." t)
  355. (autoload 'smart-asm-at-tag-p "hmouse-tag"
  356.       "Jumps to assembly identifier definitions.")
  357. (autoload 'smart-c-at-tag-p "hmouse-tag" "Jumps to C identifier definitions.")
  358. (autoload 'smart-lisp-mode-p "hmouse-tag"
  359.       "Jumps to Lisp identifier definitions.")
  360. (autoload 'smart-c++ "hmouse-tag" "Jumps to C++ identifier definitions.")
  361. ;; Does nothing unless OO-Browser C++ support has been loaded.
  362. (autoload 'smart-c++-oobr "hmouse-tag" "Jumps to C++ identifier definitions.")
  363. (autoload 'smart-objc "hmouse-tag" "Jumps to Objective-C identifier definitions.")
  364. ;; Does nothing unless OO-Browser Objective-C support has been loaded.
  365. (autoload 'smart-objc-oobr "hmouse-tag" "Jumps to Objective-C identifier definitions.")
  366. (autoload 'smart-tags-file "hmouse-tag" "Determines nearest etags file.")
  367. (autoload 'smart-tags-file-path "hmouse-tag" "Expands a filename from TAGS file.")
  368.  
  369. ;;; Window configuration save and restore autoloads.
  370. (autoload 'wconfig-add-by-name     "wconfig" "Save win config under name."  t)
  371. (autoload 'wconfig-delete-by-name  "wconfig" "Delete win config under name." t)
  372. (autoload 'wconfig-restore-by-name "wconfig" "Restore win config under name." t)
  373. (autoload 'wconfig-ring-save  "wconfig"   "Save window-config to ring."  t)
  374. (autoload 'wconfig-yank-pop   "wconfig"   "Pop window-config from ring." t)
  375. (autoload 'wconfig-delete-pop "wconfig"   "Delete window-config from ring." t)
  376.  
  377. ;;; ************************************************************************
  378. ;;; Auto mode file suffixes 
  379. ;;; ************************************************************************
  380.  
  381. ;;; Invoke kotl-mode for files ending in ".kotl".  Also allow ".kot" for DOS
  382. ;;; and Windows users.
  383. (if hyperb:kotl-p
  384.     (setq auto-mode-alist (cons '("\\.kotl$\\|\\.kot$" . kotl-mode)
  385.                 auto-mode-alist)))
  386.  
  387. ;;; ************************************************************************
  388. ;;; MESSAGE SYSTEM SUPPORT CONFIGURATION
  389. ;;; ************************************************************************
  390.  
  391. ;;; Even if you don't need some of the following hook settings, you might
  392. ;;; as well leave them in so that if they ever become useful to you, you
  393. ;;; need not reconfigure Hyperbole.  These settings do nothing if the
  394. ;;; corresponding subsystems are never invoked.
  395. ;;;
  396. ;;; GNUS USENET news reader/poster support.
  397. ;;;
  398. (var:append 'gnus-Startup-hook '(Gnus-init))
  399. ;;;
  400. ;;; Hyperbole mail reader support configuration.
  401. ;;;
  402. ;; Rmail
  403. (var:append 'rmail-mode-hook    '(Rmail-init))
  404. ;; Mh-e
  405. (var:append 'mh-inc-folder-hook '(Mh-init))
  406. ;;
  407. ;; VM support is based on V5.72 beta of VM.  If you have a version of VM
  408. ;; earlier than 5.70 beta, you should either upgrade or comment out the
  409. ;; following line so that Hyperbole support for VM is not enabled.
  410. (var:append 'vm-mode-hooks      '(Vm-init))
  411. ;;
  412. ;; PIEmail
  413. (var:append 'pm-hook            '(Pm-init))
  414. ;;;
  415. ;;; Hyperbole mail composer support configuration.
  416. ;;;
  417. (var:append 'mail-mode-hook      '((lambda () (require 'hsmail))))
  418. (var:append 'mh-letter-mode-hook '((lambda () (require 'hsmail))))
  419. (var:append 'vm-mail-mode-hook   '((lambda () (require 'hsmail))))
  420.  
  421. ;;; ************************************************************************
  422. ;;; Frame function aliases.
  423. ;;; ************************************************************************
  424. ;; Create all needed 'frame-' aliases for all 'screen-' functions, e.g.
  425. ;; screen-width.
  426. (if (fboundp 'selected-frame)
  427.     nil
  428.   (fset 'selected-frame 'selected-screen)
  429.   (mapcar
  430.    (function (lambda (func-name)
  431.            (or (fboundp (intern-soft (concat "frame" func-name)))
  432.            (fset (intern (concat "frame" func-name))
  433.              (intern-soft (concat "screen" func-name))))))
  434.    '("-width" "-height")))
  435.  
  436. (provide 'hyperbole)
  437.