comparison lisp/hyperbole/hinit.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 4103f0995bd7
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;!emacs
2 ;;
3 ;; FILE: hinit.el
4 ;; SUMMARY: Standard initializations for Hyperbole hypertext system.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: hypermedia
7 ;;
8 ;; AUTHOR: Bob Weiner
9 ;; ORG: Brown U.
10 ;;
11 ;; ORIG-DATE: 1-Oct-91 at 02:32:51
12 ;; LAST-MOD: 22-Oct-95 at 00:27:13 by Bob Weiner
13 ;;
14 ;; This file is part of Hyperbole.
15 ;; Available for use and distribution under the same terms as GNU Emacs.
16 ;;
17 ;; Copyright (C) 1991-1995, Free Software Foundation, Inc.
18 ;; Developed with support from Motorola Inc.
19 ;;
20 ;; DESCRIPTION:
21 ;; DESCRIP-END.
22
23 ;;; ************************************************************************
24 ;;; Public variables
25 ;;; ************************************************************************
26
27 (defvar hyperb:host-domain nil
28 "<@domain-name> for current host. Set automatically by 'hyperb:init'.")
29
30 ;;; ************************************************************************
31 ;;; Other required Elisp libraries
32 ;;; ************************************************************************
33
34 (require 'hvar)
35
36 (mapcar 'require '(hui-mouse hypb hui hui-mini hbmap hibtypes))
37
38 ;;; ************************************************************************
39 ;;; Public functions
40 ;;; ************************************************************************
41
42 (if (not (fboundp 'br-in-browser))
43 ;; Then the OO-Browser is not loaded, so we can never be within the
44 ;; browser. Define this as a dummy function that always returns nil
45 ;; until the OO-Browser is ever loaded.
46 (defun br-in-browser ()
47 "Always returns nil since the OO-Browser is not loaded."
48 nil))
49
50 (defun hyperb:init ()
51 "Standard configuration routine for Hyperbole."
52 (interactive)
53 (run-hooks 'hyperb:init-hook)
54 (hyperb:check-dir-user)
55 (or hyperb:host-domain (setq hyperb:host-domain (hypb:domain-name)))
56 (hyperb:act-set)
57 ;;
58 ;; Save button attribute file whenever same dir file is saved and
59 ;; 'ebut:hattr-save' is non-nil.
60 ;;
61 (var:append 'write-file-hooks '(hattr:save))
62 ;;
63 (hyperb:init-menubar))
64
65 (defun hyperb:init-menubar ()
66 "Add a pulldown menu for Hyperbole, if appropriate."
67 (and hyperb:window-system
68 (or hyperb:lemacs-p
69 (if hyperb:emacs19-p
70 (require 'lmenu)))
71 (require 'hui-menu)
72 ;; XEmacs or Emacs19 under a window system; add Hyperbole menu to
73 ;; menubar.
74 (hyperbole-menubar-menu)))
75
76 (defun hyperb:act-set ()
77 "COORDINATION IS NOT YET OPERATIONAL. hui-coord.el IS NOT INCLUDED.
78 Sets Hyperbole action command to uncoordinated or coordinated operation.
79 Coordinated is used when 'hcoord:hosts' is a non-nil list.
80 See \"hui-coord.el\"."
81 (interactive)
82 (fset 'hyperb:act (if (and (boundp 'hcoord:hosts) hcoord:hosts)
83 'hcoord:act 'hbut:act)))
84
85
86 ;;; ************************************************************************
87 ;;; Private functions
88 ;;; ************************************************************************
89
90 (defun hyperb:check-dir-user ()
91 "Ensures 'hbmap:dir-user' exists and is writable or signals an error."
92 (if (or (null hbmap:dir-user) (not (stringp hbmap:dir-user))
93 (and (setq hbmap:dir-user (file-name-as-directory
94 (expand-file-name hbmap:dir-user)))
95 (file-directory-p hbmap:dir-user)
96 (not (file-writable-p (directory-file-name hbmap:dir-user)))))
97 (error
98 "(hyperb:init): 'hbmap:dir-user' must be a writable directory name."))
99 (let ((hbmap:dir-user (directory-file-name hbmap:dir-user)))
100 (or (file-directory-p hbmap:dir-user) ;; Exists and is writable.
101 (let* ((parent-dir (file-name-directory
102 (directory-file-name hbmap:dir-user))))
103 (cond
104 ((not (file-directory-p parent-dir))
105 (error
106 "(hyperb:init): 'hbmap:dir-user' parent dir does not exist."))
107 ((not (file-writable-p parent-dir))
108 (error
109 "(hyperb:init): 'hbmap:dir-user' parent directory not writable."))
110 ((or (if (fboundp 'make-directory)
111 (progn (make-directory hbmap:dir-user) t))
112 (hypb:call-process-p "mkdir" nil nil hbmap:dir-user))
113 (or (file-writable-p hbmap:dir-user)
114 (or (progn (hypb:chmod '+ 700 hbmap:dir-user)
115 (file-writable-p hbmap:dir-user))
116 (error "(hyperb:init): Can't write to 'hbmap:dir-user'.")
117 )))
118 (t (error "(hyperb:init): 'hbmap:dir-user' create failed."))))))
119 t)
120
121 (provide 'hinit)
122