1 ;;; hinit.el --- Standard initializations for Hyperbole hypertext system.
3 ;; Copyright (C) 1991-1995, 2004, 2006 Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: hypermedia
10 ;; This file is part of GNU Hyperbole.
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
35 (defvar hyperb:host-domain nil
36 "<@domain-name> for current host. Set automatically by 'hyperb:init'.")
39 ;;; Other required Elisp libraries
44 (mapcar 'require '(hui-mouse hypb hui hui-mini hbmap hibtypes))
50 (if (not (fboundp 'br-in-browser))
51 ;; Then the OO-Browser is not loaded, so we can never be within the
52 ;; browser. Define this as a dummy function that always returns nil
53 ;; until the OO-Browser is ever loaded.
54 (defun br-in-browser ()
55 "Always returns nil since the OO-Browser is not loaded."
59 "Standard configuration routine for Hyperbole."
61 (run-hooks 'hyperb:init-hook)
62 (hyperb:check-dir-user)
63 (or hyperb:host-domain (setq hyperb:host-domain (hypb:domain-name)))
66 ;; Save button attribute file whenever same dir file is saved and
67 ;; 'ebut:hattr-save' is non-nil.
69 (var:append 'write-file-hooks '(hattr:save))
71 (if hyperbole-on-menubar (hyperb:init-menubar)))
73 (defun hyperb:init-menubar ()
74 "Add a pulldown menu for Hyperbole, if appropriate."
75 (and hyperb:window-system
77 ;; XEmacs or Emacs19 under a window system; add Hyperbole menu to
79 (hyperbole-menubar-menu)))
81 (defcustom hyperbole-on-menubar t
82 "Whether the hyperbole menu should be on the menubar."
85 :set (lambda (symb val)
89 (hyperb:init-menubar)))
92 (defun hyperb:act-set ()
93 "COORDINATION IS NOT YET OPERATIONAL. hui-coord.el IS NOT INCLUDED.
94 Sets Hyperbole action command to uncoordinated or coordinated operation.
95 Coordinated is used when 'hcoord:hosts' is a non-nil list.
96 See \"hui-coord.el\"."
98 (fset 'hyperb:act (if (and (boundp 'hcoord:hosts) hcoord:hosts)
99 'hcoord:act 'hbut:act)))
103 ;;; Private functions
106 (defun hyperb:check-dir-user ()
107 "Ensures 'hbmap:dir-user' exists and is writable or signals an error."
108 (if (or (null hbmap:dir-user) (not (stringp hbmap:dir-user))
109 (and (setq hbmap:dir-user (file-name-as-directory
110 (expand-file-name hbmap:dir-user)))
111 (file-directory-p hbmap:dir-user)
112 (not (file-writable-p (directory-file-name hbmap:dir-user)))))
114 "(hyperb:init): 'hbmap:dir-user' must be a writable directory name."))
115 (let ((hbmap:dir-user (directory-file-name hbmap:dir-user)))
116 (or (file-directory-p hbmap:dir-user) ;; Exists and is writable.
117 (let* ((parent-dir (file-name-directory
118 (directory-file-name hbmap:dir-user))))
120 ((not (file-directory-p parent-dir))
122 "(hyperb:init): 'hbmap:dir-user' parent dir does not exist."))
123 ((not (file-writable-p parent-dir))
125 "(hyperb:init): 'hbmap:dir-user' parent directory not writable."))
126 ((or (if (fboundp 'make-directory)
127 (progn (make-directory hbmap:dir-user) t))
128 (hypb:call-process-p "mkdir" nil nil hbmap:dir-user))
129 (or (file-writable-p hbmap:dir-user)
130 (or (progn (hypb:chmod '+ 700 hbmap:dir-user)
131 (file-writable-p hbmap:dir-user))
132 (error "(hyperb:init): Can't write to 'hbmap:dir-user'.")
134 (t (error "(hyperb:init): 'hbmap:dir-user' create failed."))))))
139 ;;; hinit.el ends here