annotate lisp/hyperbole/hinit.el @ 9:6f2bbbbbe05a

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