annotate lisp/hyperbole/hsys-hbase.el @ 36:c53a95d3c46d r19-15b101

Import from CVS: tag r19-15b101
author cvs
date Mon, 13 Aug 2007 08:53:38 +0200
parents 376386a54a3c
children
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: hsys-hbase.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Hyperbole support for the Hyperbase 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: comm, 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: 16-Oct-91 at 04:35:09
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 30-Oct-95 at 22:31:23 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 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; For information and the source to HyperBase and follow-on hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; work, see: ftp://ftp.iesd.auc.dk/pub/packages/hypertext/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; In order to use this package, you must have the HyperBase system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; and must start up a HyperBase server and then load the HyperBase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Epoch support software that comes with the HyperBase system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; Then load this package and Hyperbole will do the following when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; in a Hyperbase buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Action Key press on a button follows the link, within any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; text, closes current Epoch screen and kills node buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Assist Key press shows attributes for the current button or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; for the current node buffer, if no current button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (require 'hbut)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defib hyperbase ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Detects link buttons in buffers that communicate with the Hyperbase system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Hyperbase is a hypertext database system that interfaces to Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (and (boundp 'ehts-mode) ehts-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (let ((lbl (or (ebut:label-p 'as-label "[-> " "]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "no-but")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (ibut:label-set lbl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (hact 'hyperbase lbl))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defact hyperbase (linkname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "Follows LINKNAME in a buffer that communicates with the Hyperbase system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 If LINKNAME equals t, closes the current Epoch screen and kill the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 buffer of the current Hyperbase node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Hyperbase is a hypertext database system that interfaces to Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; From hb-EHTS.el by:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; Uffe Kock Wiil (kock@iesd.auc.dk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Claus Bo Nielsen (cbn@cci.dk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if (equal linkname "no-but")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (progn (ehts-mouse-kill-screen-and-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (and (fboundp 'epoch::select-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (epoch::select-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (let ((linknum (cdr (assoc linkname ehts-node-link-alist))) tonode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (ehts-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if (< (ehts-hb-sys-call "read" linknum "to data node no" nil t) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (ehts-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (error "Can't read \"to data node no\" in link, panic !!!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (ehts-read-4bytes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq tonode (ehts-read-4bytes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (< (ehts-hb-sys-call "read" tonode "n name" nil t) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (ehts-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (error "Can't read \"name\" in data node, panic !!!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (ehts-get-node (ehts-read-null-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (and (fboundp 'hproperty:but-create-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (hproperty:but-create-all "[-> " "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (ehts-command nil))))
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 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun hyperbase:init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Show initial set of Hyperbase buttons."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (assoc (user-full-name) ehts-node-name-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (ehts-get-node (user-full-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let (buffer screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (setq buffer "*Ehts Welcome*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq screen (ehts-find-buffer-screen buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (kill-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (switch-to-buffer (user-full-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (remove-screen screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (if (assoc "dir ehts help" ehts-node-name-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (ehts-get-node "dir ehts help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (let (buffer screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq buffer "*Ehts Welcome*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq screen (ehts-find-buffer-screen buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (kill-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (switch-to-buffer "dir ehts help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (remove-screen screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (hproperty:but-create "[-> " "]"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defun hyperbase:help (&optional but)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 "Displays attributes of a link button BUT if on one or of the current node.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Hyperbase is a hypertext database system that interfaces to Emacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (interactive (list (ibut:at-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (or (and (boundp 'ehts-mode) ehts-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (error "(hyperbase:help): Not in a Hyperbase mode buffer."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (hyperbase:attr-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (or (and (symbolp but)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (let ((lbl (ebut:key-to-label (hattr:get but 'lbl-key))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if (not (equal lbl "no-but")) lbl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defun hyperbase:already-displayed-p (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "Test if a buffer allready is displayed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let (screenid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (setq screenid (ehts-find-buffer-screen name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if screenid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (switch-screen screenid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun hyperbase:attr-help (node-link-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "Show the attributes of a node or a button link from NODE-LINK-SPEC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 A string value of NODE-LINK-SPEC means show attributes for that button link.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 A buffer value means show attributes for the node in that buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (or (stringp node-link-spec) (bufferp node-link-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (error "(hyperbase-show-attributes): Non-string or buffer argument."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let (entity name string number buffer screenid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq buffer (if (bufferp node-link-spec) (buffer-name node-link-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 entity (cdr (assoc (if buffer "node" "link") node-link-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 buffer (or buffer (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if (eq (string-match "Attributes - " buffer) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if (= entity 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq name (concat "Attributes - " buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if (not (hyperbase:already-displayed-p name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (setq number (cdr (assoc buffer ehts-node-name-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 string (ehts-create-node-attribute-string number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (ehts-setup-attribute-screen name string entity buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (if (eq ehts-node-link-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (error "No links in this node."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (setq name (concat "Attributes - "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (car (assoc node-link-spec ehts-node-link-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (not (hyperbase:already-displayed-p name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq number (cdr (assoc (substring name 13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ehts-node-link-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 string (ehts-create-link-attribute-string number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (ehts-setup-attribute-screen name string entity buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (provide 'hsys-hbase)