;;
;; Hypercard
;;
(if (and local-disk nil)		; disabled Hypercard
    (progn
      (setq hyperB-load-hooks 
	    '(lambda () 
	       (require 'hyperB-x)
	       (install-all-hyperB-x-handlers)))

      (require 'hyperB)

      (setq hyperB:hypercard-view-mode t) ; nil: find-file instead of view-file

      (if window-system
	  (progn
	    (require 'x-mouse)
	    (define-key mouse-map x-button-c-left     'x-mouse-hyperB-down) 
	    (define-key mouse-map x-button-c-left-up  'x-mouse-hyperB-up))
	(message "No x-mouse"))

      (global-set-key "\M-+" 'call-hyperB)
      (global-set-key "\M--" 
		      '(lambda ()
			 (interactive)
			 (find-file '"~/.HyperCard/Buttons")
			 (delete-other-windows)
			 ))

      (define-global-hyperB 'hyperB
	"^\\s *Trash:\\s *\\(\\S +\\)\\s *$"
	'(let ((dname (substring hyperB-name 
				 (match-beginning 1) (match-end 1))))
	   (if (file-directory-p dname) ()
	     (if (featurep 'fnexpand)
		 (setq dname (read-file-name-internal dname nil nil))))
     
	   (find-dired dname
		       '"-name core -o -name \"?tza*\" -o -name \"mist*\" ")
	   nil))
  
      (define-global-hyperB 'hyperB
	"^\\s *TAGS:\\s *\\(\\S +\\)\\s *$"
	'(let (fname (tags (substring hyperB-name 
				      (match-beginning 1) (match-end 1))))
	   (cond ((string-equal tags '"emacs-c") 
		  (setq fname "$LEMACSHOME/src" ))
		 (t (setq fname '"$LEMACSHOME/lisp")))
	    
	   (if (file-directory-p fname) ()
	     (if (featurep 'fnexpand)
		 (setq fname (read-file-name-internal fname nil nil))))
	   (visit-tags-table fname)))
  
      (define-global-hyperB 'hyperB 
	"^\\s *Card:\\s *\\(\\S +\\)\\s *$"
	'(hyperB:goto-card (substring hyperB-name 
				      (match-beginning 1) (match-end 1))))
      (define-global-hyperB 'hyperB 
	"^\\s *Load:\\s *\\(\\S +\\)\\s *$"
	'(load-library (substring hyperB-name 
				  (match-beginning 1) (match-end 1))))

      (define-global-hyperB 'hyperB "ReadMail" 
	'(if (fboundp 'vm) (vm) (rmail)))

      (define-global-hyperB 'hyperB "CompileMe" 
	'(byte-compile-file buffer-file-name))

      (define-global-hyperB 'hyperB "BrickWall" '(doctor))

      (define-global-hyperB 'hyperB "RSA" '(call-interactively 'rsa-buffer))

      (define-global-hyperB 'hyperB "Encrypt" 
	'(progn (compress-buffer)
		(call-interactively 'rsa-buffer)))

      (define-global-hyperB 'hyperB "Decrypt" 
	'(progn (call-interactively 'rsa-buffer)
		(un-compress-buffer)))

      (define-global-hyperB 'hyperB "BibDB" 
	'(find-file (concat (getenv "LTEXHOME") '"/bib/bibdb.ste")))

      (define-global-hyperB 'hyperB
	"^\\s *Split:\\s *\\(\\S +\\)\\s *$"
	'(progn
	   (split-window-horizontally 
	    (string-to-int (substring hyperB-name 
				      (match-beginning 1) (match-end 1))))
	   nil))

      (setq include-file-path 
	    (list
	     '"/usr/include"
	     '"/usr/local/X11R5/include"))
      ))					       ; if local-disk

