0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hui-mini.el
|
|
4 ;; SUMMARY: One line command menus for Hyperbole
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: hypermedia, mouse
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
24
|
9 ;; ORG: InfoDock Associates
|
0
|
10 ;;
|
|
11 ;; ORIG-DATE: 15-Oct-91 at 20:13:17
|
24
|
12 ;; LAST-MOD: 20-Feb-97 at 11:30:44 by Bob Weiner
|
0
|
13 ;;
|
|
14 ;; This file is part of Hyperbole.
|
|
15 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
16 ;;
|
24
|
17 ;; Copyright (C) 1991-1997, Free Software Foundation, Inc.
|
0
|
18 ;; Developed with support from Motorola Inc.
|
|
19 ;;
|
|
20 ;; DESCRIPTION:
|
|
21 ;; DESCRIP-END.
|
|
22
|
|
23 ;;; ************************************************************************
|
|
24 ;;; Other required Elisp libraries
|
|
25 ;;; ************************************************************************
|
|
26
|
|
27 (require 'hypb)
|
|
28
|
|
29 ;;; ************************************************************************
|
|
30 ;;; Public variables
|
|
31 ;;; ************************************************************************
|
|
32
|
|
33 (defvar hui:menu-select "\C-m"
|
|
34 "*Upper case char-string which selects the Hyperbole menu item at point.")
|
|
35 (defvar hui:menu-quit "Q"
|
|
36 "*Upper case char-string which quits selecting from a Hyperbole menu item.")
|
|
37 (defvar hui:menu-abort "\C-g"
|
|
38 "*Same function as 'hui:menu-quit'.")
|
|
39 (defvar hui:menu-top "\C-t"
|
|
40 "*Character which returns to top Hyperbole menu.")
|
|
41
|
|
42 (defvar hui:menu-p nil
|
|
43 "Non-nil iff a current Hyperbole menu activation exists.")
|
|
44
|
|
45 (defvar hui:menus nil
|
|
46 "Command menus for use with the default Hyperbole user interface.")
|
|
47 (setq
|
|
48 hui:menus
|
|
49 (delq nil
|
|
50 (list (cons
|
|
51 'hyperbole
|
|
52 (append
|
|
53 (let ((version (if (= (aref hyperb:version 0) ?0)
|
|
54 (substring hyperb:version 1)
|
|
55 hyperb:version)))
|
|
56 (list (list (concat "Hy" version ">"))))
|
|
57 (delq nil
|
|
58 (list
|
|
59 '("Act" hui:hbut-act
|
|
60 "Activates button at point or prompts for explicit button.")
|
|
61 '("Butfile/" (menu . butfile)
|
|
62 "Quick access button files menus.")
|
24
|
63 '("Cust/" (menu . cust)
|
|
64 "Customizes Hyperbole by setting major options.")
|
0
|
65 '("Doc/" (menu . doc)
|
|
66 "Quick access to Hyperbole documentation.")
|
|
67 '("Ebut/" (menu . ebut)
|
|
68 "Explicit button commands.")
|
|
69 '("Gbut/" (menu . gbut)
|
|
70 "Global button commands.")
|
|
71 '("Hist" (hhist:remove current-prefix-arg)
|
|
72 "Jumps back to location prior to last Hyperbole button follow.")
|
|
73 '("Ibut/" (menu . ibut)
|
|
74 "Implicit button and button type commands.")
|
|
75 '("Msg/" (menu . msg)
|
|
76 "Mail and News messaging facilities.")
|
|
77 (if hyperb:kotl-p
|
|
78 '("Otl/" (menu . otl)
|
|
79 "Autonumbered outlining and hyper-node facilities."))
|
|
80 '("Rolo/" (menu . rolo)
|
|
81 "Hierarchical, multi-file rolodex lookup and edit commands.")
|
|
82 '("Win/" (menu . win)
|
|
83 "Window configuration management command.")
|
|
84 ))))
|
|
85 '(butfile .
|
|
86 (("Butfile>")
|
|
87 ("DirFile" (find-file hbmap:filename)
|
|
88 "Edits directory-specific button file.")
|
|
89 ("Info"
|
|
90 (id-info "(hyperbole.info)Button Files")
|
|
91 "Displays manual section on button files.")
|
|
92 ("PersonalFile" (find-file
|
|
93 (expand-file-name hbmap:filename hbmap:dir-user))
|
|
94 "Edits user-specific button file.")
|
|
95 ))
|
24
|
96 '(cust .
|
|
97 (("Customize>")
|
|
98 ("Referent-Display/" (menu . cust-referents)
|
|
99 "Sets where referents are displayed.")
|
|
100 ("Smart-Key-at-Eol/" (menu . cust-eol)
|
|
101 "Sets how scrolling via end of line presses works.")
|
|
102 ("URL-Display/" (menu . cust-urls) "Sets where URLs are displayed.")))
|
|
103 '(cust-eol .
|
|
104 (("Smart Key press at eol scrolls>")
|
|
105 ("Proportionally" (setq smart-scroll-proportional t))
|
|
106 ("Windowful" (setq smart-scroll-proportional nil))))
|
|
107 '(cust-referents .
|
|
108 (("Ref display>")
|
|
109 ("Any-Frame" (setq hpath:display-where 'other-frame))
|
|
110 ("Current-Win" (setq hpath:display-where 'this-window))
|
|
111 ("Diff-Frame-One-Win"
|
|
112 (setq hpath:display-where 'other-frame-one-window))
|
|
113 ("New-Frame" (setq hpath:display-where 'new-frame))
|
|
114 ("Other-Win" (setq hpath:display-where 'other-window))
|
|
115 ("Single-Win" (setq hpath:display-where 'one-window))))
|
|
116 '(cust-urls .
|
|
117 (("URL display>")
|
|
118 ("Any-Netscape-Window"
|
|
119 (setq action-key-url-function 'highlight-headers-follow-url-netscape
|
|
120 highlight-headers-follow-url-function action-key-url-function
|
|
121 highlight-headers-follow-url-netscape-new-window nil))
|
|
122 ("New-Netscape-Window"
|
|
123 (setq action-key-url-function 'highlight-headers-follow-url-netscape
|
|
124 highlight-headers-follow-url-function action-key-url-function
|
|
125 highlight-headers-follow-url-netscape-new-window t))
|
|
126 ("Mosaic" (setq action-key-url-function
|
|
127 'highlight-headers-follow-url-mosaic
|
|
128 highlight-headers-follow-url-function
|
|
129 action-key-url-function))
|
|
130 ("W3-Browser"
|
|
131 (setq action-key-url-function 'w3-fetch
|
|
132 highlight-headers-follow-url-function
|
|
133 action-key-url-function))))
|
0
|
134 '(doc .
|
|
135 (("Doc>")
|
24
|
136 ("About" (hypb:display-file-with-logo
|
|
137 (expand-file-name "ABOUT" hyperb:dir))
|
|
138 "Overview of Hyperbole and InfoDock Associates.")
|
0
|
139 ("Demo" (find-file-read-only
|
|
140 (expand-file-name "DEMO" hyperb:dir))
|
|
141 "Demonstrates Hyperbole features.")
|
|
142 ("Files" (find-file-read-only
|
|
143 (expand-file-name "MANIFEST" hyperb:dir))
|
|
144 "Summarizes Hyperbole system files. Click on an entry to view it.")
|
|
145 ("Glossary"
|
|
146 (id-info "(hyperbole.info)Glossary")
|
|
147 "Glossary of Hyperbole terms.")
|
|
148 ("HypbCopy" (id-info "(hyperbole.info)Top")
|
|
149 "Displays general Hyperbole copyright and license details.")
|
|
150 ("Info" (id-info "(hyperbole.info)Top")
|
|
151 "Online Info version of Hyperbole manual.")
|
|
152 ("MailLists" (id-info "(hyperbole.info)Mail Lists")
|
|
153 "Details on Hyperbole mail list subscriptions.")
|
|
154 ("New" (progn
|
|
155 (hact 'link-to-regexp-match
|
|
156 "\\*[ \t]+What's New" 2
|
|
157 (expand-file-name "README" hyperb:dir))
|
|
158 (setq buffer-read-only nil)
|
|
159 (toggle-read-only))
|
|
160 "Recent changes to Hyperbole.")
|
|
161 ("SmartKy" (find-file-read-only (hypb:mouse-help-file))
|
|
162 "Summarizes Smart Key mouse or keyboard handling.")
|
|
163 ("Types/" (menu . types)
|
|
164 "Provides documentation on Hyperbole types.")
|
|
165 ))
|
|
166 '(ebut .
|
|
167 (("EButton>")
|
|
168 ("Act" hui:hbut-act
|
|
169 "Activates button at point or prompts for explicit button.")
|
|
170 ("Create" hui:ebut-create)
|
|
171 ("Delete" hui:ebut-delete)
|
|
172 ("Edit" hui:ebut-modify "Modifies any desired button attributes.")
|
|
173 ("Help/" (menu . ebut-help) "Summarizes button attributes.")
|
|
174 ("Info"
|
|
175 (id-info "(hyperbole.info)Explicit Buttons")
|
|
176 "Displays manual section on explicit buttons.")
|
|
177 ("Modify" hui:ebut-modify "Modifies any desired button attributes.")
|
|
178 ("Rename" hui:ebut-rename "Relabels an explicit button.")
|
|
179 ("Search" hui:ebut-search
|
|
180 "Locates and displays personally created buttons in context.")
|
|
181 ))
|
|
182 '(ebut-help .
|
|
183 (("Help on>")
|
|
184 ("BufferButs" (hui:hbut-report -1)
|
|
185 "Summarizes all explicit buttons in buffer.")
|
|
186 ("CurrentBut" (hui:hbut-report)
|
|
187 "Summarizes only current button in buffer.")
|
|
188 ("OrderedButs" (hui:hbut-report 1)
|
|
189 "Summarizes explicit buttons in lexicographically order.")
|
|
190 ))
|
|
191 '(gbut .
|
|
192 (("GButton>")
|
|
193 ("Act" gbut:act "Activates global button by name.")
|
|
194 ("Create" hui:gbut-create "Adds a global button to gbut:file.")
|
|
195 ("Edit" hui:gbut-modify "Modifies global button attributes.")
|
|
196 ("Help" gbut:help "Reports on a global button by name.")
|
|
197 ("Info" (id-info "(hyperbole.info)Global Buttons")
|
|
198 "Displays manual section on global buttons.")
|
|
199 ("Modify" hui:gbut-modify "Modifies global button attributes.")
|
|
200 ))
|
|
201 '(ibut .
|
|
202 (("IButton>")
|
24
|
203 ("Act" hui:hbut-current-act "Activates implicit button at point.")
|
0
|
204 ("DeleteIButType" (hui:htype-delete 'ibtypes)
|
|
205 "Deletes specified button type.")
|
|
206 ("Help" hui:hbut-help "Reports on button's attributes.")
|
|
207 ("Info" (id-info "(hyperbole.info)Implicit Buttons")
|
|
208 "Displays manual section on implicit buttons.")
|
|
209 ("Types" (hui:htype-help 'ibtypes 'no-sort)
|
|
210 "Displays documentation for one or all implicit button types.")
|
|
211 ))
|
|
212 '(msg .
|
|
213 (("Msg>")
|
|
214 ("Compose-Hypb-Mail"
|
24
|
215 (hmail:compose "hyperbole@infodock.com" '(hact 'hyp-config))
|
0
|
216 "Send a message to the Hyperbole discussion list.")
|
|
217 ("Edit-Hypb-List-Entry"
|
24
|
218 (hmail:compose "hyperbole-request@infodock.com"
|
0
|
219 '(hact 'hyp-request))
|
|
220 "Add, remove or change your entry on a the Hyperbole mail list.")
|
|
221 ("Modify-Hypb-Announce-Entry"
|
24
|
222 (hmail:compose "hyperbole-announce-request@infodock.com"
|
0
|
223 '(hact 'hyp-request))
|
|
224 "Add, remove or change your entry on the Hyperbole Announce mail list.")
|
|
225 ))
|
|
226 (if hyperb:kotl-p
|
|
227 '(otl
|
|
228 . (("Otl>")
|
|
229 ("All" kotl-mode:show-all "Expand all collapsed cells.")
|
|
230 ("Blanks" kvspec:toggle-blank-lines
|
|
231 "Toggle blank lines between cells on or off.")
|
|
232 ("Create" kfile:find "Create or edit an outline file.")
|
|
233 ("Downto" kotl-mode:hide-sublevels
|
|
234 "Hide all cells in outline deeper than a particular level.")
|
|
235 ("Examp" (find-file-read-only
|
|
236 (expand-file-name
|
|
237 "EXAMPLE.kotl" (concat hyperb:dir "kotl/")))
|
|
238 "Display a self-descriptive example outline file.")
|
|
239 ("Hide" (progn (kotl-mode:is-p)
|
|
240 (kotl-mode:hide-tree (kcell-view:label)))
|
|
241 "Collapse tree rooted at point.")
|
|
242 ("Info"
|
|
243 (id-info "(hyperbole.info)Outliner")
|
|
244 "Display manual section on Hyperbole outliner.")
|
|
245 ("Kill" kotl-mode:kill-tree
|
|
246 "Kill ARG following trees starting from point.")
|
|
247 ("Link" klink:create
|
|
248 "Create and insert an implicit link at point.")
|
|
249 ("Overvw" kotl-mode:overview
|
|
250 "Show first line of each cell.")
|
|
251 ("Show" (progn (kotl-mode:is-p)
|
|
252 (kotl-mode:show-tree (kcell-view:label)))
|
|
253 "Expand tree rooted at point.")
|
|
254 ("Top" kotl-mode:top-cells
|
|
255 "Hide all but top-level cells.")
|
|
256 ("Vspec" kvspec:activate
|
|
257 "Prompt for and activate a view specifiction.")
|
|
258 )))
|
|
259 '(rolo .
|
|
260 (("Rolo>")
|
|
261 ("Add" rolo-add "Add a new rolo entry.")
|
|
262 ("Display" rolo-display-matches
|
|
263 "Display last found rolodex matches again.")
|
|
264 ("Edit" rolo-edit "Edit an existing rolo entry.")
|
|
265 ("Info" (id-info "(hyperbole.info)Rolodex")
|
|
266 "Displays manual section on Hyperbole rolodex.")
|
|
267 ("Kill" rolo-kill "Kill an existing rolo entry.")
|
|
268 ("Mail" rolo-mail-to "Mail to address following point.")
|
|
269 ("Order" rolo-sort "Order rolo entries in a file.")
|
|
270 ("RegexFind" rolo-grep "Find entries containing a regexp.")
|
|
271 ("StringFind" rolo-fgrep "Find entries containing a string.")
|
|
272 ("WordFind" rolo-word "Find entries containing words.")
|
|
273 ("Yank" rolo-yank
|
|
274 "Find an entry containing a string and insert it at point.")
|
|
275 ))
|
|
276 '(types .
|
|
277 (("Types>")
|
|
278 ("ActionTypes" (hui:htype-help 'actypes)
|
|
279 "Displays documentation for one or all action types.")
|
|
280 ("IButTypes" (hui:htype-help 'ibtypes 'no-sort)
|
|
281 "Displays documentation for one or all implicit button types.")
|
|
282 ))
|
|
283 '(win .
|
|
284 (("WinConfig>")
|
|
285 ("AddName" wconfig-add-by-name
|
|
286 "Name current window configuration.")
|
|
287 ("DeleteName" wconfig-delete-by-name
|
|
288 "Delete named window configuration.")
|
|
289 ("RestoreName" wconfig-restore-by-name
|
|
290 "Restore frame to window configuration given by name.")
|
|
291 ("PopRing" (progn (wconfig-delete-pop)
|
|
292 (hyperbole 'win))
|
|
293 "Restores window configuration from ring and removes it from ring.")
|
|
294 ("SaveRing" (wconfig-ring-save)
|
|
295 "Saves current window configuration to ring.")
|
|
296 ("YankRing" (progn (call-interactively 'wconfig-yank-pop)
|
|
297 (hyperbole 'win))
|
|
298 "Restores next window configuration from ring.")
|
|
299 ))
|
|
300 )))
|
|
301
|
|
302 ;;; ************************************************************************
|
|
303 ;;; Public functions
|
|
304 ;;; ************************************************************************
|
|
305
|
|
306 ;;; Old name
|
|
307 (fset 'hui:menu 'hyperbole)
|
|
308
|
|
309 ;;; Used as autoloaded main entry point to Hyperbole (but hsite.el) is the
|
|
310 ;;; file that is autoloaded when this is invoked.
|
|
311 ;;; It brings up a menu of commands.
|
|
312 (defun hyperbole (&optional menu menu-list)
|
|
313 "Invokes default Hyperbole menu user interface when not already active.
|
|
314 Suitable for binding to a key, e.g. {C-h h}.
|
|
315 Non-interactively, returns t if menu is actually invoked by call, else nil.
|
|
316
|
|
317 Two optional arguments may be given to invoke alternative menus.
|
|
318 MENU (a symbol) specifies the menu to invoke from MENU-LIST, (a
|
|
319 Hyperbole menu list structure). MENU defaults to 'hyperbole and MENU-LIST
|
|
320 to `hui:menus'. See `hui:menus' definition for the format of the menu list
|
|
321 structure."
|
|
322
|
|
323 (interactive)
|
|
324 (if (and hui:menu-p (> (minibuffer-depth) 0))
|
|
325 (progn (beep) nil)
|
|
326 (unwind-protect
|
|
327 (progn
|
|
328 (require 'hsite) ;; Since "hui-mini" may be loaded without loading
|
|
329 ;; all of Hyperbole.
|
|
330 (hyperb:init-menubar)
|
|
331 (setq hui:menu-p t)
|
|
332 (hui:menu-act (or menu 'hyperbole) menu-list)
|
|
333 t)
|
|
334 (setq hui:menu-p nil))))
|
|
335
|
|
336 (defun hui:menu-act (menu &optional menu-list)
|
|
337 "Prompts user with Hyperbole MENU (a symbol) and performs selected item.
|
|
338 Optional second argument MENU-LIST is a Hyperbole menu list structure from
|
|
339 which to extract MENU. It defaults to `hui:menus'. See its definition for
|
|
340 the menu list structure."
|
|
341 (let ((set-menu '(or (and menu (symbolp menu)
|
|
342 (setq menu-alist
|
|
343 (cdr (assq menu (or menu-list hui:menus)))))
|
|
344 (hypb:error "(menu-act): Invalid menu symbol arg: %s"
|
|
345 menu)))
|
|
346 (show-menu t)
|
|
347 (rtn)
|
|
348 menu-alist act-form)
|
|
349 (while (and show-menu (eval set-menu))
|
|
350 (cond ((and (consp (setq act-form (hui:menu-select menu-alist)))
|
|
351 (cdr act-form)
|
|
352 (symbolp (cdr act-form)))
|
|
353 ;; Display another menu
|
|
354 (setq menu (cdr act-form)))
|
|
355 (act-form
|
|
356 (let ((prefix-arg current-prefix-arg))
|
|
357 (cond ((symbolp act-form)
|
|
358 (if (eq act-form t)
|
|
359 nil
|
|
360 (setq show-menu nil
|
|
361 rtn (call-interactively act-form))))
|
|
362 ((stringp act-form)
|
|
363 (hui:menu-help act-form)
|
|
364 ;; Loop and show menu again.
|
|
365 )
|
|
366 (t (setq show-menu nil
|
|
367 rtn (eval act-form))))))
|
|
368 (t (setq show-menu nil))))
|
|
369 rtn))
|
|
370
|
|
371 (defun hui:menu-enter (&optional char-str)
|
|
372 "Uses CHAR-STR or last input character as minibuffer argument."
|
|
373 (interactive)
|
|
374 (let ((input (or char-str (aref (recent-keys) (1- (length (recent-keys)))))))
|
|
375 (cond (hyperb:emacs19-p
|
|
376 (and (not (integerp input))
|
|
377 (eventp input)
|
|
378 (setq input (event-basic-type input))))
|
|
379 (hyperb:lemacs-p
|
|
380 (if (eventp input)
|
|
381 (setq input (event-to-character input)))))
|
|
382 (if (or (symbolp input)
|
|
383 (and (integerp input)
|
|
384 (= input ?\r)))
|
|
385 (setq input (hargs:at-p)))
|
|
386 (erase-buffer)
|
|
387 (or (symbolp input) (insert input)))
|
|
388 (exit-minibuffer))
|
|
389
|
|
390 (defun hui:menu-help (help-str)
|
|
391 "Displays HELP-STR in a small window. HELP-STR must be a string."
|
|
392 (let* ((window-min-height 2)
|
|
393 (owind (selected-window))
|
|
394 (buf-name (hypb:help-buf-name "Menu")))
|
|
395 (unwind-protect
|
|
396 (progn
|
|
397 (save-window-excursion
|
|
398 (hkey-help-show buf-name)) ;; Needed to save wconfig.
|
|
399 (if (eq (selected-window) (minibuffer-window))
|
|
400 (other-window 1))
|
|
401 (if (= (length (hypb:window-list 'no-mini)) 1)
|
|
402 (split-window-vertically nil))
|
|
403 (select-window (hui:bottom-window))
|
|
404 (switch-to-buffer (get-buffer-create buf-name))
|
|
405 (setq buffer-read-only nil)
|
|
406 (erase-buffer)
|
|
407 (insert "\n" help-str)
|
|
408 (set-buffer-modified-p nil)
|
|
409 (shrink-window
|
|
410 (- (window-height)
|
|
411 (+ 3 (length
|
|
412 (delq nil
|
|
413 (mapcar (function
|
|
414 (lambda (chr) (= chr ?\n)))
|
|
415 help-str)))))))
|
|
416 (select-window owind))))
|
|
417
|
|
418 (defun hui:menu-xemacs (&optional menu menu-list)
|
|
419 "Returns an XEmacs menu built from Hyperbole type menus.
|
|
420 Optional MENU (a symbol) specifies a specific submenu of optional MENU-LIST.
|
|
421 a Hyperbole menu list structure. Otherwise, all menus are used.
|
|
422 MENU defaults to 'hyperbole and MENU-LIST to `hui:menus'. See `hui:menus'
|
|
423 definition for the format of the menu list structure."
|
|
424 (mapcar
|
|
425 (function
|
|
426 (lambda (entry)
|
|
427 (or (consp entry)
|
|
428 (error "(hui:menu-xemacs): Invalid menu entry: %s" entry))
|
|
429 (let ((label (car entry))
|
|
430 (content (car (cdr entry))))
|
|
431 (cond ((null content) (hypb:replace-match-string ">$" label "" t))
|
|
432 ((and (consp content) (eq (car content) 'menu))
|
|
433 (hui:menu-xemacs (cdr content)))
|
|
434 (t (vector label content 't))))))
|
|
435 (cdr (assq (or menu 'hyperbole) (or menu-list hui:menus)))))
|
|
436
|
|
437 (defun hui:menu-select (menu-alist)
|
|
438 "Prompts user to choose the first character of any item from MENU-ALIST.
|
|
439 Case is not significant. If chosen by direct selection with the Assist Key,
|
|
440 returns any help string for item, else returns the action form for the item."
|
|
441 (let* ((menu-line (hui:menu-line menu-alist))
|
|
442 (set:equal-op 'eq)
|
|
443 (select-char (string-to-char hui:menu-select))
|
|
444 (quit-char (string-to-char hui:menu-quit))
|
|
445 (abort-char (string-to-char hui:menu-abort))
|
|
446 (top-char (string-to-char hui:menu-top))
|
|
447 (item-keys (mapcar (function
|
|
448 (lambda (item) (aref item 0)))
|
|
449 (mapcar 'car (cdr menu-alist))))
|
|
450 (keys (apply 'list select-char quit-char abort-char
|
|
451 top-char item-keys))
|
|
452 (key 0)
|
|
453 (hargs:reading-p 'hmenu)
|
|
454 sublist)
|
|
455 (while (not (memq (setq key (upcase
|
|
456 (string-to-char
|
|
457 (read-from-minibuffer
|
|
458 "" menu-line hui:menu-mode-map))))
|
|
459 keys))
|
|
460 (beep)
|
|
461 (setq hargs:reading-p 'hmenu)
|
|
462 (discard-input))
|
|
463 (cond ((eq key quit-char) nil)
|
|
464 ((eq key abort-char) (beep) nil)
|
|
465 ((eq key top-char) '(menu . hyperbole))
|
|
466 ((and (eq key select-char)
|
|
467 (save-excursion
|
|
468 (if (search-backward " " nil t)
|
|
469 (progn (skip-chars-forward " ")
|
|
470 (setq key (following-char))
|
|
471 nil) ;; Drop through.
|
|
472 t))))
|
|
473 (t (if (setq sublist (memq key item-keys))
|
|
474 (let* ((label-act-help-list
|
|
475 (nth (- (1+ (length item-keys)) (length sublist))
|
|
476 menu-alist))
|
|
477 (act-form (car (cdr label-act-help-list))))
|
|
478 (if (eq hargs:reading-p 'hmenu-help)
|
|
479 (let ((help-str
|
|
480 (or (car (cdr (cdr label-act-help-list)))
|
|
481 "No help documentation for this item.")))
|
|
482 (concat (car label-act-help-list) "\n "
|
|
483 help-str "\n Action: "
|
|
484 (prin1-to-string act-form)))
|
|
485 act-form)))))))
|
|
486
|
|
487 ;;; ************************************************************************
|
|
488 ;;; Private functions
|
|
489 ;;; ************************************************************************
|
|
490
|
|
491 (if (fboundp 'window-lowest-p)
|
|
492 (defun hui:bottom-window ()
|
|
493 "Return a window that is at the bottom of the selected frame."
|
|
494 (let ((winds (hypb:window-list 'no-mini))
|
|
495 (window))
|
|
496 (while (and (not window) winds)
|
|
497 (if (window-lowest-p (car winds))
|
|
498 (setq window (car winds))
|
|
499 (setq winds (cdr winds))))
|
|
500 window))
|
|
501 (defun hui:bottom-window ()
|
|
502 "Return a window that is at the bottom of the selected frame."
|
|
503 (let* ((winds (hypb:window-list 'no-mini))
|
|
504 (bot-list (mapcar
|
|
505 (function
|
|
506 (lambda (wind)
|
|
507 (nth 3 (window-edges wind))))
|
|
508 winds))
|
|
509 (bot (apply 'max bot-list)))
|
|
510 (nth (- (length winds) (length (memq bot bot-list))) winds))))
|
|
511
|
|
512 (defun hui:menu-line (menu-alist)
|
|
513 "Returns a menu line string built from MENU-ALIST."
|
|
514 (let ((menu-prompt (concat (car (car menu-alist)) " "))
|
|
515 (menu-items (mapconcat 'car (cdr menu-alist) " "))
|
|
516 menu-line)
|
|
517 (setq menu-line (concat menu-prompt menu-items))
|
|
518 ;; Narrow menu by changing 2 spaces to 1 if too wide for current frame.
|
|
519 (if (>= (length menu-line) (1- (frame-width)))
|
|
520 (concat menu-prompt (mapconcat 'car (cdr menu-alist) " "))
|
|
521 menu-line)))
|
|
522
|
|
523 ;;; ************************************************************************
|
|
524 ;;; Private variables
|
|
525 ;;; ************************************************************************
|
|
526
|
|
527 ;; Hyperbole menu mode is suitable only for specially formatted data.
|
|
528 (put 'hui:menu-mode 'mode-class 'special)
|
|
529
|
|
530 (defvar hui:menu-mode-map nil
|
|
531 "Keymap containing hui:menu commands.")
|
|
532 (if hui:menu-mode-map
|
|
533 nil
|
|
534 (setq hui:menu-mode-map (make-keymap))
|
|
535 (suppress-keymap hui:menu-mode-map)
|
|
536 (define-key hui:menu-mode-map hui:menu-quit 'hui:menu-enter)
|
|
537 (define-key hui:menu-mode-map hui:menu-abort 'hui:menu-enter)
|
|
538 (define-key hui:menu-mode-map hui:menu-top 'hui:menu-enter)
|
|
539 (define-key hui:menu-mode-map hui:menu-select 'hui:menu-enter)
|
|
540 ;;
|
|
541 ;; This next binding is necessary since the default button1 binding under
|
|
542 ;; XEmacs, mouse-track, is broken under XEmacs V19.8.
|
|
543 (and hyperb:lemacs-p window-system
|
|
544 (define-key hui:menu-mode-map 'button1 'mouse-set-point))
|
|
545 (let ((i 32))
|
|
546 (while (<= i 126)
|
|
547 (define-key hui:menu-mode-map (char-to-string i) 'hui:menu-enter)
|
|
548 (setq i (1+ i)))))
|
|
549
|
|
550 (provide 'hui-mini)
|